|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecty.io.graphml.GraphMLHandler
public class GraphMLHandler
Class for reading/writing graphs from/to GraphML format.
For more information about the GraphML file format please refer to the GraphML Primer.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Constructor Summary | |
---|---|
GraphMLHandler()
|
Method Summary | |
---|---|
void |
addDeserializationHandler(DeserializationHandler listener)
Register an event listener that can be used to handle DeserializationEvent s. |
void |
addInputDataAcceptor(GraphMLHandler.InputHandlerQueryPredicate keyDefinitionPredicate,
DataAcceptor dataAcceptor,
DeserializationHandler deserializationCallback)
Register a DataAcceptor instance for
use as an input data target. |
void |
addInputDataAcceptor(GraphMLHandler.InputHandlerQueryPredicate keyDefinitionPredicate,
DataAcceptor dataAcceptor,
KeyType valueType)
Register a DataAcceptor instance for
use as an input data target. |
void |
addInputDataAcceptor(java.lang.String name,
DataAcceptor dataAcceptor,
KeyScope scope,
DeserializationHandler deserializationCallback)
Register a DataAcceptor instance for
use as an input data target
for the actual deserialization. |
void |
addInputDataAcceptor(java.lang.String name,
DataAcceptor dataAcceptor,
KeyScope scope,
KeyType valueType)
Register a DataAcceptor instance for
use as an input data target
for the actual deserialization. |
void |
addInputDataAcceptor(java.lang.String name,
DataAcceptor dataAcceptor,
KeyType valueType)
Register a DataAcceptor instance for
use as an input data target. |
void |
addInputDataAcceptor(java.lang.String name,
java.lang.Object dataProviderKey,
KeyScope scope,
KeyType valueType)
Use a previously registered DataAcceptor instance for
use as an input data target
for the actual deserialization. |
Future |
addInputDataAcceptorFuture(GraphMLHandler.InputHandlerQueryPredicate predicate,
KeyType valueType)
Create a Future instance that wraps an DataMap for
use as an input data target. |
Future |
addInputDataAcceptorFuture(java.lang.String name,
KeyScope scope,
KeyType valueType)
Create a Future instance that wraps an DataMap for
use as an input data target. |
Future |
addInputDataAcceptorFuture(java.lang.String name,
KeyType valueType)
Create a Future instance that wraps an DataMap for
use as an input data target. |
void |
addInputHandlerProvider(InputHandlerProvider provider)
Register an event listener that can be used to handle QueryInputHandlersEvent s. |
void |
addNamespace(java.lang.String namespaceURI,
java.lang.String shortName)
Adds a namespace declaration to the header of a GraphML file. |
void |
addOutputDataProvider(java.lang.String name,
DataProvider dataProvider,
KeyScope scope,
KeyType type)
Register a DataProvider instance for
use as an output data source
This methods creates and configures the necessary handler
itself. |
void |
addOutputDataProvider(java.lang.String name,
DataProvider dataProvider,
KeyScope scope,
SerializationHandler serializationCallback)
Register a DataProvider instance for
use as an output data source. |
void |
addOutputDataProvider(java.lang.String name,
java.lang.String uri,
DataProvider dataProvider,
KeyScope scope,
KeyType type)
Register a DataProvider instance for
use as an output data source
This methods creates and configures the necessary handler
itself. |
void |
addOutputDataProvider(java.lang.String name,
java.lang.String uri,
DataProvider dataProvider,
KeyScope scope,
KeyType type,
SerializationHandler serializationCallback)
Register a DataProvider instance for
use as an output data source. |
void |
addOutputHandlerProvider(OutputHandlerProvider provider)
Register an event listener that can be used to handle QueryOutputHandlersEvent s. |
void |
addParseEventListener(ParseEventListener listener)
Register a ParseEventListener . |
void |
addRegisteredOutputDataProvider(java.lang.String name,
KeyScope scope,
KeyType type)
Use DataProvider instance that has been registered on the underlying graph instance
as source for the given GraphML attribute. |
void |
addRegisteredOutputDataProvider(java.lang.String name,
java.lang.Object registryTag,
KeyScope scope,
KeyType type)
Use DataProvider instance that has been registered on the underlying graph instance
as source for the given GraphML attribute. |
void |
addRegisteredOutputDataProvider(java.lang.String name,
java.lang.String uri,
java.lang.Object registryTag,
KeyScope scope,
KeyType type)
Use DataProvider instance that has been registered on the underlying graph instance
as source for the given GraphML attribute. |
void |
addSchemaLocation(java.lang.String schemaNamespace,
java.lang.String schemaLocation)
Adds a schema location to the header of a GraphML file. |
void |
addSerializationHandler(SerializationHandler listener)
Register an event listener that can be used to handle SerializationEvent s. |
void |
addWriteEventListener(WriteEventListener listener)
Register a WriteEventListener . |
protected void |
configureDeserializationHandlers(Graph graph,
GraphMLParser parser)
Configure predefined handlers for the DeserializationEvent event. |
protected void |
configureDeserializationProperties(Graph graph,
GraphMLParser parser)
Configure important deserialization properties of GraphMLHandler . |
protected void |
configureGraphMLParser(Graph graph,
GraphMLParser parser)
Configures the specified GraphMLParser to handle the given graph. |
protected void |
configureGraphMLWriter(Graph graph,
GraphMLWriter writer)
Configures the specified GraphMLWriter for writing the given graph. |
protected void |
configureInputHandlers(Graph graph,
GraphMLParser parser)
Configures default event handlers for the GraphMLParser.fireQueryInputHandlersEvent(y.io.graphml.input.QueryInputHandlersEvent) event. |
protected void |
configureLookup(Graph graph,
GraphMLParser parser)
Configure the default lookup map of parser . |
protected void |
configureLookup(Graph graph,
GraphMLWriter writer)
Configure the default lookup map of writer . |
protected void |
configureNamespaces(GraphMLWriter writer)
Configures writer to use the namespace declarations set with
addNamespace(String, String) . |
protected void |
configureOutputHandlers(Graph graph,
GraphMLWriter writer)
Configures default event handlers for the QueryOutputHandlersEvent event. |
protected void |
configureParseEvents(Graph graph,
GraphMLParser parser)
Configure the default parse events of parser . |
protected void |
configureSchemaLocations(GraphMLWriter writer)
Configures writer to use the schema locations set with
addSchemaLocation(String, String) . |
protected void |
configureSerializationHandlers(Graph graph,
GraphMLWriter writer)
Configure the predefined handlers for the SerializationEvent event. |
protected void |
configureSerializationProperties(Graph graph,
GraphMLWriter writer)
Configure important serialization properties of GraphMLHandler . |
protected void |
configureWriteEvents(Graph graph,
GraphMLWriter writer)
Configure the default write events of writer . |
protected void |
configureXMLWriter(XmlWriter writer)
Configure writer . |
protected GraphElementFactory |
createGraphElementFactory(GraphMLParser parser,
Graph graph)
Create an GraphElementFactory instance that creates the graph elements for the graph instance. |
protected GraphMLParser |
createGraphMLParser(Graph graph)
Creates a suitable instance of GraphMLParser that can handle the given graph. |
protected GraphMLWriter |
createGraphMLWriter(Graph graph)
Creates and configures a new GraphMLWriter that is used for writing
the specified graph. |
protected XmlWriter |
createXMLWriter(java.io.OutputStream os,
java.lang.String encoding)
Factory method that creates and configures a suitable XmlWriter implementation that
can write the graph to the given OutputStream with the given settings. |
protected XmlWriter |
createXMLWriter(java.io.Writer writer)
Factory method that creates and configures a suitable XmlWriter implementation that
can write the graph to the given Writer with the given settings |
protected void |
fireDeserializationEvent(DeserializationEvent event)
Notifies all registered DeserializationHandler instances of event . |
protected void |
fireQueryInputHandlersProviders(QueryInputHandlersEvent event)
Notifies all registered InputHandlerProvider instances of event . |
protected void |
fireQueryOutputHandlersEvent(QueryOutputHandlersEvent event)
Notifies all registered OutputHandlerProvider instances of event . |
protected void |
fireSerializationEvent(SerializationEvent event)
Notifies all registered SerializationHandler instances of event . |
java.lang.Object |
getDeserializationProperty(java.lang.Object key)
Retrieves a deserialization property that has been set using setDeserializationProperty(Object, Object) . |
static java.lang.String |
getKeyName(org.w3c.dom.Element keyDefinition)
Get the attribute name from an GraphML keyDefinition element. |
static KeyScope |
getKeyScope(org.w3c.dom.Element keyDefinition)
Get the KeyScope from an GraphML keyDefinition element. |
static KeyType |
getKeyType(org.w3c.dom.Element keyDefinition)
Get the KeyType from an GraphML keyDefinition element. |
static java.lang.String |
getKeyUri(org.w3c.dom.Element keyDefinition)
Get the attribute URI from an GraphML keyDefinition element. |
java.lang.Object |
getSerializationProperty(java.lang.Object key)
Retrieves a serialization property that has been set using setSerializationProperty(Object, Object) . |
boolean |
isClearGraphBeforeRead()
Whether to clear an existing graph instance before reading If true , an existing graph instance will be cleared
before the graph is read into this instance, otherwise the loaded
graph will be merged into the existing one. |
boolean |
isWriteXMLSchema()
Gets whether schema locations should be written. |
static boolean |
matchesName(org.w3c.dom.Element keyDefinition,
java.lang.String name)
Utility method that checks whether the attr.name attribute in a GraphML key definition matches
name . |
static boolean |
matchesScope(org.w3c.dom.Element keyDefinition,
KeyScope scope)
Utility method that checks whether the for attribute in a GraphML key definition matches
scope . |
static boolean |
matchesType(org.w3c.dom.Element keyDefinition,
KeyType type)
Utility method that checks whether the attr.type attribute in a GraphML key definition matches
type . |
static boolean |
matchesUri(org.w3c.dom.Element keyDefinition,
java.lang.String uri)
Utility method that checks whether the attr.uri attribute in a GraphML key definition matches
uri . |
protected void |
onGraphMLParserHandleDeserialization(DeserializationEvent e)
Default event listener that is registered to GraphMLParser.addDeserializationHandler(y.io.graphml.input.DeserializationHandler) . |
protected void |
onGraphMLParserQueryInputHandlers(QueryInputHandlersEvent e)
Default event listener that is registered to GraphMLParser.addInputHandlerProvider(y.io.graphml.input.InputHandlerProvider) . |
protected void |
onGraphMLWriterHandleSerialization(SerializationEvent e)
Default event listener that is registered to GraphMLWriter.addSerializationHandler(y.io.graphml.output.SerializationHandler) . |
protected void |
onGraphMLWriterQueryOutputHandlers(QueryOutputHandlersEvent e)
Default event listener that is registered to GraphMLWriter.addOutputHandlerProvider(y.io.graphml.output.OutputHandlerProvider) . |
void |
read(Graph graph,
org.w3c.dom.Document doc)
Read GraphML from an existing XML document. |
void |
read(Graph graph,
java.io.InputStream stream)
Reads GraphML content from the given input stream and populates the Graph object. |
void |
removeDeserializationHandler(DeserializationHandler listener)
Unregister an event listener that has been registered with addDeserializationHandler(DeserializationHandler) . |
void |
removeDeserializationProperty(java.lang.Object key)
Removes a deserialization property that has been set using setDeserializationProperty(Object, Object) . |
void |
removeInputHandlerProvider(InputHandlerProvider provider)
Unregister an event listener that has been registered with addInputHandlerProvider(InputHandlerProvider) . |
void |
removeOutputHandlerProvider(OutputHandlerProvider provider)
Unregister an event listener that has been registered with addOutputHandlerProvider(OutputHandlerProvider) . |
void |
removeParseEventListener(ParseEventListener listener)
Unregister a ParseEventListener that
has been registered with addParseEventListener(ParseEventListener) |
void |
removeSerializationHandler(SerializationHandler listener)
Unregister an event listener that has been registered with addSerializationHandler(y.io.graphml.output.SerializationHandler) . |
void |
removeSerializationProperty(java.lang.Object key)
Removes the serialization property that has been set using setDeserializationProperty(Object, Object) . |
void |
removeWriteEventListener(WriteEventListener listener)
Unregister a WriteEventListener that
has been registered with addWriteEventListener(y.io.graphml.output.WriteEventListener) |
void |
setClearGraphBeforeRead(boolean value)
Whether to clear an existing graph instance before reading If set to true , an existing graph instance will be cleared
before the graph is read into this instance, otherwise the loaded
graph will be merged into the existing one. |
void |
setDeserializationProperty(java.lang.Object key,
java.lang.Object value)
Sets a deserialization property that allows to fine tune the parse process. |
void |
setSerializationProperty(java.lang.Object key,
java.lang.Object value)
Sets a serialization property that allows to fine tune the write process. |
void |
setWriteXMLSchema(boolean value)
Sets whether schema locations should be written. |
void |
write(Graph graph,
java.io.OutputStream os)
Writes the given graph Object to the output stream creating a GraphML file. |
void |
write(Graph graph,
java.io.OutputStream os,
java.lang.String encoding)
Writes the given graph Object to the output stream creating a GraphML file. |
void |
write(Graph graph,
java.io.Writer os)
Writes the given graph Object to the writer creating a GraphML file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GraphMLHandler()
Method Detail |
---|
public boolean isWriteXMLSchema()
true
if schema locations should be written at all.setWriteXMLSchema(boolean)
,
addSchemaLocation(String,String)
public void setWriteXMLSchema(boolean value)
value
- true
if schema locations should be written at all.isWriteXMLSchema()
,
addSchemaLocation(String,String)
public boolean isClearGraphBeforeRead()
If true
, an existing graph instance will be cleared
before the graph is read into this instance, otherwise the loaded
graph will be merged into the existing one.
true
.
true
if an existing graph instance should be cleared before writing.setClearGraphBeforeRead(boolean)
public void setClearGraphBeforeRead(boolean value)
If set to true
, an existing graph instance will be cleared
before the graph is read into this instance, otherwise the loaded
graph will be merged into the existing one.
true
value
- true
if an existing graph instance should be cleared before writing.isClearGraphBeforeRead()
public void addNamespace(java.lang.String namespaceURI, java.lang.String shortName)
namespaceURI
- The namespace URIshortName
- The namespace prefixpublic void addSchemaLocation(java.lang.String schemaNamespace, java.lang.String schemaLocation)
schemaNamespace
- The namespace URI for this schema locationschemaLocation
- The schema locationsetWriteXMLSchema(boolean)
,
isWriteXMLSchema()
public void write(Graph graph, java.io.OutputStream os) throws GraphMLWriteException
This method just calls write(y.base.Graph,java.io.OutputStream,String)
with
the default "UTF-8" encoding.
graph
- The Graph Object that is to be written to a GraphML file.os
- The output stream where the output is written.
java.lang.IllegalArgumentException
- if graph
or os
is null
.
GraphMLWriteException
public void write(Graph graph, java.io.OutputStream os, java.lang.String encoding) throws GraphMLWriteException
graph
- The Graph Object that is to be written to a GraphML file.os
- The output stream where the output is written.encoding
- The encoding that should be used for writing
java.lang.IllegalArgumentException
- if graph
or os
is null
.
GraphMLWriteException
public void write(Graph graph, java.io.Writer os) throws GraphMLWriteException
graph
- The Graph Object that is to be written to a GraphML file.os
- The writer where the output is written.
java.lang.IllegalArgumentException
- if graph
or os
is null
.
GraphMLWriteException
public void addOutputDataProvider(java.lang.String name, DataProvider dataProvider, KeyScope scope, KeyType type)
DataProvider
instance for
use as an output data source
This methods creates and configures the necessary handler itself.
name
- The name of the attributedataProvider
- the DataProvider that serves as data sourcescope
- the type of the keys in the DataProvidertype
- the type of the values in the DataProviderpublic void addOutputDataProvider(java.lang.String name, java.lang.String uri, DataProvider dataProvider, KeyScope scope, KeyType type)
DataProvider
instance for
use as an output data source
This methods creates and configures the necessary handler itself.
name
- The name of the attributeuri
- The URI to add to the key definition to disambiguate keys.dataProvider
- the DataProvider that serves as data sourcescope
- the type of the keys in the DataProvidertype
- the type of the values in the DataProviderpublic void addOutputDataProvider(java.lang.String name, DataProvider dataProvider, KeyScope scope, SerializationHandler serializationCallback)
DataProvider
instance for
use as an output data source.
This method uses a custom SerializationHandler
for the actual serialization and implies KeyType.COMPLEX
as serialization type.
This methods creates and configures the necessary handler. itself.
name
- The name of the attribute.dataProvider
- The DataProvider that serves as data source.serializationCallback
- Custom serialization callback.public void addOutputDataProvider(java.lang.String name, java.lang.String uri, DataProvider dataProvider, KeyScope scope, KeyType type, SerializationHandler serializationCallback)
DataProvider
instance for
use as an output data source.
This method uses a custom SerializationHandler
for the actual serialization.
name
- The name of the attributeuri
- The (optional) attribute URI for more precise attribute identification.dataProvider
- The DataProvider that serves as data source.scope
- The scope of the attribute.type
- The KeyType of the attribute.serializationCallback
- Custom serialization callback.public void addRegisteredOutputDataProvider(java.lang.String name, KeyScope scope, KeyType type)
DataProvider
instance that has been registered on the underlying graph instance
as source for the given GraphML attribute.
name
- The GraphML name of the attribute, as well as the tag name of
the DataProvider for Graph.getDataProvider(Object)
scope
- The scope of the attribute.type
- The KeyType of the attribute.public void addRegisteredOutputDataProvider(java.lang.String name, java.lang.Object registryTag, KeyScope scope, KeyType type)
DataProvider
instance that has been registered on the underlying graph instance
as source for the given GraphML attribute.
name
- The GraphML name of the attributeregistryTag
- The tag of the DataProvider for Graph.getDataProvider(Object)
scope
- The scope of the attribute.type
- The KeyType of the attribute.public void addRegisteredOutputDataProvider(java.lang.String name, java.lang.String uri, java.lang.Object registryTag, KeyScope scope, KeyType type)
DataProvider
instance that has been registered on the underlying graph instance
as source for the given GraphML attribute.
name
- The GraphML name of the attributeuri
- The URI to add to the key definition to disambiguate keys.registryTag
- The tag of the DataProvider for Graph.getDataProvider(Object)
scope
- The scope of the attribute.type
- The KeyType of the attribute.protected GraphMLWriter createGraphMLWriter(Graph graph)
GraphMLWriter
that is used for writing
the specified graph.
Calls
configureGraphMLWriter(y.base.Graph, y.io.graphml.output.GraphMLWriter)
after creating a new GraphMLWriter
instance.
graph
- The graph that will be written.
GraphMLWriter
instance that is configured for graph
.protected void configureGraphMLWriter(Graph graph, GraphMLWriter writer)
GraphMLWriter
for writing the given graph.
Called from createGraphMLWriter(y.base.Graph)
.
graph
- The graph to write.writer
- The writer to configure.protected void configureLookup(Graph graph, GraphMLWriter writer)
writer
.
This implementation does not configure any specific lookup implementations
graph
- The graph that will be written.writer
- The writer to configure.GraphMLWriter.setLookup(Class,Object)
protected void configureSerializationProperties(Graph graph, GraphMLWriter writer)
GraphMLHandler
.
graph
- The graph to write.writer
- The writer to configure.GraphMLWriter.setSerializationProperty(Object,Object)
public void setSerializationProperty(java.lang.Object key, java.lang.Object value)
key
- The key for the property.value
- The value of the property.getSerializationProperty(Object)
public void removeSerializationProperty(java.lang.Object key)
setDeserializationProperty(Object, Object)
.
key
- The key for the property.setSerializationProperty(Object, Object)
public java.lang.Object getSerializationProperty(java.lang.Object key)
setSerializationProperty(Object, Object)
.
key
- The key for the property.
setSerializationProperty(Object, Object)
protected XmlWriter createXMLWriter(java.io.Writer writer) throws GraphMLWriteException
XmlWriter
implementation that
can write the graph to the given Writer
with the given settings
writer
- The serialization destination
XmlWriter
instance for the serialization
GraphMLWriteException
protected XmlWriter createXMLWriter(java.io.OutputStream os, java.lang.String encoding) throws GraphMLWriteException
XmlWriter
implementation that
can write the graph to the given OutputStream
with the given settings.
os
- The serialization destinationencoding
- The encoding of the stream
XmlWriter
instance for the serialization
GraphMLWriteException
protected void configureXMLWriter(XmlWriter writer)
writer
.
This implementation does nothing.
writer
- The writer to configure.protected void configureSchemaLocations(GraphMLWriter writer)
writer
to use the schema locations set with
addSchemaLocation(String, String)
.
In addition to the schema locations configured with
addSchemaLocation(String, String)
, this method also sets the
schema location for the core GraphML namespace if not overridden with
addSchemaLocation(String, String)
.
writer
- The writer to configure.protected void configureNamespaces(GraphMLWriter writer)
writer
to use the namespace declarations set with
addNamespace(String, String)
.
In addition to the namespace declarations configured with
addNamespace(String,String)
, this method also sets the namespace
declarations for the core GraphML namespace, the yFile for Java
extensions, and the namespaces for Java framework classes if not overridden
with addNamespace(String, String)
.
writer
- The writer to configure.protected void configureOutputHandlers(Graph graph, GraphMLWriter writer)
QueryOutputHandlersEvent
event.
This implementation does not configure any output handlers.
graph
- The graph that will be written.writer
- The writer that should be configured.protected void configureSerializationHandlers(Graph graph, GraphMLWriter writer)
SerializationEvent
event.
This implementation does not configure any serialization handlers.
graph
- The graph that will be written.writer
- The writer to configure.protected void configureWriteEvents(Graph graph, GraphMLWriter writer)
writer
.
This implementation registers a single write event handler that forwards to listeners registered with
addWriteEventListener(y.io.graphml.output.WriteEventListener)
graph
- The graph that will be written.writer
- The writer to configure.GraphMLWriter.getWriteEventHandler()
public void addOutputHandlerProvider(OutputHandlerProvider provider)
QueryOutputHandlersEvent
s.
Registering a listener allows to use OutputHandler
s dynamically, depending on the
actual graph data. For each write, a QueryOutputHandlersEvent
is fired and
propagated to all registered event listeners.
provider
- Event listener for the QueryInputHandlersEvent
fireQueryOutputHandlersEvent(QueryOutputHandlersEvent)
,
removeOutputHandlerProvider(OutputHandlerProvider)
,
GraphMLWriter.addOutputHandlerProvider(OutputHandlerProvider)
public void removeOutputHandlerProvider(OutputHandlerProvider provider)
addOutputHandlerProvider(OutputHandlerProvider)
.
provider
- Event listener for the QueryOutputHandlersEvent
fireQueryOutputHandlersEvent(QueryOutputHandlersEvent)
,
addOutputHandlerProvider(OutputHandlerProvider)
,
GraphMLWriter.removeOutputHandlerProvider(OutputHandlerProvider)
protected void fireQueryOutputHandlersEvent(QueryOutputHandlersEvent event) throws GraphMLWriteException
OutputHandlerProvider
instances of event
.
For each write, a QueryOutputHandlersEvent
is fired and
propagated to all registered event listeners.
event
- The event that has been raised.
GraphMLWriteException
OutputHandler
,
OutputHandlerProvider
,
addOutputHandlerProvider(OutputHandlerProvider)
,
GraphMLWriter.fireQueryOutputHandlersEvent(QueryOutputHandlersEvent)
protected void onGraphMLWriterQueryOutputHandlers(QueryOutputHandlersEvent e) throws GraphMLWriteException
GraphMLWriter.addOutputHandlerProvider(y.io.graphml.output.OutputHandlerProvider)
.
This implementation just propagates the event e
to all registered event handlers by calling
fireQueryOutputHandlersEvent(y.io.graphml.output.QueryOutputHandlersEvent)
.
e
- The event data.
GraphMLWriteException
public void addSerializationHandler(SerializationHandler listener)
SerializationEvent
s.
Registering a listener allows to use custom serialization code.
listener
- Event listener for the SerializationEvent
fireSerializationEvent(SerializationEvent)
,
removeSerializationHandler(y.io.graphml.output.SerializationHandler)
,
GraphMLWriter.addSerializationHandler(y.io.graphml.output.SerializationHandler)
public void removeSerializationHandler(SerializationHandler listener)
addSerializationHandler(y.io.graphml.output.SerializationHandler)
.
listener
- Event listener for the SerializationEvent
fireSerializationEvent(SerializationEvent)
,
addSerializationHandler(y.io.graphml.output.SerializationHandler)
,
GraphMLWriter.removeSerializationHandler(y.io.graphml.output.SerializationHandler)
protected void fireSerializationEvent(SerializationEvent event) throws GraphMLWriteException
SerializationHandler
instances of event
.
Usually, this method is called indirectly through calls to
GraphMLWriteContext.serialize(Object)
to write the XML representation of an object.
event
- The event that has been raised.
GraphMLWriteException
SerializationHandler
,
addSerializationHandler(y.io.graphml.output.SerializationHandler)
,
GraphMLWriteContext.serialize(Object)
,
GraphMLWriter.fireSerializationEvent(y.io.graphml.output.SerializationEvent)
protected void onGraphMLWriterHandleSerialization(SerializationEvent e) throws GraphMLWriteException
GraphMLWriter.addSerializationHandler(y.io.graphml.output.SerializationHandler)
.
This implementation just propagates the event e
to all registered event handlers by calling
fireSerializationEvent(y.io.graphml.output.SerializationEvent)
.
e
- The event data.
GraphMLWriteException
public void addWriteEventListener(WriteEventListener listener)
WriteEventListener
.
listener
- The listener to add.removeWriteEventListener(y.io.graphml.output.WriteEventListener)
public void removeWriteEventListener(WriteEventListener listener)
WriteEventListener
that
has been registered with addWriteEventListener(y.io.graphml.output.WriteEventListener)
listener
- The listener to remove.addWriteEventListener(y.io.graphml.output.WriteEventListener)
public void read(Graph graph, java.io.InputStream stream) throws GraphMLParseException
graph
- The Graph Object that is to be populated from the stream.stream
- The input stream that holds the GraphML file to be read.
java.lang.IllegalArgumentException
- stream
or graph
are null.
GraphMLParseException
public void read(Graph graph, org.w3c.dom.Document doc) throws GraphMLParseException
graph
- The Graph Object that is to be populated from the document.doc
- The XML document.
java.lang.IllegalArgumentException
- if doc
or graph
are null.
GraphMLParseException
public void addInputDataAcceptor(java.lang.String name, DataAcceptor dataAcceptor, KeyType valueType)
DataAcceptor
instance for
use as an input data target.
This methods creates and configures the necessary handler itself.
valueType
- The type of the DataAcceptor valuesname
- The name of the attributedataAcceptor
- the DataAcceptor that serves as data targetpublic void addInputDataAcceptor(GraphMLHandler.InputHandlerQueryPredicate keyDefinitionPredicate, DataAcceptor dataAcceptor, KeyType valueType)
DataAcceptor
instance for
use as an input data target.
This methods creates and configures the necessary handler itself.
keyDefinitionPredicate
- The predicate function that will determine whether to create an InputHandler
for the given key definition.dataAcceptor
- the DataAcceptor that serves as data sourcevalueType
- The type of the DataAcceptor valuespublic void addInputDataAcceptor(java.lang.String name, DataAcceptor dataAcceptor, KeyScope scope, DeserializationHandler deserializationCallback)
DataAcceptor
instance for
use as an input data target
for the actual deserialization.
This methods creates and configures the necessary handler itself.
name
- The name of the attributedataAcceptor
- the DataAcceptor that serves as data sourcescope
- The type of the DataAcceptor keysdeserializationCallback
- custom deserialization callback.public void addInputDataAcceptor(java.lang.String name, DataAcceptor dataAcceptor, KeyScope scope, KeyType valueType)
DataAcceptor
instance for
use as an input data target
for the actual deserialization.
This methods creates and configures the necessary handler itself.
name
- The name of the attributedataAcceptor
- the DataAcceptor that serves as data sourcescope
- The type of the DataAcceptor keysvalueType
- The type of the DataAcceptor valuespublic void addInputDataAcceptor(java.lang.String name, java.lang.Object dataProviderKey, KeyScope scope, KeyType valueType)
DataAcceptor
instance for
use as an input data target
for the actual deserialization.
This methods creates and configures the necessary handler
itself. It is expects that a DataAcceptor
instance is registered under the
key with Graph.addDataProvider(Object,y.base.DataProvider)
. This typically means that the instance is a
DataMap
, such as a NodeMap
or EdgeMap
.
name
- The name of the attributedataProviderKey
- the DataAcceptor that serves as data sourcescope
- The type of the DataAcceptor keysvalueType
- The type of the DataAcceptor valuespublic void addInputDataAcceptor(GraphMLHandler.InputHandlerQueryPredicate keyDefinitionPredicate, DataAcceptor dataAcceptor, DeserializationHandler deserializationCallback)
DataAcceptor
instance for
use as an input data target.
This method uses a DeserializationHandler
for the actual deserialization.
This methods creates and configures the necessary handler itself.
keyDefinitionPredicate
- The predicate function that will determine whether to create an InputHandler
for the given key definition.dataAcceptor
- the DataAcceptor that serves as data sourcedeserializationCallback
- custom deserialization callback.public Future addInputDataAcceptorFuture(java.lang.String name, KeyType valueType)
Future
instance that wraps an DataMap
for
use as an input data target.
The return value will only contain a value if a matching GraphML attribute has been read,
which can be queried with Future.hasValue
This methods creates and configures the necessary handler
itself.
name
- The name of the attributevalueType
- The type of the DataAcceptor values
Future
instance that wraps an DataMap
that actually holds the data.public Future addInputDataAcceptorFuture(java.lang.String name, KeyScope scope, KeyType valueType)
Future
instance that wraps an DataMap
for
use as an input data target.
The return value will only contain a value if a matching GraphML attribute has been read,
which can be queried with Future.hasValue
This methods creates and configures the necessary handler
itself.
name
- The name of the attribute.valueType
- The type of the DataAcceptor values.scope
- The scope of the attribute.
Future
instance that wraps an DataMap
that actually holds the data.public Future addInputDataAcceptorFuture(GraphMLHandler.InputHandlerQueryPredicate predicate, KeyType valueType)
Future
instance that wraps an DataMap
for
use as an input data target.
The return value will only contain a value if a matching GraphML attribute has been read,
which can be queried with Future.hasValue
This methods creates and configures the necessary handler
itself.
predicate
- The predicate that will determine whether to create an InputHandler
for the given key definition.valueType
- The type of the DataAcceptor values.
Future
instance that wraps an DataMap
that actually holds the data.public static boolean matchesName(org.w3c.dom.Element keyDefinition, java.lang.String name)
attr.name
attribute in a GraphML key definition matches
name
.
keyDefinition
- The key definition element to check.name
- The name to check.
true
iff the key definition contains a matching attr.name
attribute or if name
is null
.public static boolean matchesUri(org.w3c.dom.Element keyDefinition, java.lang.String uri)
attr.uri
attribute in a GraphML key definition matches
uri
.
keyDefinition
- The key definition element to check.uri
- The URI to check.
true
iff the key definition contains a matching attr.uri
attribute or if uri
is null
.public static boolean matchesType(org.w3c.dom.Element keyDefinition, KeyType type)
attr.type
attribute in a GraphML key definition matches
type
.
keyDefinition
- The key definition element to check.type
- The attribute type to check.
true
iff the key definition contains a matching attr.type
attribute.public static boolean matchesScope(org.w3c.dom.Element keyDefinition, KeyScope scope)
for
attribute in a GraphML key definition matches
scope
.
keyDefinition
- The key definition element to check.scope
- The attribute scope to check.
true
iff the key definition contains a matching for
attribute.public static KeyScope getKeyScope(org.w3c.dom.Element keyDefinition)
KeyScope
from an GraphML keyDefinition
element.
If no for
attribute is present, this method returns KeyScope.ALL
.
keyDefinition
- The GraphML key definition to parse.
KeyScope
from keyDefinition
.public static KeyType getKeyType(org.w3c.dom.Element keyDefinition)
KeyType
from an GraphML keyDefinition
element.
If no attr.type
attribute is present, this method returns KeyType.COMPLEX
.
keyDefinition
- The GraphML key definition to parse.
KeyType
from keyDefinition
.public static java.lang.String getKeyName(org.w3c.dom.Element keyDefinition)
keyDefinition
element.
If no attr.name
attribute is present, this method returns an empty string.
keyDefinition
- The GraphML key definition to parse.
keyDefinition
.public static java.lang.String getKeyUri(org.w3c.dom.Element keyDefinition)
keyDefinition
element.
If no attr.uri
attribute is present, this method returns an empty string.
keyDefinition
- The GraphML key definition to parse.
keyDefinition
.protected GraphElementFactory createGraphElementFactory(GraphMLParser parser, Graph graph)
GraphElementFactory
instance that creates the graph elements for the graph
instance.
parser
- The parser to use.graph
- The graph that is populated.
GraphElementFactory
instance that is configured for the given parameters.protected GraphMLParser createGraphMLParser(Graph graph)
GraphMLParser
that can handle the given graph.
Calls
configureGraphMLParser(y.base.Graph, y.io.graphml.input.GraphMLParser)
after creating a new GraphMLParser
instance.
graph
- The graph that should be filled by this instance
GraphMLParser
that can handle the given graphprotected void configureGraphMLParser(Graph graph, GraphMLParser parser)
GraphMLParser
to handle the given graph.
Called from createGraphMLParser(y.base.Graph)
.
graph
- The graph that should be filled by this instance.parser
- The parser to configure.protected void configureParseEvents(Graph graph, GraphMLParser parser)
parser
.
This implementation registers a single parse event handler that forwards to listeners registered with
addParseEventListener(y.io.graphml.input.ParseEventListener)
graph
- The graph that will be populated.parser
- The parser to configure.protected void configureLookup(Graph graph, GraphMLParser parser)
parser
.
This implementation does not configure any specific lookup implementations
graph
- The graph that will be populated.parser
- The parser to configure.GraphMLParser.setLookup(Class,Object)
protected void configureInputHandlers(Graph graph, GraphMLParser parser)
GraphMLParser.fireQueryInputHandlersEvent(y.io.graphml.input.QueryInputHandlersEvent)
event.
This implementation does not configure any input handlers.
parser
- The parser that should be configured.protected void configureDeserializationHandlers(Graph graph, GraphMLParser parser)
DeserializationEvent
event.
This implementation does not configure any serialization handlers.
graph
- The graph that will be parsed.parser
- The parser to configure.protected void configureDeserializationProperties(Graph graph, GraphMLParser parser)
GraphMLHandler
.
graph
- The graph to parse.parser
- The parser to configure.GraphMLParser.setDeserializationProperty(Object,Object)
public void setDeserializationProperty(java.lang.Object key, java.lang.Object value)
key
- The key for the property.value
- The value of the property.getDeserializationProperty(Object)
public void removeDeserializationProperty(java.lang.Object key)
setDeserializationProperty(Object, Object)
.
key
- The key for the property.setDeserializationProperty(Object, Object)
public java.lang.Object getDeserializationProperty(java.lang.Object key)
setDeserializationProperty(Object, Object)
.
key
- The key for the property.
setDeserializationProperty(Object, Object)
public void addInputHandlerProvider(InputHandlerProvider provider)
QueryInputHandlersEvent
s.
Registering a listener allows to use InputHandler
s dynamically, depending on the
actual input. For each key definition, a QueryInputHandlersEvent
is fired and
propagated to all registered event listeners.
provider
- Event listener for the QueryInputHandlersEvent
fireQueryInputHandlersProviders(QueryInputHandlersEvent)
,
removeInputHandlerProvider(InputHandlerProvider)
,
GraphMLParser.addInputHandlerProvider(InputHandlerProvider)
public void removeInputHandlerProvider(InputHandlerProvider provider)
addInputHandlerProvider(InputHandlerProvider)
.
provider
- Event listener for the QueryInputHandlersEvent
fireQueryInputHandlersProviders(QueryInputHandlersEvent)
,
addInputHandlerProvider(InputHandlerProvider)
,
GraphMLParser.removeInputHandlerProvider(InputHandlerProvider)
protected void fireQueryInputHandlersProviders(QueryInputHandlersEvent event) throws GraphMLParseException
InputHandlerProvider
instances of event
.
For each graphml key definition, a QueryInputHandlersEvent
is fired and
propagated to all registered event listeners.
event
- The event that has been raised.
GraphMLParseException
InputHandler
,
InputHandlerProvider
,
addInputHandlerProvider(InputHandlerProvider)
,
GraphMLParser.fireQueryInputHandlersEvent(QueryInputHandlersEvent)
protected void onGraphMLParserQueryInputHandlers(QueryInputHandlersEvent e) throws GraphMLParseException
GraphMLParser.addInputHandlerProvider(y.io.graphml.input.InputHandlerProvider)
.
This implementation just propagates the event e
to all registered event handlers by calling
fireQueryInputHandlersProviders(y.io.graphml.input.QueryInputHandlersEvent)
.
e
- The event data.
GraphMLParseException
public void addDeserializationHandler(DeserializationHandler listener)
DeserializationEvent
s.
Registering a listener allows to use custom deserialization code.
listener
- Event listener for the DeserializationEvent
fireDeserializationEvent(DeserializationEvent)
,
removeDeserializationHandler(DeserializationHandler)
,
GraphMLParser.addDeserializationHandler(DeserializationHandler)
public void removeDeserializationHandler(DeserializationHandler listener)
addDeserializationHandler(DeserializationHandler)
.
listener
- Event listener for the DeserializationEvent
fireDeserializationEvent(DeserializationEvent)
,
addDeserializationHandler(DeserializationHandler)
,
GraphMLParser.removeDeserializationHandler(DeserializationHandler)
protected void fireDeserializationEvent(DeserializationEvent event) throws GraphMLParseException
DeserializationHandler
instances of event
.
Usually, this method is called indirectly through calls to GraphMLParseContext.deserialize(GraphMLParseContext,Node,Class)
to parse Xml content to an object.
event
- The event that has been raised.
GraphMLParseException
DeserializationHandler
,
addDeserializationHandler(DeserializationHandler)
,
GraphMLParseContext.deserialize(GraphMLParseContext,Node,Class)
,
GraphMLParser.fireDeserializationEvent(DeserializationEvent)
protected void onGraphMLParserHandleDeserialization(DeserializationEvent e) throws GraphMLParseException
GraphMLParser.addDeserializationHandler(y.io.graphml.input.DeserializationHandler)
.
This implementation just propagates the event e
to all registered event handlers by calling
fireDeserializationEvent(y.io.graphml.input.DeserializationEvent)
.
e
- The event data.
GraphMLParseException
public void addParseEventListener(ParseEventListener listener)
ParseEventListener
.
listener
- The listener to add.removeParseEventListener(ParseEventListener)
public void removeParseEventListener(ParseEventListener listener)
ParseEventListener
that
has been registered with addParseEventListener(ParseEventListener)
listener
- The listener to remove.addParseEventListener(ParseEventListener)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |