org.graphdrawing.graphml.writer
Class GraphMLWriteContext

java.lang.Object
  extended byorg.graphdrawing.graphml.writer.GraphMLWriteContext
All Implemented Interfaces:
Lookup

public class GraphMLWriteContext
extends Object
implements Lookup

Messenger class that represents the current state of the writing process. Among others, instances store the current graph element nesting, thus implementing stack semantics.


Nested Class Summary
static interface GraphMLWriteContext.ResourceDescriptor
           
static interface GraphMLWriteContext.ResourceEncoder
          Interface for classes that encode object to GraphML output
static interface GraphMLWriteContext.ResourceHandler
          Interface for classes that provide methods to manage shared object resources for the output process
 
Constructor Summary
GraphMLWriteContext(DirectGraphMLWriter writer)
          Create a new context
 
Method Summary
 List getContainers()
          Provide direct access to the complete element stack.
 Object getCurrentContainer()
          Return a reference to the topmost element on the current element stack.
 GraphMLWriteErrorHandler 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()
          Pop a graph element from the current element stack.
 void pushGraphMLElement(Object element)
          Push a new graph element onto the current element stack
 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
 

Constructor Detail

GraphMLWriteContext

public GraphMLWriteContext(DirectGraphMLWriter writer)
Create a new context

Parameters:
writer - the writer that uses this context
Method Detail

pushGraphMLElement

public void pushGraphMLElement(Object element)
Push a new graph element onto the current element stack

Parameters:
element -

popGraphMLElement

public void popGraphMLElement()
Pop a graph element from the current element stack. The element is not returned


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.

getContainers

public List getContainers()
Provide direct access to the complete element stack.

Returns:
a reference to the complete 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 GraphMLWriteErrorHandler getErrorHandler()
Return a reference to an error handler that can be used to handle error conditions

Returns:
a reference to an error handler

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-2009, yWorks GmbH. All rights reserved.