org.graphdrawing.graphml.attr
Class AttributeInputHandler

java.lang.Object
  extended byorg.graphdrawing.graphml.attr.AttributeInputHandler
All Implemented Interfaces:
DOMInputHandler
Direct Known Subclasses:
AttrDataAcceptorInputHandler

public class AttributeInputHandler
extends Object
implements DOMInputHandler

This class handles parsing of the GraphML extensions defined in the attribute module. This class handles only the low-level parsing, the processing of the attributes is forwarded to an instance of AttributeFactory.


Field Summary
protected  AttributeFactory attributeFactory
           
protected  String defaultValue
           
protected  String name
           
protected  int scope
           
 
Constructor Summary
AttributeInputHandler(String attrName, AttributeFactory attributeFactory)
          Creates a new input handler for a given attribute.
AttributeInputHandler(String name, AttributeFactory attributeFactory, int scope)
           
 
Method Summary
 boolean acceptKey(NamedNodeMap attributes, int scopeType)
          Tests if the provided key/data pair defines an attribute.
 void applyDefault(DOMGraphMLParseContext context)
          This method is invoked when no data tag is defined, and the default value should be applied.
 void parseData(DOMGraphMLParseContext context, boolean defaultMode, Node node)
          This method is invoked, each time a data element with matching key is processed.
 void setAttributeFactory(AttributeFactory attributeFactory)
          Sets the current AttributeFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attributeFactory

protected AttributeFactory attributeFactory

name

protected String name

defaultValue

protected String defaultValue

scope

protected int scope
Constructor Detail

AttributeInputHandler

public AttributeInputHandler(String attrName,
                             AttributeFactory attributeFactory)
Creates a new input handler for a given attribute.

Parameters:
attrName - the name of the attribute.

AttributeInputHandler

public AttributeInputHandler(String name,
                             AttributeFactory attributeFactory,
                             int scope)
Method Detail

setAttributeFactory

public void setAttributeFactory(AttributeFactory attributeFactory)
Sets the current AttributeFactory.

Parameters:
attributeFactory -

acceptKey

public boolean acceptKey(NamedNodeMap attributes,
                         int scopeType)
Tests if the provided key/data pair defines an attribute.

Specified by:
acceptKey in interface DOMInputHandler
Parameters:
attributes - the attributes of the key tag.
scopeType - the scope for which the key is defined. One of GraphMLConstants.SCOPE_ALL, GraphMLConstants.SCOPE_EDGE, GraphMLConstants.SCOPE_ENDPOINT, GraphMLConstants.SCOPE_GRAPH, GraphMLConstants.SCOPE_NODE, GraphMLConstants.SCOPE_PORT, GraphMLConstants.SCOPE_HYPEREDGE.
Returns:
true, if the the provided key is an attribute

parseData

public void parseData(DOMGraphMLParseContext context,
                      boolean defaultMode,
                      Node node)
This method is invoked, each time a data element with matching key is processed.

Specified by:
parseData in interface DOMInputHandler
Parameters:
context - the current parse context.
defaultMode - true when the default value of included int the key element is processed, false otherwise.
node - the DOM node representing the data element.

applyDefault

public void applyDefault(DOMGraphMLParseContext context)
Description copied from interface: DOMInputHandler
This method is invoked when no data tag is defined, and the default value should be applied.

Specified by:
applyDefault in interface DOMInputHandler
Parameters:
context - the current parse context.


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