Search this API

y.io.graphml.input
Class ComplexDataAcceptorInputHandler

java.lang.Object
  extended by y.io.graphml.input.AbstractInputHandler
      extended by y.io.graphml.input.AbstractDataAcceptorInputHandler
          extended by y.io.graphml.input.ComplexDataAcceptorInputHandler
All Implemented Interfaces:
InputHandler

public class ComplexDataAcceptorInputHandler
extends AbstractDataAcceptorInputHandler

An InputHandler implementation that uses an DataAcceptor instance to associate the values with the keys.

This implementation can be provided a custom DeserializationHandler to perform the deserialization.

 

Constructor Summary
ComplexDataAcceptorInputHandler()
          Initializes a new instance of the ComplexDataAcceptorInputHandler class that uses the GraphMLParseContext for deserialization.
ComplexDataAcceptorInputHandler(DeserializationHandler deserializer)
          Initializes a new instance of the ComplexDataAcceptorInputHandler class that uses the event handler for deserialization.
 
Method Summary
protected  org.w3c.dom.Node getDeserializationXmlNode(GraphMLParseContext context, org.w3c.dom.Node node)
          Gets the node to pass to deserializer or GraphMLParseContext.deserialize(GraphMLParseContext, org.w3c.dom.Node, Class) respectively, given the 'data' or 'default' element from the GraphML.
 DeserializationHandler getDeserializer()
          Gets the custom deserializer.
 java.lang.Class getDeserializerTargetType()
          Gets the target deserialization type for the DeserializationEvent.getTargetType() property.
 boolean isUseParentElementForDeserialization()
          Controls the behavior of getDeserializationXmlNode(GraphMLParseContext, org.w3c.dom.Node) to return either the 'data' or 'default' element itself or its content.
protected  java.lang.Object parseDataCore(GraphMLParseContext context, org.w3c.dom.Node node)
          Parses the data using either the deserializer or GraphMLParseContext.deserialize(GraphMLParseContext, org.w3c.dom.Node, Class)
 void setDeserializer(DeserializationHandler value)
          Sets a custom deserializer.
 void setDeserializerTargetType(java.lang.Class value)
          Sets the target deserialization type for the DeserializationEvent.getTargetType() property.
 void setUseParentElementForDeserialization(boolean value)
          Controls the behavior of getDeserializationXmlNode(GraphMLParseContext, org.w3c.dom.Node) to return either the 'data' or 'default' element itself or its content.
 
Methods inherited from class y.io.graphml.input.AbstractDataAcceptorInputHandler
getDataAcceptor, setDataAcceptor, setValue
 
Methods inherited from class y.io.graphml.input.AbstractInputHandler
applyDefault, getDefaultValue, getPrecedence, getValidScopes, initializeFromKeyDefinition, isDefaultExists, isParseDefaultValue, parseData, setDefaultExists, setDefaultValue, setParseDefaultValue, setPrecedence, setValidScopes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComplexDataAcceptorInputHandler

public ComplexDataAcceptorInputHandler()
Initializes a new instance of the ComplexDataAcceptorInputHandler class that uses the GraphMLParseContext for deserialization.

Data is parsed through GraphMLParseContext.deserialize(GraphMLParseContext,org.w3c.dom.Node,Class) which delegates to event listeners.

See Also:
GraphMLParseContext.deserialize(GraphMLParseContext,org.w3c.dom.Node,Class)

ComplexDataAcceptorInputHandler

public ComplexDataAcceptorInputHandler(DeserializationHandler deserializer)
Initializes a new instance of the ComplexDataAcceptorInputHandler class that uses the event handler for deserialization.

Data is parsed directly by the provided deserializer, thus bypassing deserialization through GraphMLParseContext.deserialize(GraphMLParseContext,org.w3c.dom.Node,Class). Use this variant to locally override deserialization behaviour for a certain data attribute.

Parameters:
deserializer - The deserialization callback that is used to parse the data.
See Also:
getDeserializer(), setDeserializer(DeserializationHandler), DeserializationHandler.onHandleDeserialization(DeserializationEvent)
Method Detail

isUseParentElementForDeserialization

public boolean isUseParentElementForDeserialization()
Controls the behavior of getDeserializationXmlNode(GraphMLParseContext, org.w3c.dom.Node) to return either the 'data' or 'default' element itself or its content.

The default value is false, meaning that getDeserializationXmlNode(GraphMLParseContext, org.w3c.dom.Node) should return the content of the 'data' or 'default' node.

Returns:
true iff the default element should parsed itself.
See Also:
getDeserializationXmlNode(GraphMLParseContext, org.w3c.dom.Node), setUseParentElementForDeserialization(boolean)

setUseParentElementForDeserialization

public void setUseParentElementForDeserialization(boolean value)
Controls the behavior of getDeserializationXmlNode(GraphMLParseContext, org.w3c.dom.Node) to return either the 'data' or 'default' element itself or its content.

The default value is false, meaning that getDeserializationXmlNode(GraphMLParseContext, org.w3c.dom.Node) should return the content of the 'data' or 'default' node.

Parameters:
value - a value that indicates whether to parse the default element or its content
See Also:
getDeserializationXmlNode(GraphMLParseContext, org.w3c.dom.Node), isUseParentElementForDeserialization()

getDeserializer

public DeserializationHandler getDeserializer()
Gets the custom deserializer.

Returns:
The deserializer.
See Also:
setDeserializer(DeserializationHandler)

setDeserializer

public void setDeserializer(DeserializationHandler value)
Sets a custom deserializer.

Parameters:
value - The deserializer.
See Also:
getDeserializer()

getDeserializerTargetType

public java.lang.Class getDeserializerTargetType()
Gets the target deserialization type for the DeserializationEvent.getTargetType() property.

Returns:
The target type of the deserialization.
See Also:
setDeserializerTargetType(Class)

setDeserializerTargetType

public void setDeserializerTargetType(java.lang.Class value)
Sets the target deserialization type for the DeserializationEvent.getTargetType() property.

Parameters:
value - The target type of the deserialization.
See Also:
getDeserializerTargetType()

parseDataCore

protected java.lang.Object parseDataCore(GraphMLParseContext context,
                                         org.w3c.dom.Node node)
                                  throws GraphMLParseException
Parses the data using either the deserializer or GraphMLParseContext.deserialize(GraphMLParseContext, org.w3c.dom.Node, Class)

Specified by:
parseDataCore in class AbstractInputHandler
Parameters:
context - The context.
node - The node that contains the data. This is either the GraphML 'data' element or the 'default' element, depending on the return value of isUseParentElementForDeserialization()
Returns:
The parsed data.
Throws:
GraphMLParseException
See Also:
getDeserializationXmlNode(GraphMLParseContext, org.w3c.dom.Node), isUseParentElementForDeserialization()

getDeserializationXmlNode

protected org.w3c.dom.Node getDeserializationXmlNode(GraphMLParseContext context,
                                                     org.w3c.dom.Node node)
                                              throws GraphMLParseException
Gets the node to pass to deserializer or GraphMLParseContext.deserialize(GraphMLParseContext, org.w3c.dom.Node, Class) respectively, given the 'data' or 'default' element from the GraphML.

This method is called by parseDataCore(GraphMLParseContext, org.w3c.dom.Node) to determine the node to pass to the deserialization mechanism. This implementation returns node iff isUseParentElementForDeserialization() is true (i.e. the 'data' or 'default' node itself), otherwise the Node.getFirstChild() of the node.

Parameters:
context - The context within which the node is parsed.
node - The 'data' or 'default' node.
Returns:
The node that should be deserialized.
Throws:
GraphMLParseException
See Also:
isUseParentElementForDeserialization()

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.