TKey
- The type of the key.TData
- The type of the value.public class MapperInputHandler<TKey,TData> extends AbstractInputHandler<TKey,TData>
IInputHandler
implementation that uses an IMapper
instance to associate the values with the keys.
This implementation can be provided an
HandleDeserializationEventArgs
-handler to perform the deserialization. If no such value is provided then the
default deserialization is performed.
The parsed values are stored in a IMapper
.
Constructor and Description |
---|
MapperInputHandler(Class<TKey> keyType,
Class<TData> valueType)
Initializes a new instance of the
MapperInputHandler class that uses the IParseContext for
deserialization. |
MapperInputHandler(Class<TKey> keyType,
Class<TData> valueType,
IEventHandler<HandleDeserializationEventArgs> deserializer)
Initializes a new instance of the
MapperInputHandler class that uses the event handler for deserialization and
suggests the provided target type for the deserializer. |
MapperInputHandler(Class<TKey> keyType,
Class<TData> valueType,
IEventHandler<HandleDeserializationEventArgs> deserializer,
Class deserializerTargetType)
Initializes a new instance of the
MapperInputHandler class that uses the event handler for deserialization and
suggests the provided target type for the deserializer. |
Modifier and Type | Method and Description |
---|---|
void |
applyDefault(IParseContext context)
Overridden to take the
DefaultValueOverridingEnabled property into account. |
protected Node |
getDeserializationXmlNode(IParseContext context,
Node node)
Gets the node to pass to
Deserializer or IParseContext.Deserialize
respectively, given the 'data' or 'default' element from the GraphML. |
IEventHandler<HandleDeserializationEventArgs> |
getDeserializer()
Gets the deserializer.
|
Class |
getDeserializerTargetType()
Gets the target deserialization type for the
TargetType
property. |
IMapper<TKey,TData> |
getMapper()
Gets the mapper to use for storing the data.
|
boolean |
isDefaultValueOverridingEnabled()
Gets a value indicating whether values that are applied via the
AbstractInputHandler.applyDefault(IParseContext)
mechanism and are equal to the value that is already present in the mapper will explicitly be overridden in the mapper. |
boolean |
isUsingParentElementForDeserialization()
Controls the behavior of
getDeserializationXmlNode(IParseContext, Node) to return either the 'data' /'default'
element itself or its content. |
protected TData |
parseDataCore(IParseContext context,
Node node)
Parses the data using either the
Deserializer or the IParseContext.deserialize(Class, IParseContext, Node)
call. |
void |
setDefaultValueOverridingEnabled(boolean value)
Sets a value indicating whether values that are applied via the
AbstractInputHandler.applyDefault(IParseContext)
mechanism and are equal to the value that is already present in the mapper will explicitly be overridden in the mapper. |
void |
setDeserializer(IEventHandler<HandleDeserializationEventArgs> value)
Sets the deserializer.
|
void |
setDeserializerTargetType(Class value)
Sets the target deserialization type for the
TargetType
property. |
void |
setMapper(IMapper<TKey,TData> value)
Sets the mapper to use for storing the data.
|
void |
setUsingParentElementForDeserialization(boolean value)
Controls the behavior of
getDeserializationXmlNode(IParseContext, Node) to return either the 'data' /'default'
element itself or its content. |
protected void |
setValue(IParseContext context,
TKey key,
TData data)
This method uses the
Mapper to associate the data with the key. |
getDefaultValue, getPrecedence, initializeFromKeyDefinition, isDefaultExisting, isDefaultValueParsingEnabled, parseData, setDefaultValue, setDefaultValueParsingEnabled, setPrecedence
public MapperInputHandler(Class<TKey> keyType, Class<TData> valueType)
MapperInputHandler
class that uses the IParseContext
for
deserialization.
The Precedence
has an initial value of
ParsePrecedence.DEFAULT
.
keyType
- The type of the key.valueType
- The type of the value.public MapperInputHandler(Class<TKey> keyType, Class<TData> valueType, IEventHandler<HandleDeserializationEventArgs> deserializer)
MapperInputHandler
class that uses the event handler for deserialization and
suggests the provided target type for the deserializer.getDeserializerTargetType()
,
getDeserializer()
public MapperInputHandler(Class<TKey> keyType, Class<TData> valueType, IEventHandler<HandleDeserializationEventArgs> deserializer, Class deserializerTargetType)
MapperInputHandler
class that uses the event handler for deserialization and
suggests the provided target type for the deserializer.keyType
- The type of the key.valueType
- The type of the value.getDeserializerTargetType()
,
getDeserializer()
public void applyDefault(IParseContext context)
DefaultValueOverridingEnabled
property into account.applyDefault
in interface IInputHandler
applyDefault
in class AbstractInputHandler<TKey,TData>
context
- The context for the parse operation.isDefaultValueOverridingEnabled()
,
AbstractInputHandler.applyDefault(IParseContext)
protected Node getDeserializationXmlNode(IParseContext context, Node node)
Deserializer
or IParseContext.Deserialize
respectively, given the 'data' or 'default' element from the GraphML.
This method is called by parseDataCore(IParseContext, Node)
to determine the node to pass to the
deserialization mechanism.
This implementation returns node
iff UsingParentElementForDeserialization
is true
(i.e. the 'data'
or 'default'
node itself), otherwise the first child of the node
that is not a comment or processing instruction.
context
- The context within which the node is parsed.node
- The 'data' or 'default' node.isUsingParentElementForDeserialization()
public final IEventHandler<HandleDeserializationEventArgs> getDeserializer()
setDeserializer(IEventHandler)
public final Class getDeserializerTargetType()
TargetType
property.setDeserializerTargetType(Class)
public final IMapper<TKey,TData> getMapper()
setMapper(IMapper)
public final boolean isDefaultValueOverridingEnabled()
AbstractInputHandler.applyDefault(IParseContext)
mechanism and are equal to the value that is already present in the mapper will explicitly be overridden in the mapper.true
if default values should be overridden in the mapper; false
otherwise. By default this is set to
false
.setDefaultValueOverridingEnabled(boolean)
public final boolean isUsingParentElementForDeserialization()
getDeserializationXmlNode(IParseContext, Node)
to return either the 'data'
/'default'
element itself or its content.
The default value is false
, meaning that getDeserializationXmlNode(IParseContext, Node)
should return
the content of the 'data'
/'default'
node.
getDeserializationXmlNode(IParseContext, Node)
,
setUsingParentElementForDeserialization(boolean)
protected TData parseDataCore(IParseContext context, Node node)
Deserializer
or the IParseContext.deserialize(Class, IParseContext, Node)
call.parseDataCore
in class AbstractInputHandler<TKey,TData>
DeserializationNotSupportedException
- DeserializationNotSupportedException
if Deserializer
could not handle the node.context
- The context.node
- The node that contains the data. This is either the GraphML 'data'
element or the 'default'
element.getDeserializationXmlNode(IParseContext, Node)
public final void setDefaultValueOverridingEnabled(boolean value)
AbstractInputHandler.applyDefault(IParseContext)
mechanism and are equal to the value that is already present in the mapper will explicitly be overridden in the mapper.value
- true
if default values should be overridden in the mapper; false
otherwise. By default this is set to
false
.isDefaultValueOverridingEnabled()
public final void setDeserializer(IEventHandler<HandleDeserializationEventArgs> value)
value
- The deserializer.getDeserializer()
public final void setDeserializerTargetType(Class value)
TargetType
property.value
- The target type of the deserialization.getDeserializerTargetType()
public final void setMapper(IMapper<TKey,TData> value)
value
- The mapper.getMapper()
public final void setUsingParentElementForDeserialization(boolean value)
getDeserializationXmlNode(IParseContext, Node)
to return either the 'data'
/'default'
element itself or its content.
The default value is false
, meaning that getDeserializationXmlNode(IParseContext, Node)
should return
the content of the 'data'
/'default'
node.
value
- The UsingParentElementForDeserialization to set.getDeserializationXmlNode(IParseContext, Node)
,
isUsingParentElementForDeserialization()
protected void setValue(IParseContext context, TKey key, TData data)
Mapper
to associate the data with the key.setValue
in class AbstractInputHandler<TKey,TData>
context
- The context.key
- The key.data
- The data.