|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.yworks.yfiles.server.graphml.support.GraphMLLayoutGraphIOHandler
IOHandler for (de)serializing graphs from/to GraphML format.
GraphMLLayoutGraphIOHandler supports (de)serialization of custom GraphML attributes that
hold data of simple type, as well as ids, and styles as DocumentFragments.
For more information about the GraphML file format please refer to the GraphML Primer.
| Field Summary | |
protected List |
edgeOutputHandlers
|
protected List |
graphmlOutputHandlers
|
protected List |
graphOutputHandlers
|
protected List |
inputHandlers
|
protected List |
nodeOutputHandlers
|
protected List |
portOutputHandlers
|
protected boolean |
validationEnabled
|
protected boolean |
writeDTDEnabled
|
protected boolean |
writeXMLSchemaEnabled
|
| Constructor Summary | |
GraphMLLayoutGraphIOHandler()
Creates a new instance of GraphMLIOHandler. |
|
| Method Summary | |
void |
addAttribute(DataMap map,
String attrName,
int type,
int scope)
Adds a GraphML attribute with node scope that holds data of simple type. |
void |
addEdgeAttribute(DataProvider out,
DataAcceptor in,
String attrName,
int type)
Adds a GraphML attribute with edge scope that holds data of simple type. |
void |
addGraphAttribute(DataProvider out,
DataAcceptor in,
String attrName,
int type)
Adds a GraphML attribute with graph scope that holds data of simple type. |
void |
addInputHandler(DOMInputHandler inputHandler)
Adds a subordinate input handler to this GraphMLIOHandler. |
void |
addInputHandler(DOMInputHandler inputHandler,
int scope)
Deprecated. Use addInputHandler(org.graphdrawing.graphml.reader.dom.DOMInputHandler) instead |
void |
addNamespace(String namespaceURI,
String shortName)
Adds a namespace declaration to the GraphML file. |
void |
addNodeAttribute(DataProvider out,
DataAcceptor in,
String attrName,
int type)
Adds a GraphML attribute with node scope that holds data of simple type. |
void |
addOutputHandler(OutputHandler outputHandler,
int scope)
Adds a subordinate output handler for the given element scope to this GraphMLIOHandler. |
void |
addSchemaLocation(String namespace,
String schemaLocation)
Adds a schema location to the header of a GraphML file. |
boolean |
canRead()
Returns true. |
boolean |
canWrite()
Returns true. |
void |
clearInputHandlers()
Clear all input handlers |
protected void |
configureParser(DOMGraphMLParser graphMLParser,
Graph graph)
Configures the parser for the read operations. |
protected DirectGraphMLWriter |
createDirectGraphMLWriter()
Creates and returns a GraphML writer instance. |
protected YGraphElementFactory |
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 |
GraphMLParseErrorHandler |
getErrorHandler()
Return the parse error handler that is used by this instance. |
String |
getFileFormatString()
Returns the GraphML file format string. |
String |
getFileNameExtension()
Returns the default file name extension for GraphML files. |
DataAcceptor |
getGraphIdAcceptor()
Return the DataAcceptor instance for graph ids that has been previously registered with setGraphIdAcceptor(y.base.DataAcceptor) |
DataProvider |
getGraphIdProvider()
Return the DataProvider instance for graph ids that has been previously registered with setGraphIdProvider(y.base.DataProvider) |
String |
getGraphmlCoreNS()
Get the namespace URI where the core GraphML elements live. |
DataAcceptor |
getIdDataAcceptor()
Return the DataAcceptor instance for graph element ids that has been previously registered with setIdDataAcceptor(y.base.DataAcceptor) |
DataProvider |
getIdDataProvider()
Return the DataProvider instance for graph element ids that has been previously registered with setIdDataProvider(y.base.DataProvider) |
Collection |
getInputHandlers()
Returns the registered input handlers for GraphML attributes that are registered with this GraphMLIOHandler. |
Collection |
getInputHandlers(int scope)
Deprecated. Use getInputHandlers() instead |
String |
getOutputEncoding()
Get the output encoding that is used by this handler instance. |
Collection |
getOutputHandlers(int scope)
Returns an editable view on the registered output handlers for GraphML attributes with given scope that are registered with this GraphMLIOHandler. |
SerializerRegistry |
getSerializerRegistry()
|
boolean |
isReadEmbeddedResources()
Returns whether embedded resources should be evaluated. |
boolean |
isValidationEnabled()
Returns if a validating parser is used. |
boolean |
isWriteDTDEnabled()
Returns if a reference to the GraphML DTD should be written. |
boolean |
isWriteEmbeddedResources()
Returns whether embedded resources should be written in a separate block. |
boolean |
isWriteXMLSchemaEnabled()
Returns if a reference to the GraphML XML Schema definition should be written. |
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 |
removeInputHandler(DOMInputHandler handler)
unregister an inputhandler |
void |
setErrorHandler(GraphMLParseErrorHandler errorHandler)
Set a custom parse error handler that is used by this instance. |
void |
setGraphIdAcceptor(DataAcceptor graphIdAcceptor)
Register a DataAcceptor instance that stores graphml graph element ids for each graph itself.
|
void |
setGraphIdProvider(DataProvider graphIdProvider)
Register a DataProvider instance that provides graphml element ids for each graph itself.
|
void |
setGraphmlCoreNS(String graphmlCoreNS)
Set the namespace URI where the core GraphML elements live. |
void |
setIdDataAcceptor(DataAcceptor idDataAcceptor)
Register a DataAcceptor instance that stores graphml element ids.
|
void |
setIdDataProvider(DataProvider idDataProvider)
Register a DataProvider instance that provides graphml element ids for each element.
|
void |
setOutputEncoding(String outputEncoding)
Set a specific encoding for the output. |
void |
setReadEmbeddedResources(boolean readEmbeddedResource)
Set whether embedded resources should be evaluated. |
void |
setSerializerRegistry(SerializerRegistry serializerRegistry)
|
void |
setValidationEnabled(boolean b)
Sets if a validating parser is used. |
void |
setWriteDTDEnabled(boolean b)
Sets if a reference to the GraphML DTD should be written. |
void |
setWriteEmbeddedResources(boolean writeEmbeddedResource)
Set whether embedded resources should be written in a separate block. |
void |
setWriteXMLSchemaEnabled(boolean b)
Returns if a reference to the GraphML XML Schema definition should be written. |
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected boolean writeDTDEnabled
protected boolean writeXMLSchemaEnabled
protected boolean validationEnabled
protected List inputHandlers
protected List graphOutputHandlers
protected List graphmlOutputHandlers
protected List portOutputHandlers
protected List nodeOutputHandlers
protected List edgeOutputHandlers
| Constructor Detail |
public GraphMLLayoutGraphIOHandler()
y.view are already registered.
Also provided by default is support for post-processors.
PostprocessorInputHandler| Method Detail |
public String getOutputEncoding()
public void setOutputEncoding(String outputEncoding)
outputEncoding - custom output encodingpublic boolean isReadEmbeddedResources()
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.
public void setReadEmbeddedResources(boolean readEmbeddedResource)
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.
readEmbeddedResource - whether embedded resources should be read if present.public boolean isWriteEmbeddedResources()
false, no resources are embedded in the graphml file. The exact behaviour in this case depends on the
OutputHandler used. Default is true.
public void setWriteEmbeddedResources(boolean writeEmbeddedResource)
false, no resources are embedded in the graphml file. The exact behaviour in this case depends on the
OutputHandler used. Default is true.
writeEmbeddedResource - whether embedded resources should be written in a separate block.public GraphMLParseErrorHandler getErrorHandler()
public void setErrorHandler(GraphMLParseErrorHandler errorHandler)
errorHandler - the parse error handler that should be used by this instance.public String getGraphmlCoreNS()
"http://graphml.graphdrawing.org/xmlns/graphml" for compatibility
with older yfiles GraphML releases, however, the official GraphML namespace is now "http://graphml.graphdrawing.org/xmlns"
public void setGraphmlCoreNS(String graphmlCoreNS)
"http://graphml.graphdrawing.org/xmlns/graphml" for compatibility
with older yfiles GraphML releases, however, the official GraphML namespace is now "http://graphml.graphdrawing.org/xmlns"
graphmlCoreNS - the namespace URI where the core GraphML elements livepublic SerializerRegistry getSerializerRegistry()
public void setSerializerRegistry(SerializerRegistry serializerRegistry)
public String getFileFormatString()
public String getFileNameExtension()
graphmlpublic boolean canRead()
true.
public boolean canWrite()
true.
public void addInputHandler(DOMInputHandler inputHandler,
int scope)
addInputHandler(org.graphdrawing.graphml.reader.dom.DOMInputHandler) instead
addInputHandler(org.graphdrawing.graphml.reader.dom.DOMInputHandler) and
test the scope in DOMInputHandler.acceptKey(org.w3c.dom.NamedNodeMap,int) instead
inputHandler - the input handler to be added.scope - This parameter is unusedpublic void addInputHandler(DOMInputHandler inputHandler)
for attribute of the key node
inputHandler - the input handler to be added.
public void addOutputHandler(OutputHandler outputHandler,
int scope)
outputHandler - the output handler to be added.scope - Scope specifier; one of GraphMLConstants.SCOPE_GRAPH, GraphMLConstants.SCOPE_GRAPHML,
GraphMLConstants.SCOPE_NODE,
or GraphMLConstants.SCOPE_EDGE.public Collection getInputHandlers()
public Collection getInputHandlers(int scope)
getInputHandlers() instead
addInputHandler(org.graphdrawing.graphml.reader.dom.DOMInputHandler) and
test the scope in DOMInputHandler.acceptKey(org.w3c.dom.NamedNodeMap,int) instead
scope - This parameter is unused
public void clearInputHandlers()
public void removeInputHandler(DOMInputHandler handler)
handler - public Collection getOutputHandlers(int scope)
scope - Scope specifier; one of GraphMLConstants.SCOPE_GRAPH, GraphMLConstants.SCOPE_NODE,
or GraphMLConstants.SCOPE_EDGE.
protected DirectGraphMLWriter createDirectGraphMLWriter()
public void addAttribute(DataMap map,
String attrName,
int type,
int scope)
Note that the currently used yFiles data accessor implementations type-cast Java types long and float to int and double, respectively.
map - The node map that is accessed by both input and output handler whenever actual
data for a node is to be read from or written to a GraphML file.attrName - The name that is used inside the GraphML file with the XML attr.name
attribute of the GraphML <key> element.type - Type specifier as defined in interface AttributeConstants.scope - the GraphMLConstants scope to use.
public void addGraphAttribute(DataProvider out,
DataAcceptor in,
String attrName,
int type)
Note that the currently used yFiles data accessor implementations type-cast Java types long and float to int and double, respectively.
out - The data provider that is accessed by the output handler whenever actual data
for a graph is to be written to a GraphML file.in - The data acceptor that is accessed by the input handler whenever actual data
for a graph is to be read from a GraphML file.attrName - The name that is used inside the GraphML file with the XML attr.name
attribute of the GraphML <key> element.type - Type specifier as defined in interface AttributeConstants.
public void addNodeAttribute(DataProvider out,
DataAcceptor in,
String attrName,
int type)
Note that the currently used yFiles data accessor implementations type-cast Java types long and float to int and double, respectively.
out - The data provider that is accessed by the output handler whenever actual data
for a node is to be written to a GraphML file.in - The data acceptor that is accessed by the input handler whenever actual data
for a node is to be read from a GraphML file.attrName - The name that is used inside the GraphML file with the XML attr.name
attribute of the GraphML <key> element.type - Type specifier as defined in interface AttributeConstants.
public void addEdgeAttribute(DataProvider out,
DataAcceptor in,
String attrName,
int type)
out - The data provider that is accessed by the output handler whenever actual data
for an edge is to be written to a GraphML file.in - The data acceptor that is accessed by the input handler whenever actual data
for an edge is to be read from a GraphML file.attrName - The name that is used inside the GraphML file with the XML attr.name
attribute of the GraphML <key> element.type - Type specifier as defined in interface AttributeConstants.public boolean isValidationEnabled()
public boolean isWriteDTDEnabled()
public boolean isWriteXMLSchemaEnabled()
public void setValidationEnabled(boolean b)
public void setWriteDTDEnabled(boolean b)
public void setWriteXMLSchemaEnabled(boolean b)
public void addNamespace(String namespaceURI,
String shortName)
public void addSchemaLocation(String namespace,
String schemaLocation)
public void write(Graph graph,
String name)
throws IOException
name - The name of the output file
IOException
public void read(Graph graph,
String name)
throws IOException
name - The name of the file to be read.
IOException
public void read(Graph graph,
URL url)
throws IOException
url - The url of the resource to be read.
IOException
public void write(Graph graph,
OutputStream os)
throws IOException
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.
graph - The Graph2D object that is to be written to a GraphML file.os - The output stream that becomes the GraphML file.
IOExceptionYGraphElementProvider
public void write(Graph graph,
Writer writer)
throws IOException
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.
graph - The Graph2D object that is to be written to a GraphML file.writer - The writer that becomes the GraphML file.
IOExceptionYGraphElementProvider,
YHierarchyGraphElementProvider
public void write(Graph graph,
Result result)
throws IOException
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.
graph - The Graph2D object that is to be written to a GraphML file.result - The Transformer result that stores the output.
IOExceptionYGraphElementProvider,
YHierarchyGraphElementProviderprotected GraphElementProvider createGraphElementProvider(Graph graph)
public DataProvider getIdDataProvider()
setIdDataProvider(y.base.DataProvider)
setIdDataProvider(y.base.DataProvider)public void setIdDataProvider(DataProvider idDataProvider)
DataProvider instance that provides graphml element ids for each element.
DirectGraphMLWriter
will be used.setGraphIdProvider(y.base.DataProvider)
idDataProvider - public DataAcceptor getIdDataAcceptor()
setIdDataAcceptor(y.base.DataAcceptor)
setIdDataAcceptor(y.base.DataAcceptor)public void setIdDataAcceptor(DataAcceptor idDataAcceptor)
DataAcceptor instance that stores graphml element ids.
This stores a graphml element id for each graph element, except for nested graphs (see setGraphIdAcceptor(y.base.DataAcceptor)
idDataAcceptor - public DataAcceptor getGraphIdAcceptor()
setGraphIdAcceptor(y.base.DataAcceptor)
setGraphIdAcceptor(y.base.DataAcceptor)public void setGraphIdAcceptor(DataAcceptor graphIdAcceptor)
DataAcceptor instance that stores graphml graph element ids for each graph itself.
This stores a graph id for each group node in hierarchic graphs.
graphIdAcceptor - public DataProvider getGraphIdProvider()
setGraphIdProvider(y.base.DataProvider)
setGraphIdProvider(y.base.DataProvider)public void setGraphIdProvider(DataProvider graphIdProvider)
DataProvider instance that provides graphml element ids for each graph itself.
This should provide a graph id for each group node in hierarchic graphs.
DirectGraphMLWriter
will be used.
graphIdProvider -
public void read(Graph graph,
InputStream is)
throws IOException
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.
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.
IOExceptionYGraphElementFactory,
YHierarchyGraphElementFactory
public void read(Graph graph,
Node n)
throws IOException
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
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.
IOExceptionYGraphElementFactory,
YHierarchyGraphElementFactory
protected void configureParser(DOMGraphMLParser graphMLParser,
Graph graph)
graphMLParser - The parser to configuregraph - the graph that will be parsed.protected YGraphElementFactory createGraphElementFactory(Graph graph)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||