|
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 DeserializationEvents. |
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(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(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(String name,
DataAcceptor dataAcceptor,
KeyType valueType)
Register a DataAcceptor instance for
use as an input data target. |
void |
addInputDataAcceptor(String name,
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(String name,
KeyScope scope,
KeyType valueType)
Create a Future instance that wraps an DataMap for
use as an input data target. |
Future |
addInputDataAcceptorFuture(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 QueryInputHandlersEvents. |
void |
addNamespace(String namespaceURI,
String shortName)
Adds a namespace declaration to the header of a GraphML file. |
void |
addOutputDataProvider(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(String name,
DataProvider dataProvider,
KeyScope scope,
SerializationHandler serializationCallback)
Register a DataProvider instance for
use as an output data source. |
void |
addOutputDataProvider(String name,
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(String name,
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 QueryOutputHandlersEvents. |
void |
addParseEventListener(ParseEventListener listener)
Register a ParseEventListener. |
void |
addRegisteredOutputDataProvider(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(String name,
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(String name,
String uri,
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(String schemaNamespace,
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 SerializationEvents. |
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(OutputStream os,
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(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. |
Object |
getDeserializationProperty(Object key)
Retrieves a deserialization property that has been set using setDeserializationProperty(Object, Object). |
static String |
getKeyName(Element keyDefinition)
Get the attribute name from an GraphML keyDefinition element. |
static KeyScope |
getKeyScope(Element keyDefinition)
Get the KeyScope from an GraphML keyDefinition element. |
static KeyType |
getKeyType(Element keyDefinition)
Get the KeyType from an GraphML keyDefinition element. |
static String |
getKeyUri(Element keyDefinition)
Get the attribute URI from an GraphML keyDefinition element. |
Object |
getSerializationProperty(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(Element keyDefinition,
String name)
Utility method that checks whether the attr.name attribute in a GraphML key definition matches
name. |
static boolean |
matchesScope(Element keyDefinition,
KeyScope scope)
Utility method that checks whether the for attribute in a GraphML key definition matches
scope. |
static boolean |
matchesType(Element keyDefinition,
KeyType type)
Utility method that checks whether the attr.type attribute in a GraphML key definition matches
type. |
static boolean |
matchesUri(Element keyDefinition,
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,
Document doc)
Read GraphML from an existing XML document. |
void |
read(Graph graph,
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(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(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(Object key,
Object value)
Sets a deserialization property that allows to fine tune the parse process. |
void |
setSerializationProperty(Object key,
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,
OutputStream os)
Writes the given graph Object to the output stream creating a GraphML file. |
void |
write(Graph graph,
OutputStream os,
String encoding)
Writes the given graph Object to the output stream creating a GraphML file. |
void |
write(Graph graph,
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(String namespaceURI,
String shortName)
namespaceURI - The namespace URIshortName - The namespace prefix
public void addSchemaLocation(String schemaNamespace,
String schemaLocation)
schemaNamespace - The namespace URI for this schema locationschemaLocation - The schema locationsetWriteXMLSchema(boolean),
isWriteXMLSchema()
public void write(Graph graph,
OutputStream os)
throws GraphMLWriteException
This method just calls write(y.base.Graph,java.io.OutputStream,String) with
the default "UTF-8" encoding.
IllegalArgumentException - if graph or os
is null.
GraphMLWriteExceptiongraph - The Graph Object that is to be written to a GraphML file.os - The output stream where the output is written.
public void write(Graph graph,
OutputStream os,
String encoding)
throws GraphMLWriteException
IllegalArgumentException - if graph or os
is null.
GraphMLWriteExceptiongraph - 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
public void write(Graph graph,
Writer os)
throws GraphMLWriteException
IllegalArgumentException - if graph or os
is null.
GraphMLWriteExceptiongraph - The Graph Object that is to be written to a GraphML file.os - The writer where the output is written.
public void addOutputDataProvider(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 DataProvider
public void addOutputDataProvider(String name,
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 DataProvider
public void addOutputDataProvider(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(String name,
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(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(String name,
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(String name,
String uri,
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(Object key,
Object value)
key - The key for the property.value - The value of the property.getSerializationProperty(Object)public void removeSerializationProperty(Object key)
setDeserializationProperty(Object, Object).
key - The key for the property.setSerializationProperty(Object, Object)public Object getSerializationProperty(Object key)
setSerializationProperty(Object, Object).
key - The key for the property.
setSerializationProperty(Object, Object)
protected XmlWriter createXMLWriter(Writer writer)
throws GraphMLWriteException
XmlWriter implementation that
can write the graph to the given Writer with the given settings
GraphMLWriteExceptionwriter - The serialization destination
XmlWriter instance for the serialization
protected XmlWriter createXMLWriter(OutputStream os,
String encoding)
throws GraphMLWriteException
XmlWriter implementation that
can write the graph to the given OutputStream with the given settings.
GraphMLWriteExceptionos - The serialization destinationencoding - The encoding of the stream
XmlWriter instance for the serializationprotected 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 and the yFile for Java
extensions 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)
QueryOutputHandlersEvents.
Registering a listener allows to use OutputHandlers 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 QueryInputHandlersEventfireQueryOutputHandlersEvent(QueryOutputHandlersEvent),
removeOutputHandlerProvider(OutputHandlerProvider),
GraphMLWriter.addOutputHandlerProvider(OutputHandlerProvider)public void removeOutputHandlerProvider(OutputHandlerProvider provider)
addOutputHandlerProvider(OutputHandlerProvider).
provider - Event listener for the QueryOutputHandlersEventfireQueryOutputHandlersEvent(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.
GraphMLWriteExceptionevent - The event that has been raised.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).
GraphMLWriteExceptione - The event data.public void addSerializationHandler(SerializationHandler listener)
SerializationEvents.
Registering a listener allows to use custom serialization code.
listener - Event listener for the SerializationEventfireSerializationEvent(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 SerializationEventfireSerializationEvent(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.
GraphMLWriteExceptionevent - The event that has been raised.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).
GraphMLWriteExceptione - The event data.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,
InputStream stream)
throws GraphMLParseException
IllegalArgumentException - stream or graph are null.
GraphMLParseExceptiongraph - The Graph Object that is to be populated from the stream.stream - The input stream that holds the GraphML file to be read.
public void read(Graph graph,
Document doc)
throws GraphMLParseException
IllegalArgumentException - if doc or graph are null.
GraphMLParseExceptiongraph - The Graph Object that is to be populated from the document.doc - The XML document.
public void addInputDataAcceptor(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 target
public 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 values
public void addInputDataAcceptor(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(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 values
public void addInputDataAcceptor(String name,
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 values
public 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(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(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(Element keyDefinition,
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(Element keyDefinition,
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(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(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(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(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 String getKeyName(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 String getKeyUri(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 graph
protected 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(Object key,
Object value)
key - The key for the property.value - The value of the property.getDeserializationProperty(Object)public void removeDeserializationProperty(Object key)
setDeserializationProperty(Object, Object).
key - The key for the property.setDeserializationProperty(Object, Object)public Object getDeserializationProperty(Object key)
setDeserializationProperty(Object, Object).
key - The key for the property.
setDeserializationProperty(Object, Object)public void addInputHandlerProvider(InputHandlerProvider provider)
QueryInputHandlersEvents.
Registering a listener allows to use InputHandlers 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 QueryInputHandlersEventfireQueryInputHandlersProviders(QueryInputHandlersEvent),
removeInputHandlerProvider(InputHandlerProvider),
GraphMLParser.addInputHandlerProvider(InputHandlerProvider)public void removeInputHandlerProvider(InputHandlerProvider provider)
addInputHandlerProvider(InputHandlerProvider).
provider - Event listener for the QueryInputHandlersEventfireQueryInputHandlersProviders(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.
GraphMLParseExceptionevent - The event that has been raised.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).
GraphMLParseExceptione - The event data.public void addDeserializationHandler(DeserializationHandler listener)
DeserializationEvents.
Registering a listener allows to use custom deserialization code.
listener - Event listener for the DeserializationEventfireDeserializationEvent(DeserializationEvent),
removeDeserializationHandler(DeserializationHandler),
GraphMLParser.addDeserializationHandler(DeserializationHandler)public void removeDeserializationHandler(DeserializationHandler listener)
addDeserializationHandler(DeserializationHandler).
listener - Event listener for the DeserializationEventfireDeserializationEvent(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.
GraphMLParseExceptionevent - The event that has been raised.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).
GraphMLParseExceptione - The event data.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-2013, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||