yext.graphml.compat
Class GraphMLLayoutGraphIOHandler

java.lang.Object
  extended byy.io.IOHandler
      extended byyext.graphml.graph2D.GraphMLIOHandler
          extended byyext.graphml.compat.GraphMLLayoutGraphIOHandler

public class GraphMLLayoutGraphIOHandler
extends GraphMLIOHandler

IOHandler for (de)serializing graphs from/to GraphML format. GraphMLIOHandler supports (de)serialization of custom GraphML attributes that hold data of simple type. Such GraphML attributes with graph, node, or edge scope can be conveniently enabled using one of the following methods addGraphAttribute, addNodeAttribute, or addEdgeAttribute.

For more information about the GraphML file format please refer to the GraphML Primer.


Field Summary
 
Fields inherited from class yext.graphml.graph2D.GraphMLIOHandler
edgeOutputHandlers, graphmlOutputHandlers, graphOutputHandlers, ignoreGraphicsEnabled, inputHandlers, nodeOutputHandlers, portOutputHandlers, validationEnabled, writeDTDEnabled, writeXMLSchemaEnabled
 
Constructor Summary
GraphMLLayoutGraphIOHandler()
           
 
Method Summary
protected  DirectGraphMLWriter createDirectGraphMLWriter(Graph graph)
          Creates and returns a GraphML writer instance.
protected  GraphElementFactory createGraphElementFactory(Graph graph)
          Create the factory instance used for reading the graph
protected  GraphElementProvider createGraphElementProvider(Graph graph)
          Create the provider instance used for writing the graph
protected  DOMGraphMLParser createParser(Graph graph)
           
 boolean isAutoCreateGroupingDPs()
          Returns whether data providers for grouping information should automatically be created and registered.
 void read(Graph graph, InputStream is)
          Reads a GraphML file from the given input stream and populates the Graph2D object.
 void read(Graph graph, Node n)
          Reads a Graph from a preparsed DOM tree object.
 void read(Graph graph, String name)
          Fills the contents of the given graph from a file.
 void read(Graph graph, URL url)
          Fills the contents of the given graph from a URL.
 void setAutoCreateGroupingDPs(boolean autoCreateGroupingDPs)
          Sets whether data providers for grouping information should automatically be created and registered.
 void write(Graph graph, OutputStream os)
          Writes the given Graph2D object to the output stream creating a GraphML file.
 void write(Graph graph, Result result)
          Writes the given Graph2D object to a Transformer result.
 void write(Graph graph, String name)
          Writes the contents of the given graph to a file.
 void write(Graph graph, Writer writer)
          Writes the given Graph2D object to the output stream creating a GraphML file.
 
Methods inherited from class yext.graphml.graph2D.GraphMLIOHandler
addAttribute, addAttribute, addEdgeAttribute, addEdgeRealizerSerializer, addGraphAttribute, addInputHandler, addInputHandler, addNamespace, addNodeAttribute, addNodeRealizerSerializer, addOutputHandler, addSchemaLocation, canRead, canWrite, clearInputHandlers, configureCoreWriter, createXmlWriter, createXmlWriter, createXmlWriter, getErrorHandler, getFileFormatString, getFileNameExtension, getGraphIdAcceptor, getGraphIdProvider, getGraphmlCoreNS, getIdDataAcceptor, getIdDataProvider, getInputHandlers, getInputHandlers, getOutputEncoding, getOutputHandlers, getRealizerSerializerManager, getResourceDecoderProvider, getResourceEncoderProvider, isIgnoreGraphicsEnabled, isReadEmbeddedResources, isValidationEnabled, isWriteDTDEnabled, isWriteEmbeddedResources, isWriteSelectionStateEnabled, isWriteXMLSchemaEnabled, read, read, removeInputHandler, setErrorHandler, setGraphIdAcceptor, setGraphIdProvider, setGraphmlCoreNS, setIdDataAcceptor, setIdDataProvider, setIgnoreGraphicsEnabled, setOutputEncoding, setReadEmbeddedResources, setValidationEnabled, setWriteDTDEnabled, setWriteEmbeddedResources, setWriteSelectionStateEnabled, setWriteXMLSchemaEnabled, write, write, write
 
Methods inherited from class y.io.IOHandler
canWriteSubset, createObjectInputStream, createObjectOutputStream, hide, read, read, shouldSerialize, shouldSerialize, write, writeSubset, writeSubset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphMLLayoutGraphIOHandler

public GraphMLLayoutGraphIOHandler()
Method Detail

isAutoCreateGroupingDPs

public boolean isAutoCreateGroupingDPs()
Returns whether data providers for grouping information should automatically be created and registered. This only has an effect if these DataProviders don't exist yet on the graph, otherwise an existing instance will away be used. Default value is false.

Returns:
See Also:
setAutoCreateGroupingDPs(boolean), GroupingKeys.GROUP_DPKEY, GroupingKeys.NODE_ID_DPKEY, GroupingKeys.PARENT_NODE_ID_DPKEY

setAutoCreateGroupingDPs

public void setAutoCreateGroupingDPs(boolean autoCreateGroupingDPs)
Sets whether data providers for grouping information should automatically be created and registered. This only has an effect if these DataProviders don't exist yet on the graph, otherwise an existing instance will away be used. Default value is false.

Note: If this flag is set to true, DataProviders for the following keys will be automatically created and registered:

In that case, it is not safe to modify the graph afterwards and query the group structure.

See Also:
isAutoCreateGroupingDPs(), GroupingKeys.GROUP_DPKEY, GroupingKeys.NODE_ID_DPKEY, GroupingKeys.PARENT_NODE_ID_DPKEY

write

public void write(Graph graph,
                  String name)
           throws IOException
Writes the contents of the given graph to a file.

Parameters:
name - The name of the output file
Throws:
IOException

write

public void write(Graph graph,
                  OutputStream os)
           throws IOException
Writes the given Graph2D object to the output stream creating a GraphML file. The proper DTD (Document Type Definition), or alternatively XML Schema definition, as well as the XML header is also written.

Note that the graph element provider that is used by the encoder logic to write the GraphML file is chosen depending on whether the Graph2D object has a HierarchyManager associated or not.

Parameters:
graph - The Graph2D object that is to be written to a GraphML file.
os - The output stream that becomes the GraphML file.
Throws:
IOException
See Also:
YGraphElementProvider

write

public void write(Graph graph,
                  Writer writer)
           throws IOException
Writes the given Graph2D object to the output stream creating a GraphML file. The proper DTD (Document Type Definition), or alternatively XML Schema definition, as well as the XML header is also written.

Note that the graph element provider that is used by the encoder logic to write the GraphML file is chosen depending on whether the Graph2D object has a HierarchyManager associated or not.

Parameters:
graph - The Graph2D object that is to be written to a GraphML file.
writer - The writer that becomes the GraphML file.
Throws:
IOException
See Also:
YGraphElementProvider, YHierarchyGraphElementProvider

write

public void write(Graph graph,
                  Result result)
           throws IOException
Writes the given Graph2D object to a Transformer result. The proper DTD (Document Type Definition), or alternatively XML Schema definition, as well as the XML header is also written.

Note that the graph element provider that is used by the encoder logic to write the GraphML file is chosen depending on whether the Graph2D object has a HierarchyManager associated or not.

This method is especially useful if the result should be postprocessed by other XML applications directly (i.e. without re-reading and parsing)

Parameters:
graph - The Graph2D object that is to be written to a GraphML file.
result - The Transformer result that stores the output.
Throws:
IOException
See Also:
YGraphElementProvider, YHierarchyGraphElementProvider

createGraphElementProvider

protected GraphElementProvider createGraphElementProvider(Graph graph)
Create the provider instance used for writing the graph

Overrides:
createGraphElementProvider in class GraphMLIOHandler

createDirectGraphMLWriter

protected DirectGraphMLWriter createDirectGraphMLWriter(Graph graph)
Description copied from class: GraphMLIOHandler
Creates and returns a GraphML writer instance. Note that this method is also invoked to create the GraphML writer that is used with this GraphMLIOHandler.

Overrides:
createDirectGraphMLWriter in class GraphMLIOHandler

read

public void read(Graph graph,
                 String name)
          throws IOException
Fills the contents of the given graph from a file.

Parameters:
name - The name of the file to be read.
Throws:
IOException

read

public void read(Graph graph,
                 URL url)
          throws IOException
Fills the contents of the given graph from a URL.

Parameters:
url - The url of the resource to be read.
Throws:
IOException

read

public void read(Graph graph,
                 InputStream is)
          throws IOException
Reads a GraphML file from the given input stream and populates the Graph2D object.

Note that the graph element factory that is used by the parser logic to create new graph elements (and eventually also new graphs) is chosen depending on whether the Graph2D object has a HierarchyManager associated or not.

Parameters:
graph - The Graph2D object that is to be populated with nodes and edges as read from the GraphML file.
is - The input stream that holds the GraphML file to be read.
Throws:
IOException
See Also:
YGraphElementFactory, YHierarchyGraphElementFactory

read

public void read(Graph graph,
                 Node n)
          throws IOException
Reads a Graph from a preparsed DOM tree object.

Note that the graph element factory that is used by the parser logic to create new graph elements (and eventually also new graphs) is chosen depending on whether the Graph2D object has a HierarchyManager associated or not. This overload is useful if the IOHandler is used after a chain of TRaX transformations

Note: No validation is performed on the DOM tree by this overload.

Parameters:
graph - The Graph2D object that is to be populated with nodes and edges as read from the GraphML file.
n - The root node of the preparsed DOM tree.
Throws:
IOException
See Also:
YGraphElementFactory, YHierarchyGraphElementFactory

createParser

protected DOMGraphMLParser createParser(Graph graph)
Overrides:
createParser in class GraphMLIOHandler

createGraphElementFactory

protected GraphElementFactory createGraphElementFactory(Graph graph)
Create the factory instance used for reading the graph

Overrides:
createGraphElementFactory in class GraphMLIOHandler


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