Packagecom.yworks.io.graphml
Classpublic class GraphMLIOHandler
InheritanceGraphMLIOHandler Inheritance flash.events.EventDispatcher
ImplementsIOHandler
SubclassesDotnetCompatGraphMLIOHandler, JavaCompatGraphMLIOHandler, LayoutGraphMLIOHandler

An IOHandler that can read and write graphs in graphml format.

Note that no additional input/output handlers are registered if an instances of this class is created, i.e. no graphical properties of graph items will be read or written by a "plain" instance that was not configured by adding IInputHandlers, IOuputHandlers, IDeserialiers and/or IRealizerSerializers.

Usually, a preconfigured GraphMLIOHandler class should be used instead of this class. Most yFiles FLEX applications can just use a com.yworks.remote.RoundtripSupport instance to read and write GraphML data. RoundtripSupport will use preconfigured io handlers for reading and writing. As an alternative, DotnetCompatGraphMLIOHandler or JavaCompatGraphmlIOHandler can be used.

See the See also

com.yworks.remote.RoundtripSupport
com.yworks.io.JavaCompatGraphmlIOHandler
com.yworks.io.DotnetCompatGraphMLIOHandler


Public Properties
 PropertyDefined by
  clearGraphBeforeRead : Boolean
Whether to clear an existing graph instance before reading

If set to true, an exisisting graph instance will be cleared before the graph is read into this instance, otherwise the loaded graph will be merged into the existing one.

GraphMLIOHandler
  parseErrorHandler : IGraphMLParseErrorHandler
Gets or sets whether embedded resources should be evaluated.
GraphMLIOHandler
  readLabels : Boolean
Whether labels should be deserialized.
GraphMLIOHandler
  readMajorVersion : int
The major file format version for the input.
GraphMLIOHandler
  readMinorVersion : int
The minor file format version for the input.
GraphMLIOHandler
  readRealizers : Boolean
Whether styles should be deserialized from realizers.
GraphMLIOHandler
  readStyles : Boolean
Whether styles should be deserialized.
GraphMLIOHandler
  realizerSerializerManager : RealizerSerializerManager
[read-only] Get the RealizerSerializerManager instance used by this GraphMLIOHandler.
GraphMLIOHandler
  writeLabels : Boolean
Whether labels should be serialized.
GraphMLIOHandler
  writeMajorVersion : int
The major file format version for the output
GraphMLIOHandler
  writeMinorVersion : int
The minor file format version for the output
GraphMLIOHandler
  writeRealizers : Boolean
Whether styles should be serialized as realizers.
GraphMLIOHandler
  writeSharedReferences : Boolean
Get or set whether embedded resources should be written in a separate block.
GraphMLIOHandler
  writeStyles : Boolean
Whether styles should be serialized.
GraphMLIOHandler
Protected Properties
 PropertyDefined by
  _edgeOutputHandlers : List
The installed edge output handlers
GraphMLIOHandler
  _graphMLOutputHandlers : List
The installed graphml output handlers
GraphMLIOHandler
  _graphOutputHandlers : List
The installed graph output handlers
GraphMLIOHandler
  _inputHandlers : List
The installed input handlers
GraphMLIOHandler
  _namespaces : ArrayList
The installed namespaces
GraphMLIOHandler
  _nodeOutputHandlers : List
The installed node output handlers
GraphMLIOHandler
  _portOutputHandlers : List
The installed port output handlers
GraphMLIOHandler
Public Methods
 MethodDefined by
  
Constructor.
GraphMLIOHandler
  
addEdgeAttribute(mapper:IMapper, attrName:String, type:String = "string"):void
Adds a GraphML attribute with edge scope that holds data of simple type.
GraphMLIOHandler
  
Adds a input handler that can parse <data> blocks.
GraphMLIOHandler
  
addNamespace(ns:Namespace):void
Adds a namespace to the header of a GraphML file.
GraphMLIOHandler
  
addNodeAttribute(mapper:IMapper, attrName:String, type:String = "string"):void
Adds a GraphML attribute with node scope that holds data of simple type.
GraphMLIOHandler
  
addOutputHandler(outputHandler:IOutputHandler, scope:String):void
Adds a subordinate output handler for the given element scope to this GraphMLIOHandler.
GraphMLIOHandler
  
addRegistryEdgeAttribute(registryTag:Object, attrName:String, type:String = "string"):void
Adds a GraphML attribute with edge scope that holds data of simple type.
GraphMLIOHandler
  
addRegistryNodeAttribute(registryTag:Object, attrName:String, type:String = "string"):void
Adds a GraphML attribute with node scope that holds data of simple type.
GraphMLIOHandler
  
Returns an iterable view of all input handlers that have been registered with this instance.
GraphMLIOHandler
  
Returns an editable view on the registered output handlers for GraphML attributes with given scope that are registered with this GraphMLIOHandler.
GraphMLIOHandler
  
Returns an Iterable of all deserializers that have been registered with this instance.
GraphMLIOHandler
  
Returns an iterable view of all serializers that have been registered with this instance.
GraphMLIOHandler
  
read(graph:IGraph, xml:XML):void
populate the given graph with the graph defined in the given xml file.
GraphMLIOHandler
  
readURL(graph:IGraph, url:String):void
Populate the graph with the graph structure defined in a graph file located at the URL.
GraphMLIOHandler
  
Register a IDeserializer instance for reading custom information.
GraphMLIOHandler
  
Register a ISerializer instance for writing custom information.
GraphMLIOHandler
  
removeInputHandler(inputHandler:IInputHandler):void
Removes an input handler.
GraphMLIOHandler
  
removeOutputHandler(outputHandler:IOutputHandler, scope:String):void
Removes an output handler that was added for the given scope.
GraphMLIOHandler
  
Unregister an IDeserializer instance that was previously registered.
GraphMLIOHandler
  
Unregister an ISerializer instance that was previously registered.
GraphMLIOHandler
  
write(graph:IGraph):XML
Write the given graph to a XML Object in GraphML format.
GraphMLIOHandler
Protected Methods
 MethodDefined by
  
Create the DirectGraphMLWriter instance that is used for writing GraphML output.
GraphMLIOHandler
  
Create a suitable instance of IGraphElementFactory that can handle the given graph
GraphMLIOHandler
  
Create an IGraphElementProvider instance that provides the graph elements that are to be written.
GraphMLIOHandler
  
Create the GraphMLParser instance that is used for writing GraphML output.
GraphMLIOHandler
  
Callback method for the creation of a new read context.
GraphMLIOHandler
  
Callback method for the creation of a new write context.
GraphMLIOHandler
  
Create the IXmlWriter instance that is used for low-level XML writing.
GraphMLIOHandler
  
Callback for subclasses to register default data handlers.
GraphMLIOHandler
Events
 EventSummaryDefined by
   Dispatched when the io handler has finished parsing a graph.GraphMLIOHandler
   Dispatched when readURL is used and a the server sends a HTTP status code.GraphMLIOHandler
   Dispatched when readURL is used and an IO error occurs.GraphMLIOHandler
   Dispatched when readURL is used and a security error occurs.GraphMLIOHandler
Property detail
clearGraphBeforeReadproperty
clearGraphBeforeRead:Boolean  [read-write]

Whether to clear an existing graph instance before reading

If set to true, an exisisting graph instance will be cleared before the graph is read into this instance, otherwise the loaded graph will be merged into the existing one.

The default value is true.

Implementation
    public function get clearGraphBeforeRead():Boolean
    public function set clearGraphBeforeRead(value:Boolean):void
_edgeOutputHandlersproperty 
protected var _edgeOutputHandlers:List

The installed edge output handlers

_graphMLOutputHandlersproperty 
protected var _graphMLOutputHandlers:List

The installed graphml output handlers

_graphOutputHandlersproperty 
protected var _graphOutputHandlers:List

The installed graph output handlers

_inputHandlersproperty 
protected var _inputHandlers:List

The installed input handlers

_namespacesproperty 
protected var _namespaces:ArrayList

The installed namespaces

_nodeOutputHandlersproperty 
protected var _nodeOutputHandlers:List

The installed node output handlers

parseErrorHandlerproperty 
parseErrorHandler:IGraphMLParseErrorHandler  [read-write]

Gets or sets whether embedded resources should be evaluated. If false, no resources are read from an embedded resource data tag. The exact behaviour in this case depends on the InputHandler used (i.e. resolve an external URL instead). Default is true.

Implementation
    public function get parseErrorHandler():IGraphMLParseErrorHandler
    public function set parseErrorHandler(value:IGraphMLParseErrorHandler):void
_portOutputHandlersproperty 
protected var _portOutputHandlers:List

The installed port output handlers

readLabelsproperty 
readLabels:Boolean  [read-write]

Whether labels should be deserialized.

The default value is true.

Implementation
    public function get readLabels():Boolean
    public function set readLabels(value:Boolean):void
readMajorVersionproperty 
readMajorVersion:int  [read-write]

The major file format version for the input.

If this property is set, it forces the parser to read the specified major version format.

If the value of this property is null (the default), the version attribute of the graphml element in the parsed file determines the major version.

The default value is -1.

Implementation
    public function get readMajorVersion():int
    public function set readMajorVersion(value:int):void

See also

readMinorVersionproperty 
readMinorVersion:int  [read-write]

The minor file format version for the input.

If this property is set, it forces the parser to read the specified minor version format.

If the value of this property is null (the default), the version attribute of the graphml element in the parsed file determines the minor version.

The default value is -1.

Implementation
    public function get readMinorVersion():int
    public function set readMinorVersion(value:int):void

See also

readRealizersproperty 
readRealizers:Boolean  [read-write]

Whether styles should be deserialized from realizers.

The default value is false.

Implementation
    public function get readRealizers():Boolean
    public function set readRealizers(value:Boolean):void
readStylesproperty 
readStyles:Boolean  [read-write]

Whether styles should be deserialized.

The default value is false.

Implementation
    public function get readStyles():Boolean
    public function set readStyles(value:Boolean):void
realizerSerializerManagerproperty 
realizerSerializerManager:RealizerSerializerManager  [read-only]

Get the RealizerSerializerManager instance used by this GraphMLIOHandler. This allows to set/add/remove IRealizerSerializers for a specific handler instance.

Implementation
    public function get realizerSerializerManager():RealizerSerializerManager
writeLabelsproperty 
writeLabels:Boolean  [read-write]

Whether labels should be serialized.

The default value is true.

Implementation
    public function get writeLabels():Boolean
    public function set writeLabels(value:Boolean):void
writeMajorVersionproperty 
writeMajorVersion:int  [read-write]

The major file format version for the output

The default value is com.yworks.io.graphml.GraphMLConstants#DEFAULT_FILE_VERSION_MAJOR.

Implementation
    public function get writeMajorVersion():int
    public function set writeMajorVersion(value:int):void

See also

writeMinorVersionproperty 
writeMinorVersion:int  [read-write]

The minor file format version for the output

The default value is com.yworks.io.graphml.GraphMLConstants#DEFAULT_FILE_VERSION_MINOR.

Implementation
    public function get writeMinorVersion():int
    public function set writeMinorVersion(value:int):void

See also

writeRealizersproperty 
writeRealizers:Boolean  [read-write]

Whether styles should be serialized as realizers.

The default value is false.

Implementation
    public function get writeRealizers():Boolean
    public function set writeRealizers(value:Boolean):void
writeSharedReferencesproperty 
writeSharedReferences:Boolean  [read-write]

Get or set whether embedded resources should be written in a separate block. If false, no resources are embedded in the graphml file. The exact behaviour in this case depends on the OutputHandler used. Default is true.

Implementation
    public function get writeSharedReferences():Boolean
    public function set writeSharedReferences(value:Boolean):void
writeStylesproperty 
writeStyles:Boolean  [read-write]

Whether styles should be serialized.

The default value is false.

Implementation
    public function get writeStyles():Boolean
    public function set writeStyles(value:Boolean):void
Constructor detail
GraphMLIOHandler()constructor
public function GraphMLIOHandler()

Constructor. initializes the default style input handlers.

Method detail
addEdgeAttribute()method
public function addEdgeAttribute(mapper:IMapper, attrName:String, type:String = "string"):void

Adds a GraphML attribute with edge scope that holds data of simple type.

Parameters
mapper:IMapper — The mapper that is accessed by the output handler whenever actual data for an edge is to be written to a GraphML file.
 
attrName:String — The name that is used inside the GraphML file with the XML attr.name attribute of the GraphML <key> element.
 
type:String (default = "string") — The attr.type of the attribute.
addInputHandler()method 
public function addInputHandler(handler:IInputHandler):void

Adds a input handler that can parse <data> blocks.

The scope is determined by the for attribute of the corresponding key node

Parameters
handler:IInputHandler — the input handler to add
addNamespace()method 
public function addNamespace(ns:Namespace):void

Adds a namespace to the header of a GraphML file.

Parameters
ns:Namespace — the namespace to add.
addNodeAttribute()method 
public function addNodeAttribute(mapper:IMapper, attrName:String, type:String = "string"):void

Adds a GraphML attribute with node scope that holds data of simple type.

Parameters
mapper:IMapper — The mapper that is accessed by the output handler whenever actual data for a node is to be written to a GraphML file.
 
attrName:String — The name that is used inside the GraphML file with the XML attr.name attribute of the GraphML <key> element.
 
type:String (default = "string") — The attr.type of the attribute.
addOutputHandler()method 
public function addOutputHandler(outputHandler:IOutputHandler, scope:String):void

Adds a subordinate output handler for the given element scope to this GraphMLIOHandler.

Parameters
outputHandler:IOutputHandler — the output handler to be added.
 
scope:String — Scope specifier. one of GraphMLConstants.SCOPE_GRAPH, GraphMLConstants.SCOPE_NODE, or GraphMLConstants.SCOPE_EDGE.
addRegistryEdgeAttribute()method 
public function addRegistryEdgeAttribute(registryTag:Object, attrName:String, type:String = "string"):void

Adds a GraphML attribute with edge scope that holds data of simple type.

Parameters
registryTag:Object — The tag that is used to retrieve the mapper instance from the graph's mapper registry.
 
attrName:String — The name that is used inside the GraphML file with the XML attr.name attribute of the GraphML <key> element.
 
type:String (default = "string") — The attr.type of the attribute.
addRegistryNodeAttribute()method 
public function addRegistryNodeAttribute(registryTag:Object, attrName:String, type:String = "string"):void

Adds a GraphML attribute with node scope that holds data of simple type.

Parameters
registryTag:Object — The tag that is used to retrieve the mapper instance from the graph's mapper registry.
 
attrName:String — The name that is used inside the GraphML file with the XML attr.name attribute of the GraphML <key> element.
 
type:String (default = "string") — The attr.type of the attribute.
createDirectGraphMLWriter()method 
protected function createDirectGraphMLWriter(graph:IGraph):DirectGraphMLWriter

Create the DirectGraphMLWriter instance that is used for writing GraphML output.

This method also creates the initial write context for the writer by calling createWriteContext

Parameters
graph:IGraph — The graph to create the writer for

Returns
DirectGraphMLWriter — the newly created writer.

See also

createGraphElementFactory()method 
protected function createGraphElementFactory(graph:IGraph):IGraphItemFactory

Create a suitable instance of IGraphElementFactory that can handle the given graph

Parameters
graph:IGraph — The graph that should be filled by this instance

Returns
IGraphItemFactory — A suitable instance of IGraphElementFactory that can handle the given graph
createGraphElementProvider()method 
protected function createGraphElementProvider(graph:IGraph):IGraphElementProvider

Create an IGraphElementProvider instance that provides the graph elements that are to be written.

Parameters
graph:IGraph — The graph instance to provide elements from.

Returns
IGraphElementProvider — The newly created graph element provider
createGraphMLParser()method 
protected function createGraphMLParser(graph:IGraph):GraphMLParser

Create the GraphMLParser instance that is used for writing GraphML output.

This method also creates the initial parse context for the parser by calling createParseContext

Parameters
graph:IGraph — The graph that is to be filled by the parser

Returns
GraphMLParser — the newly created GraphMLParser

See also

createParseContext()method 
protected function createParseContext(parser:GraphMLParser, graph:IGraph):GraphMLParseContext

Callback method for the creation of a new read context.

This method is called by createGraphMLParser

Parameters
parser:GraphMLParser — The reader to create the read context for.
 
graph:IGraph — The graph that is to be read by the reader

Returns
GraphMLParseContext — A context that can be passed to the reader as the initial context

See also

createWriteContext()method 
protected function createWriteContext(writer:DirectGraphMLWriter, graph:IGraph):GraphMLWriteContext

Callback method for the creation of a new write context.

This method is called by createDirectGraphMLWriter

Parameters
writer:DirectGraphMLWriter — The writer to create the write context for.
 
graph:IGraph — The graph that is to be written by the writer

Returns
GraphMLWriteContext — A context that can be passed to the core writer as initial context

See also

createXmlWriter()method 
protected function createXmlWriter():IXmlWriter

Create the IXmlWriter instance that is used for low-level XML writing.

Returns
IXmlWriter — The newly created IXmlWriter instance.
getInputHandlers()method 
public function getInputHandlers():Iterable

Returns an iterable view of all input handlers that have been registered with this instance.

Returns
Iterable — An Iterable of the registered input handlers.
getOutputHandlers()method 
public function getOutputHandlers(scope:String):Collection

Returns an editable view on the registered output handlers for GraphML attributes with given scope that are registered with this GraphMLIOHandler. Output handlers can be added or removed from the returned collection.

Parameters
scope:String — Scope specifier. one of GraphMLConstants.SCOPE_GRAPH, GraphMLConstants.SCOPE_NODE, or GraphMLConstants.SCOPE_EDGE.

Returns
Collection — All registered subordinate output handlers for GraphML attributes with given scope.
getRegisteredDeserializers()method 
public function getRegisteredDeserializers():Iterable

Returns an Iterable of all deserializers that have been registered with this instance.

Returns
Iterable — An Iterable of the registered deserializers.
getRegisteredSerializers()method 
public function getRegisteredSerializers():Iterable

Returns an iterable view of all serializers that have been registered with this instance.

Returns
Iterable — An Iterable of the registered serilaizers.
initializeHandlers()method 
protected function initializeHandlers():void

Callback for subclasses to register default data handlers. This implementation doesn't register any handlers.

read()method 
public function read(graph:IGraph, xml:XML):void

populate the given graph with the graph defined in the given xml file.

Parameters
graph:IGraph — The graph to populate.
 
xml:XML — The graphml file as a xml object.
readURL()method 
public function readURL(graph:IGraph, url:String):void

Populate the graph with the graph structure defined in a graph file located at the URL.

Parameters
graph:IGraph — the graph to fill.
 
url:String — An URL where a graph file is located.
registerDeserializer()method 
public function registerDeserializer(deserializer:IDeserializer):void

Register a IDeserializer instance for reading custom information.

Parameters
deserializer:IDeserializer — The deserializer to register.
registerSerializer()method 
public function registerSerializer(serializer:ISerializer):void

Register a ISerializer instance for writing custom information.

Parameters
serializer:ISerializer — The serializer to register.
removeInputHandler()method 
public function removeInputHandler(inputHandler:IInputHandler):void

Removes an input handler.

Parameters
inputHandler:IInputHandler — A previously added input handler that is to be removed.
removeOutputHandler()method 
public function removeOutputHandler(outputHandler:IOutputHandler, scope:String):void

Removes an output handler that was added for the given scope.

Parameters
outputHandler:IOutputHandler — The output handler to be removed.
 
scope:String — Scope specifier. one of GraphMLConstants.SCOPE_GRAPH, GraphMLConstants.SCOPE_NODE, or GraphMLConstants.SCOPE_EDGE.
unregisterDeserializer()method 
public function unregisterDeserializer(deserializer:IDeserializer):void

Unregister an IDeserializer instance that was previously registered.

Parameters
deserializer:IDeserializer — The deserializer to be deregistered.
unregisterSerializer()method 
public function unregisterSerializer(serializer:ISerializer):void

Unregister an ISerializer instance that was previously registered.

Parameters
serializer:ISerializer — The serializer to be deregistered.
write()method 
public function write(graph:IGraph):XML

Write the given graph to a XML Object in GraphML format. The exact output depends on the output handlers registered with this instance and on the readRealizers,writeRealizers,readStyles and writeStyles flags.

Parameters
graph:IGraph — The graph to be written.

Returns
XML — A XML object containing the GraphML output.

See also

Event detail
graphChangedevent 
Event object type: com.yworks.graph.model.GraphEvent

Dispatched when the io handler has finished parsing a graph. The GraphEvent kind is set to GraphEventKind.UPDATE.

httpStatusevent  
Event object type: flash.events.HTTPStatusEvent

Dispatched when readURL is used and a the server sends a HTTP status code.

ioErrorevent  
Event object type: flash.events.IOErrorEvent

Dispatched when readURL is used and an IO error occurs.

securityErrorevent  
Event object type: flash.events.SecurityErrorEvent

Dispatched when readURL is used and a security error occurs.