TKey
- The type of the keys.TData
- The type of the data.public class MapperOutputHandler<TKey,TData> extends AbstractOutputHandler<TKey,TData>
AbstractOutputHandler
class, that uses an IMapper
to retrieve the values to
output for each item and a Serializer
callback for the serialization or delegates to the IWriteContext.serialize(Type, IWriteContext, java.lang.Object)
callback.Constructor and Description |
---|
MapperOutputHandler(Class<TKey> keyType,
Class<TData> dataType,
KeyScope scope,
String name,
KeyType type)
Initializes a new instance of the
MapperOutputHandler class using the provided key scope, the name, and the key
type. |
MapperOutputHandler(Class<TKey> keyType,
Class<TData> dataType,
String name)
Initializes a new instance of the
MapperOutputHandler class using the given name and inferring the scope and the
type from the class parameters. |
Modifier and Type | Method and Description |
---|---|
IMapper<TKey,TData> |
getMapper()
Gets the mapper to use for querying the data for each item.
|
MapperMetadata |
getMapperMetadata()
Gets the mapper metadata to serialize to the key definition.
|
IEventHandler<HandleSerializationEventArgs> |
getSerializer()
Gets the serialization callback to use for serializing the value in
writeValueCore(IWriteContext, java.lang.Object) . |
Class |
getSourceType()
Gets the source type of the serialization.
|
protected TData |
getValue(IWriteContext context,
TKey key)
Callback method that obtains the data for the given key.
|
void |
setMapper(IMapper<TKey,TData> value)
Sets the mapper to use for querying the data for each item.
|
void |
setMapperMetadata(MapperMetadata value)
Sets the mapper metadata to serialize to the key definition.
|
void |
setSerializer(IEventHandler<HandleSerializationEventArgs> value)
Sets the serialization callback to use for serializing the value in
writeValueCore(IWriteContext, java.lang.Object) . |
void |
setSourceType(Class value)
Sets the source type of the serialization.
|
void |
writeKeyDefinitionContent(IWriteContext context)
Writes the contents of the key definition.
|
protected void |
writeValueCore(IWriteContext context,
TData data)
Callback method that performs the actual writing of the data using either the
Serializer or the
IWriteContext.serialize(Type, IWriteContext, Object) method. |
getDataTagAttributes, getDefaultValue, getKeyDefinitionAttributes, getPrecedence, isDefaultExisting, isDefaultValue, isKeyDefaultWritingEnabled, setDefaultExisting, setDefaultValue, setKeyDefaultWritingEnabled, setKeyDefinitionName, setKeyDefinitionScope, setKeyDefinitionType, setKeyDefinitionUri, setPrecedence, writeValue
public MapperOutputHandler(Class<TKey> keyType, Class<TData> dataType, KeyScope scope, String name, KeyType type)
MapperOutputHandler
class using the provided key scope, the name, and the key
type.keyType
- The type of the keys.dataType
- The type of the data.scope
- The scope for the key definition attributes.name
- The name for the key definition attributes.type
- The type for the key definition attributes.public MapperOutputHandler(Class<TKey> keyType, Class<TData> dataType, String name)
MapperOutputHandler
class using the given name and inferring the scope and the
type from the class parameters.
The GraphML key scope and type are determined automatically.
keyType
- The type of the keys.dataType
- The type of the data.name
- The name to use for the key attributes.public final IMapper<TKey,TData> getMapper()
setMapper(IMapper)
public final MapperMetadata getMapperMetadata()
setMapperMetadata(MapperMetadata)
public final IEventHandler<HandleSerializationEventArgs> getSerializer()
writeValueCore(IWriteContext, java.lang.Object)
.null
to indicate that the context should be used instead.getSourceType()
,
setSerializer(IEventHandler)
public final Class getSourceType()
This type will be used as the SourceType
.
getSerializer()
,
HandleSerializationEventArgs
,
setSourceType(Class)
protected TData getValue(IWriteContext context, TKey key)
getValue
in class AbstractOutputHandler<TKey,TData>
context
- The context.key
- The key.Mapper
.public final void setMapper(IMapper<TKey,TData> value)
value
- The mapper.getMapper()
public final void setMapperMetadata(MapperMetadata value)
value
- The mapper metadata.getMapperMetadata()
public final void setSerializer(IEventHandler<HandleSerializationEventArgs> value)
writeValueCore(IWriteContext, java.lang.Object)
.value
- The serialization callback or null
to indicate that the context should be used instead.getSourceType()
,
getSerializer()
public final void setSourceType(Class value)
This type will be used as the SourceType
.
value
- The desired type of the object that is serialized.getSerializer()
,
HandleSerializationEventArgs
,
getSourceType()
public void writeKeyDefinitionContent(IWriteContext context) throws IOException
This method will additionally write the MapperMetadata
to the key definition content, if
any has been set.
writeKeyDefinitionContent
in interface IOutputHandler
writeKeyDefinitionContent
in class AbstractOutputHandler<TKey,TData>
IOException
- If the key definition cannot be written.context
- The context.protected void writeValueCore(IWriteContext context, TData data) throws IOException
Serializer
or the
IWriteContext.serialize(Type, IWriteContext, Object)
method.writeValueCore
in class AbstractOutputHandler<TKey,TData>
IOException
- If the data cannot be written.context
- The context to use for writing.data
- The data to write.