Search this API

y.io.graphml.input
Class AbstractInputHandler

java.lang.Object
  extended by y.io.graphml.input.AbstractInputHandler
All Implemented Interfaces:
InputHandler
Direct Known Subclasses:
AbstractDataAcceptorInputHandler, AbstractReadNodePortHandler, EdgeLayoutInputHandler, NodeLayoutInputHandler, ReadEdgeRealizerHandler, ReadNodeRealizerHandler

public abstract class AbstractInputHandler
extends java.lang.Object
implements InputHandler

An abstract convenience implementation of the InputHandler interface.

 

Constructor Summary
protected AbstractInputHandler()
          Initializes a new instance of the AbstractInputHandler class.
protected AbstractInputHandler(ParsePrecedence precedence)
          Initializes a new instance of the AbstractInputHandler class.
 
Method Summary
 void applyDefault(GraphMLParseContext context)
          This method is invoked when no data tag is defined, and the default value should be applied.
 java.lang.Object 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.
 java.util.Set getValidScopes()
          Allows to restrict the scopes where the handler is used, if the handler is registered to KeyScope.ALL.
 void initializeFromKeyDefinition(GraphMLParseContext context, org.w3c.dom.Element definition)
          Initializes this instance from the GraphML key definition.
 boolean isDefaultExists()
          Gets value indicating whether the default value exists in the key definition.
 boolean isParseDefaultValue()
          Gets a value indicating whether the default value in the key definition should be parsed.
 void parseData(GraphMLParseContext context, org.w3c.dom.Node node)
          This method is invoked each time a data element with matching key is processed.
protected abstract  java.lang.Object parseDataCore(GraphMLParseContext context, org.w3c.dom.Node node)
          Abstract method callback that actually parses the data.
 void setDefaultExists(boolean value)
          Sets a value indicating whether the default value exists in the key definition.
 void setDefaultValue(java.lang.Object value)
          Sets the default value that will be applied to the keys where the data attribute is missing.
 void setParseDefaultValue(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.
 void setValidScopes(java.util.Set value)
          Allows to restrict the scopes where the handler is used, if the handler is registered to KeyScope.ALL.
protected abstract  void setValue(GraphMLParseContext context, java.lang.Object key, java.lang.Object data)
          Abstract method callback that actually stores the value with the keys.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractInputHandler

protected AbstractInputHandler()
Initializes a new instance of the AbstractInputHandler class.

The getPrecedence() has an initial value of ParsePrecedence.DEFAULT.


AbstractInputHandler

protected AbstractInputHandler(ParsePrecedence precedence)
Initializes a new instance of the AbstractInputHandler class.

The getPrecedence() gets the initial value assigned to precedence

Parameters:
precedence - The precedence to assign to the getPrecedence() property.
Method Detail

isParseDefaultValue

public boolean isParseDefaultValue()
Gets a value indicating whether the default value in the key definition should be parsed.

Returns:
true if the default value should be parsed; otherwise, false. The default is true.
See Also:
setParseDefaultValue(boolean), getDefaultValue()

setParseDefaultValue

public void setParseDefaultValue(boolean value)
Sets a value indicating whether the default value in the key definition should be parsed.

Parameters:
value - true if the default value should be parsed; otherwise, false. The default is true.
See Also:
getDefaultValue(), setDefaultExists(boolean)

getDefaultValue

public java.lang.Object getDefaultValue()
Gets the default value that will be applied to the keys where the data attribute is missing.

Returns:
The default value.
See Also:
setDefaultValue(Object)

setDefaultValue

public void setDefaultValue(java.lang.Object value)
Sets the default value that will be applied to the keys where the data attribute is missing.

Parameters:
value - The default value.
See Also:
getDefaultValue()

isDefaultExists

public boolean isDefaultExists()
Gets value indicating whether the default value exists in the key definition.

If this property is to true, the applyDefault(GraphMLParseContext) method will call the setValue(GraphMLParseContext, Object, Object) method

Returns:
true if the default value exists; otherwise, false.
See Also:
setDefaultExists(boolean), isParseDefaultValue(), getDefaultValue()

setDefaultExists

public void setDefaultExists(boolean value)
Sets a value indicating whether the default value exists in the key definition.

If this property is set to true, the applyDefault(GraphMLParseContext) method will call the setValue(GraphMLParseContext, Object, Object) method

Parameters:
value - true if the default value exists; otherwise, false.
See Also:
isDefaultExists(), isParseDefaultValue(), getDefaultValue()

getPrecedence

public ParsePrecedence getPrecedence()
Gets the parse precedence that is associated with this handler.

Specified by:
getPrecedence in interface InputHandler
Returns:
The parse precedence.
See Also:
setPrecedence(ParsePrecedence)

setPrecedence

public void setPrecedence(ParsePrecedence value)
Sets the parse precedence that is associated with this handler.

Parameters:
value - The parse precedence.
See Also:
getPrecedence()

parseData

public void parseData(GraphMLParseContext context,
                      org.w3c.dom.Node node)
               throws GraphMLParseException
This method is invoked each time a data element with matching key is processed.

Specified by:
parseData in interface InputHandler
Parameters:
context - the current parse context.
node - the DOM node representing the data element.
Throws:
GraphMLParseException
See Also:
parseDataCore(GraphMLParseContext,org.w3c.dom.Node)

getValidScopes

public java.util.Set getValidScopes()
Allows to restrict the scopes where the handler is used, if the handler is registered to KeyScope.ALL.

By default the collection contains the KeyScope.ALL.

Returns:
The set of valid KeyScopes for this handler.
See Also:
setValidScopes(java.util.Set)

setValidScopes

public void setValidScopes(java.util.Set value)
Allows to restrict the scopes where the handler is used, if the handler is registered to KeyScope.ALL.

By default the collection contains the KeyScope.ALL.

Parameters:
value - A set of valid KeyScopes for this handler.
See Also:
getValidScopes()

initializeFromKeyDefinition

public void initializeFromKeyDefinition(GraphMLParseContext context,
                                        org.w3c.dom.Element definition)
                                 throws GraphMLParseException
Initializes this instance from the GraphML key definition.

This implementation looks for the GraphML default element and delegates to parseDataCore(GraphMLParseContext, org.w3c.dom.Node) if a default is found to store the getDefaultValue() and set the isDefaultExists() property.

Parameters:
context - The context.
definition - The definition.
Throws:
GraphMLParseException

parseDataCore

protected abstract java.lang.Object parseDataCore(GraphMLParseContext context,
                                                  org.w3c.dom.Node node)
                                           throws GraphMLParseException
Abstract method callback that actually parses the data.

Parameters:
context - The context.
node - The node that contains the data. This is either the GraphML data element or the default element.
Returns:
The parsed data.
Throws:
GraphMLParseException

setValue

protected abstract void setValue(GraphMLParseContext context,
                                 java.lang.Object key,
                                 java.lang.Object data)
                          throws GraphMLParseException
Abstract method callback that actually stores the value with the keys.

Parameters:
context - The context.
key - The key.
data - The data.
Throws:
GraphMLParseException

applyDefault

public void applyDefault(GraphMLParseContext context)
                  throws GraphMLParseException
This method is invoked when no data tag is defined, and the default value should be applied.

This implementation delegates to setValue(GraphMLParseContext, Object, Object). if isDefaultExists()

Specified by:
applyDefault in interface InputHandler
Parameters:
context - the current parse context.
Throws:
GraphMLParseException

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