TKey
- The type of the key, i.e. the items that are associated with the data in the GraphML.TData
- The type of the data that is associated with the keys.public abstract class AbstractInputHandler<TKey,TData> extends Object implements IInputHandler
IInputHandler
interface.Modifier | Constructor and Description |
---|---|
protected |
AbstractInputHandler(Class<TKey> keyType)
Initializes a new instance of the
AbstractInputHandler class. |
protected |
AbstractInputHandler(Class<TKey> keyType,
ParsePrecedence precedence)
Initializes a new instance of the
AbstractInputHandler class. |
Modifier and Type | Method and Description |
---|---|
void |
applyDefault(IParseContext context)
This method is invoked when no data tag is defined, and the default value should be applied.
|
TData |
getDefaultValue()
Gets the default value that will be applied to the keys where the data attribute is missing.
|
ParsePrecedence |
getPrecedence()
Gets the parse precedence that is associated with this handler.
|
void |
initializeFromKeyDefinition(IParseContext context,
Element definition)
Initializes this instance from the GraphML key definition.
|
boolean |
isDefaultExisting()
Gets a value indicating whether a default value has been set, either through a key definition element or explicitly by
assigning a value to the
DefaultValue property. |
boolean |
isDefaultValueParsingEnabled()
Gets a value indicating whether the default value in the key definition should be parsed.
|
void |
parseData(IParseContext context,
Node node)
This method is invoked each time a data element with matching key is processed.
|
protected abstract TData |
parseDataCore(IParseContext context,
Node node)
Abstract method callback that actually parses the data.
|
void |
setDefaultValue(TData value)
Sets the default value that will be applied to the keys where the data attribute is missing.
|
void |
setDefaultValueParsingEnabled(boolean value)
Sets a value indicating whether the default value in the key definition should be parsed.
|
void |
setPrecedence(ParsePrecedence value)
Sets the parse precedence that is associated with this handler.
|
protected abstract void |
setValue(IParseContext context,
TKey key,
TData data)
Abstract method callback that actually stores the value with the keys.
|
protected AbstractInputHandler(Class<TKey> keyType)
AbstractInputHandler
class.
The Precedence
has an initial value of ParsePrecedence.DEFAULT
.
keyType
- The type of the key, i.e. the items that are associated with the data in the GraphML.protected AbstractInputHandler(Class<TKey> keyType, ParsePrecedence precedence)
AbstractInputHandler
class.
The Precedence
gets the initial value assigned to precedence
keyType
- The type of the key, i.e. the items that are associated with the data in the GraphML.precedence
- The precedence to assign to the Precedence
property.public void applyDefault(IParseContext context)
This implementation delegates to setValue(IParseContext, java.lang.Object, java.lang.Object)
if a default exists
using the DefaultValue
.
applyDefault
in interface IInputHandler
context
- the current parse context.public final TData getDefaultValue()
If any default value is set (including null
), DefaultExisting
is automatically set
to true.
setDefaultValue(java.lang.Object)
public final ParsePrecedence getPrecedence()
getPrecedence
in interface IInputHandler
setPrecedence(ParsePrecedence)
public void initializeFromKeyDefinition(IParseContext context, Element definition) throws IOException
This implementation looks for the GraphML default element and delegates to parseDataCore(IParseContext, Node)
if a default is found to store the DefaultValue
.
IOException
context
- The context.definition
- The definition.public final boolean isDefaultExisting()
DefaultValue
property.
If this property is set to true
, the applyDefault(IParseContext)
method will call the setValue(IParseContext, java.lang.Object, java.lang.Object)
method using the DefaultValue
as the value parameter.
true
if the default value exists; false
otherwise.public final boolean isDefaultValueParsingEnabled()
true
if the default value should be parsed; false
otherwise. The default is true
.setDefaultValueParsingEnabled(boolean)
public void parseData(IParseContext context, Node node) throws IOException
If the current element
is of the same type as this TKey
, this method
delegates the actual parsing to parseDataCore(IParseContext, Node)
and
setValue(IParseContext, java.lang.Object, java.lang.Object)
parseData
in interface IInputHandler
IOException
- If the data cannot be writtencontext
- the current parse context.node
- the DOM node representing the data element.protected abstract TData parseDataCore(IParseContext context, Node node) throws IOException
IOException
- If the data cannot be writtencontext
- The context.node
- The node that contains the data. This is either the GraphML 'data' element or the 'default' element.public final void setDefaultValue(TData value)
If any default value is set (including null
), DefaultExisting
is automatically set
to true.
value
- The default value.getDefaultValue()
public final void setDefaultValueParsingEnabled(boolean value)
value
- true
if the default value should be parsed; false
otherwise. The default is true
.isDefaultValueParsingEnabled()
public final void setPrecedence(ParsePrecedence value)
value
- The parse precedence.getPrecedence()
protected abstract void setValue(IParseContext context, TKey key, TData data)
context
- The context.key
- The key.data
- The data.