Packagecom.yworks.io.graphml.writer
Classpublic class DirectGraphMLWriter
InheritanceDirectGraphMLWriter Inheritance Object
Implements IContextLookup, IIdProvider

Implementation that writes a graph to a XML Object in GraphML format.



Public Properties
 PropertyDefined By
  context : GraphMLWriteContext
[read-only] The GraphMLWriteContext which is used here.
DirectGraphMLWriter
  contextLookup : Dictionary
The context lookup dictionary which is used for populating the writer context lookup.
DirectGraphMLWriter
  idProvider : IIdProvider
A reference to an IIdProvider instance.
DirectGraphMLWriter
  initialContext : GraphMLWriteContext
Gets or sets a custom write context instance that will be used by the write process.
DirectGraphMLWriter
  outputHandlerProvider : IOutputHandlerProvider
Get or set a reference to an IOutputHandlerProvider instance that will be queried for dynamic handlers.
DirectGraphMLWriter
Protected Properties
 PropertyDefined By
  currentProvider : IGraphElementProvider
[read-only] The current element provider
DirectGraphMLWriter
Public Methods
 MethodDefined By
  
Creates a new instance.
DirectGraphMLWriter
  
Adds a new IOutputHandler with edge scope.
DirectGraphMLWriter
  
Adds a new IGraphElementProvider.
DirectGraphMLWriter
  
Adds a new IOutputHandler with graph scope.
DirectGraphMLWriter
  
Adds a new IOutputHandler with node scope.
DirectGraphMLWriter
  
addOutputHandler(handler:IOutputHandler, scopeType:String):void
Adds a new IOutputHandler with scope.
DirectGraphMLWriter
  
Adds a new IOutputHandler with port scope.
DirectGraphMLWriter
  
Add a new IXmlAttributeProvider
DirectGraphMLWriter
  
Removes all IGraphElementProviders.
DirectGraphMLWriter
  
getEdgeId(o:Object, context:GraphMLWriteContext):String
Get an ID for the specified edge object
DirectGraphMLWriter
  
getGraphId(o:Object, context:GraphMLWriteContext):String
Get an ID for the specified graph object
DirectGraphMLWriter
  
getNodeId(o:Object, context:GraphMLWriteContext):String
Get an ID for the specified node object
DirectGraphMLWriter
  
getPortId(o:Object, context:GraphMLWriteContext):String
Get an ID for the specified port object
DirectGraphMLWriter
  
Gets the IGraphMLWriteErrorHandler used by this instance.
DirectGraphMLWriter
  
lookupForItem(item:Object, type:Class):Object
Tries to create or retrieve an implementation of the given type for a given item.
DirectGraphMLWriter
  
Register a default serializer.
DirectGraphMLWriter
  
Register a serializer.
DirectGraphMLWriter
  
Removes a IGraphElementProvider from the list.
DirectGraphMLWriter
  
setContextProperty(name:String, value:Object):void
Set a context property which is considered when creating a GraphMLWriteContext.
DirectGraphMLWriter
  
Removes all existing IGraphElementProvider and sets a new one.
DirectGraphMLWriter
  
write(coreWriter:IXmlWriter):void
Start the writing process.
DirectGraphMLWriter
Protected Methods
 MethodDefined By
  
Create a new write context that stores the current state of the writing process.
DirectGraphMLWriter
  
Gets the id with which an output handler is registered to this writer.
DirectGraphMLWriter
  
Sets up the initial write context This method is called directly before the actual writing process starts
DirectGraphMLWriter
  
writeData(coreWriter:IXmlWriter, context:GraphMLWriteContext):void
This method is called whenever a new write process is started.
DirectGraphMLWriter
  
Write a single data element with the given output handler.
DirectGraphMLWriter
  
writeEdge(provider:IGraphElementProvider, edge:Object, coreWriter:IXmlWriter, context:GraphMLWriteContext):void
Writes an edge element.
DirectGraphMLWriter
  
writeGraphElement(provider:IGraphElementProvider, coreWriter:IXmlWriter, topLevel:Boolean, context:GraphMLWriteContext):void
Write the <graph> element that represents the graph that is accessed through the provider.
DirectGraphMLWriter
  
writeKeyDefinition(oh:IOutputHandler, coreWriter:IXmlWriter, scope:String, context:GraphMLWriteContext):void
Writes a single key definition for the given OutputHandler.
DirectGraphMLWriter
  
Writes all key definitions.
DirectGraphMLWriter
  
writeNode(provider:IGraphElementProvider, node:Object, coreWriter:IXmlWriter, context:GraphMLWriteContext):void
Writes a node element.
DirectGraphMLWriter
  
writePort(provider:IGraphElementProvider, port:Object, coreWriter:IXmlWriter, context:GraphMLWriteContext):void
Writes a port element.
DirectGraphMLWriter
  
Method that writes the <graphml> element and everything contained to the output stream.
DirectGraphMLWriter
Property Detail
contextproperty
context:GraphMLWriteContext  [read-only]

The GraphMLWriteContext which is used here.


Implementation
    public function get context():GraphMLWriteContext

See also

contextLookupproperty 
contextLookup:Dictionary

The context lookup dictionary which is used for populating the writer context lookup.


Implementation
    public function get contextLookup():Dictionary
    public function set contextLookup(value:Dictionary):void
currentProviderproperty 
currentProvider:IGraphElementProvider  [read-only]

The current element provider


Implementation
    protected function get currentProvider():IGraphElementProvider
idProviderproperty 
idProvider:IIdProvider

A reference to an IIdProvider instance.

By default, an implementation that writes the graphml canonical id format is used.


Implementation
    public function get idProvider():IIdProvider
    public function set idProvider(value:IIdProvider):void
initialContextproperty 
initialContext:GraphMLWriteContext

Gets or sets a custom write context instance that will be used by the write process.

If this property is not set, a default implementation that is just able to handle the basic graphml serialization process is used


Implementation
    public function get initialContext():GraphMLWriteContext
    public function set initialContext(value:GraphMLWriteContext):void
outputHandlerProviderproperty 
outputHandlerProvider:IOutputHandlerProvider

Get or set a reference to an IOutputHandlerProvider instance that will be queried for dynamic handlers.

This can be used to insert handlers depending on the current context without the need to register them in advance


Implementation
    public function get outputHandlerProvider():IOutputHandlerProvider
    public function set outputHandlerProvider(value:IOutputHandlerProvider):void
Constructor Detail
DirectGraphMLWriter()Constructor
public function DirectGraphMLWriter()

Creates a new instance.

Method Detail
addEdgeOutputHandler()method
public function addEdgeOutputHandler(handler:IOutputHandler):void

Adds a new IOutputHandler with edge scope.

Parameters

handler:IOutputHandler — The new output handler.

See also

addGraphElementProvider()method 
public function addGraphElementProvider(gep:IGraphElementProvider):void

Adds a new IGraphElementProvider.

Parameters

gep:IGraphElementProvider — The IGraphElementProvider to add.

See also

addGraphOutputHandler()method 
public function addGraphOutputHandler(handler:IOutputHandler):void

Adds a new IOutputHandler with graph scope.

Parameters

handler:IOutputHandler — The new output handler.

See also

addNodeOutputHandler()method 
public function addNodeOutputHandler(handler:IOutputHandler):void

Adds a new IOutputHandler with node scope.

Parameters

handler:IOutputHandler — The new output handler.

See also

addOutputHandler()method 
public function addOutputHandler(handler:IOutputHandler, scopeType:String):void

Adds a new IOutputHandler with scope.

Parameters

handler:IOutputHandler — The new output handler.
 
scopeType:String — The scope type as defined in GraphMLConstants

See also

addPortOutputHandler()method 
public function addPortOutputHandler(handler:IOutputHandler):void

Adds a new IOutputHandler with port scope.

Parameters

handler:IOutputHandler — The new output handler.

See also

addXMLAttributeProvider()method 
public function addXMLAttributeProvider(provider:IXmlAttributeProvider):void

Add a new IXmlAttributeProvider

Parameters

provider:IXmlAttributeProvider — The attribute provider

clearGraphElementProviders()method 
public function clearGraphElementProviders():void

Removes all IGraphElementProviders.

See also

createGraphMLWriteContext()method 
protected function createGraphMLWriteContext():GraphMLWriteContext

Create a new write context that stores the current state of the writing process. This method will be called by write(IXmlWriter) whenever a new writing process starts, unless an initialContext has been set.

Returns
GraphMLWriteContext — a new GraphMLWriteContext instance
getEdgeId()method 
public function getEdgeId(o:Object, context:GraphMLWriteContext):String

Get an ID for the specified edge object

Parameters

o:Object — the current edge object
 
context:GraphMLWriteContext — the current write context, for further information to the provider

Returns
String — an ID for the specified edge object
getGraphId()method 
public function getGraphId(o:Object, context:GraphMLWriteContext):String

Get an ID for the specified graph object

Parameters

o:Object — the current graph object
 
context:GraphMLWriteContext — the current write context, for further information to the provider

Returns
String — an ID for the specified graph object
getHandlerId()method 
protected function getHandlerId(oh:IOutputHandler):String

Gets the id with which an output handler is registered to this writer.

Parameters

oh:IOutputHandler — The output handler, for which the id is queried.

Returns
String — The id of the output handler, or null, if not registered
getNodeId()method 
public function getNodeId(o:Object, context:GraphMLWriteContext):String

Get an ID for the specified node object

Parameters

o:Object — the current node object
 
context:GraphMLWriteContext — the current write context, for further information to the provider

Returns
String — an ID for the specified node object
getPortId()method 
public function getPortId(o:Object, context:GraphMLWriteContext):String

Get an ID for the specified port object

Parameters

o:Object — the current port object
 
context:GraphMLWriteContext — the current write context, for further information to the provider

Returns
String — an ID for the specified port object
getWriteErrorHandler()method 
public function getWriteErrorHandler():IGraphMLWriteErrorHandler

Gets the IGraphMLWriteErrorHandler used by this instance.

Creates a new instance of IGraphMLWriteErrorHandler if none is existing.

Returns
IGraphMLWriteErrorHandler — The write error handler.

See also

initializeWriteContext()method 
protected function initializeWriteContext(context:GraphMLWriteContext):void

Sets up the initial write context

This method is called directly before the actual writing process starts

Parameters

context:GraphMLWriteContext — The context to configure

lookupForItem()method 
public function lookupForItem(item:Object, type:Class):Object

Tries to create or retrieve an implementation of the given type for a given item.

Parameters

item:Object — the item to lookup a type for
 
type:Class — the type to look up

Returns
Object — an implementation or null
registerDefaultSerializer()method 
public function registerDefaultSerializer(serializer:ISerializer):void

Register a default serializer.

A default will only be used if no more specific (non-default) serializer exists.

Parameters

serializer:ISerializer — A serializer instance that is to be used for graphml writing

registerSerializer()method 
public function registerSerializer(serializer:ISerializer):void

Register a serializer.

Parameters

serializer:ISerializer — A serializer instance that is to be used for graphml writing

removeGraphElementProvider()method 
public function removeGraphElementProvider(gep:IGraphElementProvider):void

Removes a IGraphElementProvider from the list.

Parameters

gep:IGraphElementProvider — The IGraphElementProvider to be removed.

See also

setContextProperty()method 
public function setContextProperty(name:String, value:Object):void

Set a context property which is considered when creating a GraphMLWriteContext.

Parameters

name:String
 
value:Object

setGraphElementProvider()method 
public function setGraphElementProvider(gep:IGraphElementProvider):void

Removes all existing IGraphElementProvider and sets a new one.

Parameters

gep:IGraphElementProvider — The new IGraphElementProvider to set.

See also

write()method 
public function write(coreWriter:IXmlWriter):void

Start the writing process. This serializes the graph that can be accessed through the graphElementProvider instances set on this instance with the help of the coreWriter that handles the low level XML write process.

Parameters

coreWriter:IXmlWriter — the low level XMLWriter instance that handles all xml write requests

writeData()method 
protected function writeData(coreWriter:IXmlWriter, context:GraphMLWriteContext):void

This method is called whenever a new write process is started.

Parameters

coreWriter:IXmlWriter — the low level XMLWriter instance that handles all xml write requests
 
context:GraphMLWriteContext — the current write context

writeDataElement()method 
protected function writeDataElement(oh:IOutputHandler, coreWriter:IXmlWriter, context:GraphMLWriteContext):void

Write a single data element with the given output handler. This delegates to oh to write the content of the data tag.

Parameters

oh:IOutputHandler — the OutputHandler that writes the tag
 
coreWriter:IXmlWriter — the low level XMLWriter instance that handles all xml write requests
 
context:GraphMLWriteContext — the current write context

writeEdge()method 
protected function writeEdge(provider:IGraphElementProvider, edge:Object, coreWriter:IXmlWriter, context:GraphMLWriteContext):void

Writes an edge element.

Parameters

provider:IGraphElementProvider — the GraphElementProvider that represents the current graph
 
edge:Object — the edge object to write.
 
coreWriter:IXmlWriter — the low level XMLWriter instance that handles all xml write requests
 
context:GraphMLWriteContext — the current write context

writeGraphElement()method 
protected function writeGraphElement(provider:IGraphElementProvider, coreWriter:IXmlWriter, topLevel:Boolean, context:GraphMLWriteContext):void

Write the <graph> element that represents the graph that is accessed through the provider.

Parameters

provider:IGraphElementProvider — the GraphElementProvider that represents the current graph
 
coreWriter:IXmlWriter — the low level XMLWriter instance that handles all xml write requests
 
topLevel:Booleantrue iff this is a toplevel graph element.
 
context:GraphMLWriteContext — the current write context

writeKeyDefinition()method 
protected function writeKeyDefinition(oh:IOutputHandler, coreWriter:IXmlWriter, scope:String, context:GraphMLWriteContext):void

Writes a single key definition for the given OutputHandler.

Parameters

oh:IOutputHandler — the OutputHandler for which the key defintion is written
 
coreWriter:IXmlWriter — the low level XMLWriter instance that handles all xml write requests
 
scope:String — the scope of the attribute
 
context:GraphMLWriteContext — the current write context

writeKeyDefinitions()method 
protected function writeKeyDefinitions(coreWriter:IXmlWriter, context:GraphMLWriteContext):void

Writes all key definitions. This delegates to writeKeyDefinition( IOutputHandler,IXmlWriter,int,GraphMLWriteContext)

Parameters

coreWriter:IXmlWriter — the low level XMLWriter instance that handles all xml write requests
 
context:GraphMLWriteContext — the current write context

writeNode()method 
protected function writeNode(provider:IGraphElementProvider, node:Object, coreWriter:IXmlWriter, context:GraphMLWriteContext):void

Writes a node element.

Parameters

provider:IGraphElementProvider — the GraphElementProvider that represents the current graph
 
node:Object — the node object to write.
 
coreWriter:IXmlWriter — the low level XMLWriter instance that handles all xml write requests
 
context:GraphMLWriteContext — the current write context

writePort()method 
protected function writePort(provider:IGraphElementProvider, port:Object, coreWriter:IXmlWriter, context:GraphMLWriteContext):void

Writes a port element.

Parameters

provider:IGraphElementProvider — the GraphElementProvider that represents the current graph
 
port:Object — the port object to write.
 
coreWriter:IXmlWriter — the low level XMLWriter instance that handles all xml write requests
 
context:GraphMLWriteContext — the current write context

writeRootElement()method 
protected function writeRootElement(coreWriter:IXmlWriter, context:GraphMLWriteContext):void

Method that writes the <graphml> element and everything contained to the output stream.

Parameters

coreWriter:IXmlWriter — the low level XMLWriter instance that handles all xml write requests
 
context:GraphMLWriteContext — the current write context