Class OperationConverter
- java.lang.Object
-
- net.ssehub.easy.instantiation.serializer.xml.converter.OperationConverter
-
- All Implemented Interfaces:
com.thoughtworks.xstream.converters.Converter,com.thoughtworks.xstream.converters.ConverterMatcher
public class OperationConverter extends java.lang.Object implements com.thoughtworks.xstream.converters.ConverterA type converter for built-in operations. Background: Similar to delegating singletons also operations must be mapped. Therefore, this class writes the signature to the stream and maps back from the signature.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,Operation>OPERATIONSStores the signature-operation-mappings.
-
Constructor Summary
Constructors Constructor Description OperationConverter()Creates an operation converter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanConvert(java.lang.Class cls)Determines whether this converter instance handles the given class.private static java.lang.StringgetSignature(Operation operation)Returns the signature of an operation.voidmarshal(java.lang.Object object, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)Marshals a givenobjectto the givenwriterin the specified marshallingcontext.java.lang.Objectunmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)Unmarshals the current object to be read from the givenreaderin the specified unmarshallingcontext.
-
-
-
Field Detail
-
OPERATIONS
private static final java.util.Map<java.lang.String,Operation> OPERATIONS
Stores the signature-operation-mappings. So far we do not allow operations to be modified dynamically.
-
-
Method Detail
-
getSignature
private static final java.lang.String getSignature(Operation operation)
Returns the signature of an operation.- Parameters:
operation- the operation to return the signature for- Returns:
- the signature of
operation
-
canConvert
public boolean canConvert(java.lang.Class cls)
Determines whether this converter instance handles the given class.- Specified by:
canConvertin interfacecom.thoughtworks.xstream.converters.ConverterMatcher- Parameters:
cls- the class to be tested- Returns:
trueif this instance handlesclass(this is only the case if it is anOperation),falseelse
-
marshal
public void marshal(java.lang.Object object, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)Marshals a givenobjectto the givenwriterin the specified marshallingcontext. This method translates a delegating type singleton to a name.- Specified by:
marshalin interfacecom.thoughtworks.xstream.converters.Converter- Parameters:
object- the object to be marshalledwriter- the output stream writercontext- the marshalling context
-
unmarshal
public java.lang.Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)Unmarshals the current object to be read from the givenreaderin the specified unmarshallingcontext. This method translates the name back to the singleton instance.- Specified by:
unmarshalin interfacecom.thoughtworks.xstream.converters.Converter- Parameters:
reader- the input stream writercontext- the marshalling context- Returns:
- the unmarshalled object
-
-