org.graphdrawing.graphml.reader
Class GraphMLParseContext

java.lang.Object
  extended byorg.graphdrawing.graphml.reader.GraphMLParseContext
All Implemented Interfaces:
Lookup
Direct Known Subclasses:
DOMGraphMLParseContext

public abstract class GraphMLParseContext
extends Object
implements Lookup

Defines the context within a factory method is invoked. The parsing context grants access to the nesting within the graph element creation occurs. Through the nesting, i.e., the graph is defined in which a node or edge is created. Subclasses usually also provide access to the attributes of the element which is responsible for the call of a factory method. A parse context is only valid within the factory mehtod to which it is passed. When the factory method is finished, the state of the corresponding parse context is undefined.


Nested Class Summary
static interface GraphMLParseContext.ResourceDecoder
          Interface for classes that decode GraphML input to objects
static interface GraphMLParseContext.ResourceHandler
          Interface for classes that provide methods to manage shared object resources for the parse process
 
Field Summary
static String PROPERTY_GRAPHML_CORE_NS
           
static String PROPERTY_YWORKS_EXT_NS
           
 
Constructor Summary
protected GraphMLParseContext()
          Creates an empty parse context.
 
Method Summary
abstract  String getAttributeValue(String attrName)
          Return the value of an XML attribute in the current parse state
 List getContainers()
          Returns the current nesting of created graphs and graph elements.
 Object getCurrentContainer()
          Return a reference to the topmost element on the current element stack.
abstract  GraphMLParseErrorHandler getErrorHandler()
          Return a reference to an error handler that can be used to handle error conditions
 Object getProperty(String name)
          Return the value of a property that has been set with setProperty(String,Object)
 Object getSecondToCurrentContainer()
          Return a reference to the second to topmost element on the current element stack.
 Object lookup(Class c)
          Retrieve an object that is indexed by class c.
 void popGraphMLElement()
          Remove the topmost graph element from the element stack.
 void pushGraphMLElement(Object element)
          Used by the parser to update the current nesting.
 void setLookup(Class c, Object o)
          Store a new value in the lookup map
 void setProperty(String name, Object o)
          This can be used to set internal properties of the context that are usually handled by external facades.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_YWORKS_EXT_NS

public static final String PROPERTY_YWORKS_EXT_NS
See Also:
Constant Field Values

PROPERTY_GRAPHML_CORE_NS

public static final String PROPERTY_GRAPHML_CORE_NS
See Also:
Constant Field Values
Constructor Detail

GraphMLParseContext

protected GraphMLParseContext()
Creates an empty parse context.

Method Detail

pushGraphMLElement

public void pushGraphMLElement(Object element)
Used by the parser to update the current nesting.

Parameters:
element - the element to put on the top of the stack

popGraphMLElement

public void popGraphMLElement()
Remove the topmost graph element from the element stack.


getContainers

public List getContainers()
Returns the current nesting of created graphs and graph elements. The list contains the user objects which correspond to the graphml elements which are ancestors of the current node in the DOM tree.


getCurrentContainer

public Object getCurrentContainer()
Return a reference to the topmost element on the current element stack.

Returns:
a reference to the topmost element on the current nesting stack.

getSecondToCurrentContainer

public Object getSecondToCurrentContainer()
Return a reference to the second to topmost element on the current element stack. Useful to peek into deeper nested structures.

Returns:
a reference to the second to topmost element on the current element stack.

lookup

public Object lookup(Class c)
Description copied from interface: Lookup
Retrieve an object that is indexed by class c. The return value should be an instance of class c or a subclass.

Specified by:
lookup in interface Lookup
Parameters:
c - The class for which we want an implementation
Returns:
an implementation of c.

setLookup

public void setLookup(Class c,
                      Object o)
Store a new value in the lookup map

Parameters:
c - the class that is used as lookup key
o - an object that should be an implementation of c

getErrorHandler

public abstract GraphMLParseErrorHandler getErrorHandler()
Return a reference to an error handler that can be used to handle error conditions

Returns:
a reference to an error handler

getAttributeValue

public abstract String getAttributeValue(String attrName)
Return the value of an XML attribute in the current parse state

Parameters:
attrName - the name of the attribute
Returns:
the value of the XML attribute attrName in the current parse state

setProperty

public void setProperty(String name,
                        Object o)
This can be used to set internal properties of the context that are usually handled by external facades.

Parameters:
name - The name of the property
o - the value

getProperty

public Object getProperty(String name)
Return the value of a property that has been set with setProperty(String,Object)

Parameters:
name - the name of the property
Returns:
the value of the property


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