public class GraphMLIOHandler extends Object
For more information about the GraphML file format please refer to the GraphML Primer.
Constructor and Description |
---|
GraphMLIOHandler()
Creates a new instance of
GraphMLIOHandler . |
Modifier and Type | Method and Description |
---|---|
void |
addHandleDeserializationListener(IEventHandler<HandleDeserializationEventArgs> handleDeserializationEvent)
Adds the given listener for the
HandleDeserialization event that occurs when XML content is about to be
deserialized. |
void |
addHandleSerializationListener(IEventHandler<HandleSerializationEventArgs> handleSerializationEvent)
Adds the given listener for the
HandleSerialization event that occurs when XML content is about to be
serialized. |
Future<IInputHandler> |
addInputHandlerFactory(Predicate<Element> keyDefinitionPredicate,
IGenericInputHandlerFactory factory)
|
<TKey,TData> |
addInputMapper(Class<TKey> keyType,
Class<TData> dataType,
Predicate<Element> keyDefinitionPredicate,
IMapper<TKey,TData> mapper,
IEventHandler<HandleDeserializationEventArgs> deserializationCallback)
Register a
IMapper instance for use as an input data target. |
<TKey,TData> |
addInputMapper(Class<TKey> keyType,
Class<TData> dataType,
String name,
IMapper<TKey,TData> mapper)
Register a
IMapper instance for use as an input data target. |
<TKey,TData> |
addInputMapperFuture(Class<TKey> keyType,
Class<TData> dataType,
Predicate<Element> keyDefinitionPredicate,
IEventHandler<HandleDeserializationEventArgs> deserializationCallback)
|
<TKey,TData> |
addInputMapperFuture(Class<TKey> keyType,
Class<TData> dataType,
String name)
|
void |
addNamespace(String namespaceURI,
String shortName)
Adds a namespace to the header of a GraphML file.
|
void |
addNamespaceMapping(String xmlNamespace,
Class type)
Adds a mapping for a
xmlNamespace to the package of the given type . |
void |
addNamespaceMapping(String xmlNamespace,
String namespacePrefix,
Class type)
Adds a mapping for a
xmlNamespace with a custom prefix to the package of the given type . |
void |
addNamespaceMapping(String xmlNamespace,
String packageName,
ClassLoader classLoader)
Adds a mapping for a
xmlNamespace to a packageName and its classLoader . |
void |
addNamespaceMapping(String xmlNamespace,
String namespacePrefix,
String packageName,
ClassLoader classLoader)
Adds a mapping for a
xmlNamespace with a custom prefix to a packageName and its classLoader . |
<TModelItem,TValue> |
addOutputMapper(Class<TModelItem> modelItemType,
Class<TValue> valueType,
String name,
IMapper<TModelItem,TValue> mapper)
Register a
IMapper instance for use as an output data source. |
<TModelItem,TValue> |
addOutputMapper(Class<TModelItem> modelItemType,
Class<TValue> valueType,
String name,
String uri,
IMapper<TModelItem,TValue> mapper,
IEventHandler<HandleSerializationEventArgs> serializationCallback,
KeyType declaredKeyType)
Register a
IMapper instance for use as an output data source. |
void |
addOverrideResolveReferenceListener(IEventHandler<ResolveReferenceEventArgs> overrideResolveReferenceEvent)
Adds the given listener for the
OverrideResolveReference event that occurs before inline references are
evaluated. |
void |
addParsedListener(IEventHandler<ParseEventArgs> parsedEvent)
Adds the given listener for the
Parsed event that occurs when the the document has been parsed. |
void |
addParsingListener(IEventHandler<ParseEventArgs> parsingEvent)
Adds the given listener for the
Parsing event that occurs when the parsing of a document is just about to
begin. |
void |
addQueryInputHandlersListener(IEventHandler<QueryInputHandlersEventArgs> queryInputHandlersEvent)
Adds the given listener for the
QueryInputHandlers event that occurs when a GraphML attribute is about to be
read. |
void |
addQueryOutputHandlersListener(IEventHandler<QueryOutputHandlersEventArgs> queryOutputHandlersEvent)
Adds the given listener for the
QueryOutputHandlers event that occurs when a GraphML attribute is about to be
written. |
void |
addQueryReferenceIdListener(IEventHandler<QueryReferenceIdEventArgs> queryReferenceIdEvent)
Adds the given listener for the
QueryReferenceId event that occurs when a reference is queried. |
<TKey,TData> |
addRegistryInputMapper(Class<TKey> keyType,
Class<TData> dataType,
Object tag,
Predicate<Element> keyDefinitionPredicate,
IEventHandler<HandleDeserializationEventArgs> deserializationCallback)
Create a
Future instance that wraps an IInputHandler that stores the data in an IMapper that
will be created in the graph's IMapperRegistry . |
<TKey,TData> |
addRegistryInputMapper(Class<TKey> keyType,
Class<TData> dataType,
String name)
Create a
Future instance that wraps an IInputHandler that stores the data in an IMapper that
will be created in the graph's IMapperRegistry . |
<TModelItem,TValue> |
addRegistryOutputMapper(Class<TModelItem> modelItemType,
Class<TValue> valueType,
String name,
Object tag)
Use a registered
IMapper instance as source for the given GraphML attribute. |
<TModelItem,TValue> |
addRegistryOutputMapper(Class<TModelItem> modelItemType,
Class<TValue> valueType,
String name,
String uri,
Object tag,
IEventHandler<HandleSerializationEventArgs> serializationCallback,
KeyType declaredKeyType)
Use a registered
IMapper instance as source for the given GraphML attribute. |
void |
addRegistryOutputMapper(String name,
Object tag)
Use a registered
IMapper instance as source for the given GraphML attribute. |
void |
addRegistryOutputMapper(String name,
String uri,
Object tag,
IEventHandler<HandleSerializationEventArgs> serializationCallback)
Use a registered
IMapper instance as source for the given GraphML attribute. |
void |
addResolveReferenceListener(IEventHandler<ResolveReferenceEventArgs> resolveReferenceEvent)
Adds the given listener for the
ResolveReference event that occurs after references are evaluated. |
void |
addSchemaLocation(String schemaNamespace,
String schemaLocation)
Adds a schema location to the header of a GraphML file.
|
void |
addWritingListener(IEventHandler<WriteEventArgs> writingEvent)
Adds the given listener for the
Writing event that occurs when the writing of a document is just about to
begin. |
void |
addWrittenListener(IEventHandler<WriteEventArgs> writtenEvent)
Adds the given listener for the
Written event that occurs when the writing of a document has been finished. |
protected void |
configureDeserializationHandlers(IGraph graph,
GraphMLParser parser)
Configure the predefined handlers for the
HandleDeserialization
event. |
protected void |
configureDeserializationPropertyOverrides(GraphMLParser parser)
Configures the
deserialization property overrides for the given parser. |
protected void |
configureGraphMLParser(GraphMLParser parser,
IGraph graph)
Configures a given instance of
GraphMLParser that can handle the given graph. |
protected void |
configureGraphMLWriter(GraphMLWriter writer,
IGraph graph)
Configures a given
GraphMLWriter that is used for writing graph . |
protected void |
configureInputHandlers(GraphMLParser parser)
Configures default event handlers for the
QueryInputHandlers
event. |
protected void |
configureLookup(GraphMLParser parser)
Configures the lookup of the given parser.
|
protected void |
configureLookup(IGraph graph,
GraphMLWriter writer)
Configure the lookup map of
writer . |
protected void |
configureNamespaces(GraphMLWriter writer)
Configures
writer to use the namespace declarations set with addNamespace(String, String) . |
protected void |
configureOutputHandlers(IGraph graph,
GraphMLWriter writer)
Configures default event handlers for the
QueryOutputHandlers
event. |
protected void |
configureSchemaLocations(GraphMLWriter writer)
Configures
writer to use the schema locations set with addSchemaLocation(String, String) . |
protected void |
configureSerializationHandlers(IGraph graph,
GraphMLWriter writer)
Configures the predefined handlers for the
HandleSerialization
event. |
protected void |
configureSerializationProperties(IGraph graph,
GraphMLWriter writer)
Configure important serialization properties from properties of
GraphMLIOHandler . |
protected void |
configureSerializationPropertyOverrides(GraphMLWriter writer)
Configures the
serialization property overrides for the given writer. |
protected void |
configureXMLWriter(IXmlWriter writer)
Configure
writer . |
protected IValueSerializerContext |
createDefaultValueSerializerContext()
Creates the default value serializer context and returns it.
|
protected IGraphElementFactory |
createGraphElementFactory(GraphMLParser parser,
IGraph graph)
Create an
IGraphElementFactory instance that creates the graph elements for the graph instance. |
protected GraphMLParser |
createGraphMLParser(IGraph graph)
Create a suitable instance of
GraphMLParser that can handle the given graph. |
protected GraphMLWriter |
createGraphMLWriter(IGraph graph)
Create and configure a new
GraphMLWriter that is used for writing graph . |
protected <TKey,TData> |
createMapper(Class<TKey> keyType,
Class<TData> dataType,
IParseContext context,
Object registryTag)
Callback used by
addRegistryInputMapper(Class, Class, String) and its overloads to creates the mapper
instance. |
static <TKey,TData> |
createMapperInputHandler(Class<TKey> modelItemType,
Class<TData> dataType,
IMapper<TKey,TData> mapper,
IEventHandler<HandleDeserializationEventArgs> deserializationCallback)
Convenience factory method that can create an instance of several predefined
IInputHandler implementations that
match the provided TKey and TData . |
static <TKey,TData> |
createMapperOutputHandler(Class<TKey> modelItemType,
Class<TData> dataType,
String name,
IMapper<TKey,TData> mapper,
IEventHandler<HandleSerializationEventArgs> serializationCallback)
Convenience factory method that can create an instance of several predefined
IOutputHandler implementations that
match the provided TKey and TData . |
protected IXamlNameMapper |
createXamlNameMapper()
Configure mappings from package to XML names.
|
protected IXamlPrefixMapper |
createXamlPrefixMapper()
Configure mappings from XML namespaces to prefixes.
|
protected IXmlWriter |
createXMLWriter(OutputStream os,
Charset encoding)
Factory method that creates and configures a suitable
IXmlWriter implementation that can write the graph to the
given InputStream with the given settings. |
protected IXmlWriter |
createXMLWriter(Writer os)
Factory method that creates and configures a suitable
IXmlWriter implementation that can write the graph to the
given Writer with the given settings. |
TypedKeyMapper |
getDeserializationPropertyOverrides()
Gets the mapper for the overrides of the deserialization properties.
|
TypedKeyMapper |
getSerializationPropertyOverrides()
Gets the mapper for the overrides of the serialization properties.
|
protected void |
handleArraySerialization(Object sender,
HandleSerializationEventArgs e)
Handle the serialization of arrays.
|
protected void |
handleListSerialization(Object sender,
HandleSerializationEventArgs e)
Handle the serialization of
Iterable instances. |
protected void |
handleMarkupExtensionBasedSerialization(Object sender,
HandleSerializationEventArgs e)
Handle the serialization of
MarkupExtension convertible instances. |
protected void |
handleNullSerialization(Object sender,
HandleSerializationEventArgs e)
Handle the serialization of
null references. |
protected void |
handlePrimitivesDeserialization(Object sender,
HandleDeserializationEventArgs e)
Handle the serialization of primitive types, enums and strings.
|
protected void |
handleReferenceHandleSerialization(Object sender,
HandleSerializationEventArgs e)
Handle the serialization of
IReferenceHandle instances. |
protected void |
handleTextConvertibleSerialization(Object sender,
HandleSerializationEventArgs e)
Handle the serialization of instances that can be serialized through a
ValueSerializer . |
protected void |
handleTextNodeDeserialization(Object source,
HandleDeserializationEventArgs args)
Callback for the
HandleDeserialization event. |
protected void |
handleTypeExtensionSerialization(Object sender,
HandleSerializationEventArgs e)
Handle the serialization of TypeExtensions.
|
protected void |
handleTypeSerialization(Object sender,
HandleSerializationEventArgs e)
Handle the serialization of Types.
|
protected void |
handleXamlDeserialization(Object source,
HandleDeserializationEventArgs args)
Callback for the
HandleDeserialization event. |
protected void |
handleXamlSerialization(Object sender,
HandleSerializationEventArgs e)
Handle the serialization of complex objects that are not handled by other callbacks.
|
boolean |
isClearingGraphBeforeReadEnabled()
Whether to clear an existing graph instance before reading.
|
boolean |
isWritingSharedReferencesEnabled()
Whether to support object sharing on output.
|
boolean |
isWritingXMLSchemaEnabled()
true if schema descriptions should be written. |
static boolean |
matchesName(Element definition,
String name)
Checks whether the
name attribute in definition matches name . |
static boolean |
matchesScope(Element definition,
KeyScope scope)
Checks whether the
scope attribute in definition matches scope . |
static boolean |
matchesType(Element definition,
KeyType type)
Checks whether the
type attribute in definition matches type . |
static boolean |
matchesUri(Element definition,
String uri)
Checks whether the
uri attribute in definition matches uri . |
protected void |
onGraphMLParserHandleDeserialization(Object sender,
HandleDeserializationEventArgs e)
Event handler for the
HandleDeserialization
event. |
protected void |
onGraphMLParserQueryInputHandlers(Object sender,
QueryInputHandlersEventArgs e)
Event handler for the
QueryInputHandlers event. |
protected void |
onGraphMLWriterHandleSerialization(Object sender,
HandleSerializationEventArgs e)
Event handler for the
HandleSerialization event. |
protected void |
onGraphMLWriterQueryOutputHandlers(Object sender,
QueryOutputHandlersEventArgs e)
Event handler for the
QueryOutputHandlers event. |
protected void |
onHandleDeserialization(HandleDeserializationEventArgs args)
Raises the
HandleDeserialization event. |
protected void |
onHandleSerialization(HandleSerializationEventArgs args)
Raises the
HandleSerialization event. |
protected void |
onOverrideResolveReference(ResolveReferenceEventArgs args)
Fires the
OverrideResolveReference event. |
protected void |
onParsed(ParseEventArgs args)
Raises the
Parsed event. |
protected void |
onParsing(ParseEventArgs args)
Raises the
Parsing event. |
protected void |
onQueryInputHandlers(QueryInputHandlersEventArgs args)
Raises the
QueryInputHandlers event. |
protected void |
onQueryOutputHandlers(QueryOutputHandlersEventArgs args)
Raises the
QueryOutputHandlers event. |
protected void |
onQueryReferenceId(QueryReferenceIdEventArgs args)
Fires the
QueryReferenceId event. |
protected void |
onResolveReference(ResolveReferenceEventArgs args)
Fires the
ResolveReference event. |
protected void |
onWriting(WriteEventArgs args)
Raises the
Writing event. |
protected void |
onWritten(WriteEventArgs args)
Raises the
Written event. |
void |
read(IGraph graph,
Document document)
Read GraphML from an existing XML document.
|
void |
read(IGraph graph,
InputStream stream)
Reads GraphML content from the given input stream and populates the Graph object.
|
void |
read(IGraph graph,
InputStream stream,
URI baseUri)
Reads GraphML content from the given input stream and populates the Graph
object.
|
void |
read(IGraph graph,
Reader reader)
Reads GraphML content from the given reader and populates the Graph object.
|
void |
read(IGraph graph,
Reader reader,
URI baseUri)
Reads GraphML content from the given reader and populates the Graph
object.
|
void |
read(IGraph graph,
String filename)
Reads a GraphML file from the given GraphML file and populates the
IGraph object. |
void |
read(IGraph graph,
URL url)
Reads a GraphML file from the given url inside the applications xap file and populates the Graph
object.
|
protected void |
registerEdgeBendsInputHandler(Object sender,
QueryInputHandlersEventArgs e)
Predefined input handler that reads edge bends.
|
protected void |
registerEdgeBendsOutputHandler(Object sender,
QueryOutputHandlersEventArgs e)
Predefined output handler that writes edge bends.
|
protected void |
registerEdgeLabelsInputHandler(Object sender,
QueryInputHandlersEventArgs e)
Predefined input handler that reads edge labels.
|
protected void |
registerEdgeLabelsOutputHandler(Object sender,
QueryOutputHandlersEventArgs e)
Predefined output handler that writes edge labels.
|
protected void |
registerEdgeStyleInputHandler(Object sender,
QueryInputHandlersEventArgs e)
Predefined input handler that reads edge styles.
|
protected void |
registerEdgeStyleOutputHandler(Object sender,
QueryOutputHandlersEventArgs e)
Predefined output handler that writes edge styles.
|
protected void |
registerGraphSettingsInputHandler(Object sender,
QueryInputHandlersEventArgs e)
Predefined input handler that reads
IGraph graph default settings. |
protected void |
registerGraphSettingsOutputHandler(Object sender,
QueryOutputHandlersEventArgs e)
Predefined output handler that writes the settings of a graph.
|
protected void |
registerNodeLabelsInputHandler(Object sender,
QueryInputHandlersEventArgs e)
Predefined input handler that reads node labels.
|
protected void |
registerNodeLabelsOutputHandler(Object sender,
QueryOutputHandlersEventArgs e)
Predefined output handler that writes node labels.
|
protected void |
registerNodeLayoutInputHandler(Object sender,
QueryInputHandlersEventArgs e)
Predefined input handler that reads node layouts.
|
protected void |
registerNodeLayoutOutputHandler(Object sender,
QueryOutputHandlersEventArgs e)
Predefined output handler that writes node layouts.
|
protected void |
registerNodeStyleInputHandler(Object sender,
QueryInputHandlersEventArgs e)
Predefined input handler that reads node styles.
|
protected void |
registerNodeStyleOutputHandler(Object sender,
QueryOutputHandlersEventArgs e)
Predefined output handler that writes node styles.
|
protected void |
registerPortLocationInputHandler(Object sender,
QueryInputHandlersEventArgs e)
Predefined input handler that reads port locations.
|
protected void |
registerPortLocationOutputHandler(Object sender,
QueryOutputHandlersEventArgs e)
Predefined output handler that writes port locations.
|
protected void |
registerPortStyleInputHandler(Object sender,
QueryInputHandlersEventArgs e)
Predefined input handler that reads port styles.
|
protected void |
registerPortStyleOutputHandler(Object sender,
QueryOutputHandlersEventArgs e)
Predefined output handler that writes port styles.
|
protected void |
registerTagInputHandler(Object sender,
QueryInputHandlersEventArgs e)
Predefined input handler that reads
ITagOwner tags. |
protected void |
registerTagOutputHandler(Object sender,
QueryOutputHandlersEventArgs e)
Predefined output handler that writes
ITagOwner tags. |
void |
removeHandleDeserializationListener(IEventHandler<HandleDeserializationEventArgs> handleDeserializationEvent)
Removes the given listener for the
HandleDeserialization event that occurs when XML content is about to be
deserialized. |
void |
removeHandleSerializationListener(IEventHandler<HandleSerializationEventArgs> handleSerializationEvent)
Removes the given listener for the
HandleSerialization event that occurs when XML content is about to be
serialized. |
void |
removeOverrideResolveReferenceListener(IEventHandler<ResolveReferenceEventArgs> overrideResolveReferenceEvent)
Removes the given listener for the
OverrideResolveReference event that occurs before inline references are
evaluated. |
void |
removeParsedListener(IEventHandler<ParseEventArgs> parsedEvent)
Removes the given listener for the
Parsed event that occurs when the the document has been parsed. |
void |
removeParsingListener(IEventHandler<ParseEventArgs> parsingEvent)
Removes the given listener for the
Parsing event that occurs when the parsing of a document is just about to
begin. |
void |
removeQueryInputHandlersListener(IEventHandler<QueryInputHandlersEventArgs> queryInputHandlersEvent)
Removes the given listener for the
QueryInputHandlers event that occurs when a GraphML attribute is about to be
read. |
void |
removeQueryOutputHandlersListener(IEventHandler<QueryOutputHandlersEventArgs> queryOutputHandlersEvent)
Removes the given listener for the
QueryOutputHandlers event that occurs when a GraphML attribute is about to be
written. |
void |
removeQueryReferenceIdListener(IEventHandler<QueryReferenceIdEventArgs> queryReferenceIdEvent)
Removes the given listener for the
QueryReferenceId event that occurs when a reference is queried. |
void |
removeResolveReferenceListener(IEventHandler<ResolveReferenceEventArgs> resolveReferenceEvent)
Removes the given listener for the
ResolveReference event that occurs after references are evaluated. |
void |
removeWritingListener(IEventHandler<WriteEventArgs> writingEvent)
Removes the given listener for the
Writing event that occurs when the writing of a document is just about to
begin. |
void |
removeWrittenListener(IEventHandler<WriteEventArgs> writtenEvent)
Removes the given listener for the
Written event that occurs when the writing of a document has been finished. |
void |
setClearingGraphBeforeReadEnabled(boolean value)
Whether to clear an existing graph instance before reading.
|
void |
setWritingSharedReferencesEnabled(boolean value)
Whether to support object sharing on output.
|
void |
setWritingXMLSchemaEnabled(boolean value)
true if schema descriptions should be written. |
void |
write(IGraph graph,
OutputStream os)
Writes the given graph object to the output stream creating a GraphML file.
|
void |
write(IGraph graph,
OutputStream os,
Charset encoding)
Writes the given graph object to the output stream creating a GraphML file.
|
void |
write(IGraph graph,
String filename)
Writes the given graph object to a GraphML file with a given filename.
|
void |
write(IGraph graph,
Writer os)
Writes the given graph object to the output writer creating a GraphML file.
|
public GraphMLIOHandler()
GraphMLIOHandler
.public final void addHandleDeserializationListener(IEventHandler<HandleDeserializationEventArgs> handleDeserializationEvent)
HandleDeserialization
event that occurs when XML content is about to be
deserialized.
Subscribe to this event to provide custom deserialization handling for XML content.
The event handlers added to this event are called in inverse order, i.e. handlers that have been added later are called earlier.
The current XML content is provided by XmlNode
. If you want to
return deserialized content, set the value of the Result
property.
handleDeserializationEvent
- The listener to add.GraphMLParser.addHandleDeserializationListener(IEventHandler)
,
removeHandleDeserializationListener(IEventHandler)
public final void addHandleSerializationListener(IEventHandler<HandleSerializationEventArgs> handleSerializationEvent)
HandleSerialization
event that occurs when XML content is about to be
serialized.
Subscribe to this event to provide custom serialization handling for XML content.
The event handlers added to this event are called in inverse order, i.e. handlers that have been added later are called earlier.
The current item is provided by Item
.
handleSerializationEvent
- The listener to add.removeHandleSerializationListener(IEventHandler)
public final Future<IInputHandler> addInputHandlerFactory(Predicate<Element> keyDefinitionPredicate, IGenericInputHandlerFactory factory)
Future
instance that wraps an IInputHandler
that is dynamically created by factory
.
The return value will only contain a value if a matching GraphML attribute has been read, which can be queried with
HasValue
. The validity is determined by
keyDefinitionPredicate
. This methods creates and configures the necessary handler itself.
keyDefinitionPredicate
- The predicate that matches the key definition.factory
- A factory to create IInputHandler
instances.Future
instance that wraps an IInputHandler
that actually parses the data.public final <TKey,TData> void addInputMapper(Class<TKey> keyType, Class<TData> dataType, Predicate<Element> keyDefinitionPredicate, IMapper<TKey,TData> mapper, IEventHandler<HandleDeserializationEventArgs> deserializationCallback)
IMapper
instance for use as an input data target.
This method uses a custom IEventHandler
for the actual deserialization.
This methods creates and configures the necessary handler itself.
TKey
- The type of the mapper keysTData
- The type of the mapper valuesdataType
- The type of the mapper valueskeyType
- The type of the mapper keyskeyDefinitionPredicate
- The predicate function that will determine whether to create an IInputHandler
for the given key definition.mapper
- the mapper that serves as data sourcedeserializationCallback
- custom deserialization callback.public final <TKey,TData> void addInputMapper(Class<TKey> keyType, Class<TData> dataType, String name, IMapper<TKey,TData> mapper)
IMapper
instance for use as an input data target.
This methods creates and configures the necessary handler itself.
TKey
- The type of the mapper keysTData
- The type of the mapper valuesdataType
- The type of the mapper valueskeyType
- The type of the mapper keysname
- The name of the attributemapper
- the mapper that serves as data sourcepublic final <TKey,TData> Future<IMapper<TKey,TData>> addInputMapperFuture(Class<TKey> keyType, Class<TData> dataType, Predicate<Element> keyDefinitionPredicate, IEventHandler<HandleDeserializationEventArgs> deserializationCallback)
Future
instance that wraps an IMapper
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 HasValue
This methods creates and configures the necessary handler itself.
TKey
- The type of the mapper keysTData
- The type of the mapper valuesdataType
- The type of the mapper valueskeyType
- The type of the mapper keysdeserializationCallback
- custom deserialization callback.keyDefinitionPredicate
- The predicate function that will determine whether to create an IInputHandler
for the given key definition.Future
instance that wraps an IMapper
that actually holds the data.public final <TKey,TData> Future<IMapper<TKey,TData>> addInputMapperFuture(Class<TKey> keyType, Class<TData> dataType, String name)
public void addNamespace(String namespaceURI, String shortName)
namespaceURI
- The namespace URIshortName
- The namespace prefixpublic void addNamespaceMapping(String xmlNamespace, Class type)
xmlNamespace
to the package of the given type
.
The mapping is added to the createXamlNameMapper()
IXamlNameMapper} to determining type
information from XML elements and
to lookup the xmlNamespace
that should be used for a class in type
`s package.
xmlNamespace
- The XML namespace to map.type
- A class in the package that should be mapped.public void addNamespaceMapping(String xmlNamespace, String namespacePrefix, Class type)
xmlNamespace
with a custom prefix to the package of the given type
.
The mapping is added to the createXamlNameMapper()
IXamlNameMapper} to determining type
information from XML elements and
to lookup the xmlNamespace
that should be used for a class in type
`s package.
xmlNamespace
- The XML namespace to map.namespacePrefix
- The prefix of the namespace to map.type
- A class in the package that should be mapped.public void addNamespaceMapping(String xmlNamespace, String packageName, ClassLoader classLoader)
xmlNamespace
to a packageName
and its classLoader
.
The mapping is added to the createXamlNameMapper()
IXamlNameMapper} to determining type
information from XML elements and
to lookup the xmlNamespace
that should be used for a class in packageName
.
xmlNamespace
- The XML namespace to map.packageName
- The package name.classLoader
- The ClassLoader to load the classes in the given package.public void addNamespaceMapping(String xmlNamespace, String namespacePrefix, String packageName, ClassLoader classLoader)
xmlNamespace
with a custom prefix to a packageName
and its classLoader
.
The mapping is added to the createXamlNameMapper()
IXamlNameMapper} to determining type
information from XML elements and
to lookup the xmlNamespace
that should be used for a class in packageName
.
xmlNamespace
- The XML namespace to map.packageName
- The package name.classLoader
- The ClassLoader to load the classes in the given package.public final <TModelItem,TValue> void addOutputMapper(Class<TModelItem> modelItemType, Class<TValue> valueType, String name, IMapper<TModelItem,TValue> mapper)
IMapper
instance for use as an output data source.
This methods creates and configures the necessary handler itself
TModelItem
- The type of the mapper keysTValue
- The type of the mapper valuesvalueType
- The type of the mapper valuesmodelItemType
- The type of the mapper keysname
- The name of the attributemapper
- the mapper that serves as data sourcepublic final <TModelItem,TValue> void addOutputMapper(Class<TModelItem> modelItemType, Class<TValue> valueType, String name, String uri, IMapper<TModelItem,TValue> mapper, IEventHandler<HandleSerializationEventArgs> serializationCallback, KeyType declaredKeyType)
IMapper
instance for use as an output data source.
This method uses a custom IEventHandler
for the actual serialization.
This methods creates and configures the necessary handler itself.
TModelItem
- The type of the mapper keysTValue
- The type of the mapper valuesvalueType
- The type of the mapper valuesmodelItemType
- The type of the mapper keysname
- The name of the attributeuri
- The URI to add to the key definition to disambiguate keys.mapper
- the mapper that serves as data sourceserializationCallback
- custom serialization callback.declaredKeyType
- The key type to write in the declaration.public final void addOverrideResolveReferenceListener(IEventHandler<ResolveReferenceEventArgs> overrideResolveReferenceEvent)
OverrideResolveReference
event that occurs before inline references are
evaluated.
Subscribe to this event to customize resolving of GraphML object references. This event is fired before the framework tries to resolve internal references and can therefore be used to override internal references, for example.
overrideResolveReferenceEvent
- The listener to add.addResolveReferenceListener(IEventHandler)
,
removeOverrideResolveReferenceListener(IEventHandler)
public final void addParsedListener(IEventHandler<ParseEventArgs> parsedEvent)
Parsed
event that occurs when the the document has been parsed.parsedEvent
- The listener to add.onParsed(ParseEventArgs)
,
GraphMLParser.addParsedListener(IEventHandler)
,
removeParsedListener(IEventHandler)
public final void addParsingListener(IEventHandler<ParseEventArgs> parsingEvent)
Parsing
event that occurs when the parsing of a document is just about to
begin.
This event can be used to register to the fine-grained events available in the
Context
's ParseEvents
and to configure
the parsing process on a per parse case.
parsingEvent
- The listener to add.onParsing(ParseEventArgs)
,
GraphMLParser.addParsingListener(IEventHandler)
,
removeParsingListener(IEventHandler)
public final void addQueryInputHandlersListener(IEventHandler<QueryInputHandlersEventArgs> queryInputHandlersEvent)
QueryInputHandlers
event that occurs when a GraphML attribute is about to be
read.
Subscribe to this event to dynamically register one or more IInputHandler
instance(s) for a given GraphML
attribute key definition.
The current key definition is provided by KeyDefinition
. If you
want to register an IInputHandler
for this GraphML attribute, you can add the handler with QueryInputHandlersEventArgs.addInputHandler(IInputHandler)
method. Implementations should also consider the Handled
property.
queryInputHandlersEvent
- The listener to add.GraphMLParser.addQueryInputHandlersListener(IEventHandler)
,
removeQueryInputHandlersListener(IEventHandler)
public final void addQueryOutputHandlersListener(IEventHandler<QueryOutputHandlersEventArgs> queryOutputHandlersEvent)
QueryOutputHandlers
event that occurs when a GraphML attribute is about to be
written.
Subscribe to this event to dynamically register one or more IOutputHandler
instance(s) for a given GraphML
attribute key definition.
The event handlers added to this event are called in inverse order, i.e. handlers that have been added later are called earlier.
If you want to register an IOutputHandler
for this GraphML attribute, you can add the handler with
QueryOutputHandlersEventArgs.addOutputHandler(IOutputHandler)
.
queryOutputHandlersEvent
- The listener to add.removeQueryOutputHandlersListener(IEventHandler)
public final void addQueryReferenceIdListener(IEventHandler<QueryReferenceIdEventArgs> queryReferenceIdEvent)
QueryReferenceId
event that occurs when a reference is queried.
This event can be used to provide names of external or internal references for objects.
The reference targets are not serialized to the GraphML file if they are set to
GraphMLReferenceType.EXTERNAL
. To resolve these references when parsing, you
typically have to subscribe to the ResolveReference
event.
queryReferenceIdEvent
- The listener to add.QueryReferenceIdEventArgs.getReferenceId()
,
QueryReferenceIdEventArgs.getReferenceType()
,
removeQueryReferenceIdListener(IEventHandler)
public final <TKey,TData> Future<IMapper<TKey,TData>> addRegistryInputMapper(Class<TKey> keyType, Class<TData> dataType, Object tag, Predicate<Element> keyDefinitionPredicate, IEventHandler<HandleDeserializationEventArgs> deserializationCallback)
Future
instance that wraps an IInputHandler
that stores the data in an IMapper
that
will be created
in the graph's IMapperRegistry
.
The return value will only contain a value if a matching GraphML attribute has been read, which can be queried with
HasValue
. This methods creates and configures the necessary handler itself and creates
an IMapper
in the IMapperRegistry
with name tag
.
tag
- The name of the key in the IMapperRegistry
.keyDefinitionPredicate
- A predicate to determine whether the key definition is valid.deserializationCallback
- The custom deserialization callback, can be null
which will result in default deserialization.Future
instance that wraps an IMapper
that actually holds the data.public final <TKey,TData> Future<IMapper<TKey,TData>> addRegistryInputMapper(Class<TKey> keyType, Class<TData> dataType, String name)
Future
instance that wraps an IInputHandler
that stores the data in an IMapper
that
will be created
in the graph's IMapperRegistry
.
The return value will only contain a value if a matching GraphML attribute has been read, which can be queried with
HasValue
. The attribute must be registered under the attribute name name
. This
methods creates and configures the necessary handler itself and creates
an IMapper
in the IMapperRegistry
with name name
.
name
- The name of the GraphML attribute and the key in the IMapperRegistry
.Future
instance that wraps an IMapper
that actually holds the data.public final <TModelItem,TValue> void addRegistryOutputMapper(Class<TModelItem> modelItemType, Class<TValue> valueType, String name, Object tag)
IMapper
instance as source for the given GraphML attribute.name
- The GraphML name of the attributetag
- The tag name of the mapper in the IMapperRegistry
public final <TModelItem,TValue> void addRegistryOutputMapper(Class<TModelItem> modelItemType, Class<TValue> valueType, String name, String uri, Object tag, IEventHandler<HandleSerializationEventArgs> serializationCallback, KeyType declaredKeyType)
IMapper
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.tag
- The tag name of the mapper in the IMapperRegistry
serializationCallback
- custom serialization callback.declaredKeyType
- The key type to write in the declaration.public final void addRegistryOutputMapper(String name, Object tag)
IMapper
instance as source for the given GraphML attribute.
The type arguments of the mapper are determined automatically.
name
- The GraphML name of the attributetag
- The tag name of the mapper in the IMapperRegistry
public final void addRegistryOutputMapper(String name, String uri, Object tag, IEventHandler<HandleSerializationEventArgs> serializationCallback)
IMapper
instance as source for the given GraphML attribute.
The type arguments of the mapper are determined automatically.
name
- The GraphML name of the attributeuri
- The optional URI of the attributetag
- The tag name of the mapper in the IMapperRegistry
serializationCallback
- An optional serialization handlerpublic final void addResolveReferenceListener(IEventHandler<ResolveReferenceEventArgs> resolveReferenceEvent)
ResolveReference
event that occurs after references are evaluated.
Subscribe to this event to customize resolving of GraphML object references. This event is fired when the framework could not resolve an object reference by an internal one.
resolveReferenceEvent
- The listener to add.addOverrideResolveReferenceListener(IEventHandler)
,
removeResolveReferenceListener(IEventHandler)
public void addSchemaLocation(String schemaNamespace, String schemaLocation)
schemaNamespace
- The namespace URI for this schema locationschemaLocation
- The schema locationpublic final void addWritingListener(IEventHandler<WriteEventArgs> writingEvent)
Writing
event that occurs when the writing of a document is just about to
begin.
This event can be used to register to the fine-grained events available in the
Context
's WriteEvents
and to configure
the writing process on a per write case.
writingEvent
- The listener to add.onWriting(WriteEventArgs)
,
GraphMLWriter.addWritingListener(IEventHandler)
,
removeWritingListener(IEventHandler)
public final void addWrittenListener(IEventHandler<WriteEventArgs> writtenEvent)
Written
event that occurs when the writing of a document has been finished.writtenEvent
- The listener to add.onWritten(WriteEventArgs)
,
GraphMLWriter.addWrittenListener(IEventHandler)
,
removeWrittenListener(IEventHandler)
protected void configureDeserializationHandlers(IGraph graph, GraphMLParser parser)
HandleDeserialization
event.
Except for text content and primitive types, this implementation delegates all work to
handleXamlDeserialization(Object, HandleDeserializationEventArgs)
This method is called for each parse process.
graph
- The graph that will be parsed.parser
- The parser to configure.handlePrimitivesDeserialization(Object, HandleDeserializationEventArgs)
,
handleXamlDeserialization(Object, HandleDeserializationEventArgs)
,
handleTextNodeDeserialization(Object, HandleDeserializationEventArgs)
protected void configureDeserializationPropertyOverrides(GraphMLParser parser)
deserialization property overrides
for the given parser.
This method is called for each parse process.
parser
- The parser to set the deserialization properties.protected void configureGraphMLParser(GraphMLParser parser, IGraph graph)
GraphMLParser
that can handle the given graph.
This method is called by createGraphMLParser(IGraph)
.
parser
- The parser to configuregraph
- The graph that should be filled by the parserprotected void configureGraphMLWriter(GraphMLWriter writer, IGraph graph)
GraphMLWriter
that is used for writing graph
.
This method is called by createGraphMLWriter(IGraph)
.
writer
- The writer to configuregraph
- The graph that will be written.protected void configureInputHandlers(GraphMLParser parser)
QueryInputHandlers
event.
This implementation configures several input handlers for the standard yFiles for JavaFX GraphML attributes (styles, folding state, labels, geometry).
This method is called for each parse process.
parser
- The parser that should be configured.protected void configureLookup(GraphMLParser parser)
This method is called for each parse process.
parser
- The parser to configure.protected void configureLookup(IGraph graph, GraphMLWriter writer)
writer
.
This method is called for each write process.
graph
- The graph that will be written.writer
- The writer to configure.GraphMLWriter.setLookup(Class, Object)
protected void configureNamespaces(GraphMLWriter writer)
writer
to use the namespace declarations set with addNamespace(String, String)
.
In addition to the namespace declarations provided with addNamespace(String, String)
, the default GraphMLWriter
implementation also automatically places all namespace declarations that have occurred
This method is called for each write process.
writer
- The writer to configure.protected void configureOutputHandlers(IGraph graph, GraphMLWriter writer)
QueryOutputHandlers
event.
This implementation configures several output handlers for the standard yFiles GraphML attributes (styles, folding state, labels, geometry).
This method is called for each write process.
graph
- The graph that will be written.writer
- The writer that should be configured.protected void configureSchemaLocations(GraphMLWriter writer)
writer
to use the schema locations set with addSchemaLocation(String, String)
.
This method is called for each write process.
writer
- The writer to configure.protected void configureSerializationHandlers(IGraph graph, GraphMLWriter writer)
HandleSerialization
event.
This method is called for each write process.
graph
- The graph that will be written.writer
- The writer to configure.protected void configureSerializationProperties(IGraph graph, GraphMLWriter writer)
GraphMLIOHandler
.
This method is called for each write process.
graph
- The graph to write.writer
- The writer to configure.GraphMLWriter.setSerializationProperty(TypedKey, Object)
protected void configureSerializationPropertyOverrides(GraphMLWriter writer)
serialization property overrides
for the given writer.
This method is called for each write process.
writer
- The writer to set the serialization properties.protected void configureXMLWriter(IXmlWriter writer)
writer
.
This method is called for each write process.
This implementation does nothing.
writer
- The writer to configure.protected IValueSerializerContext createDefaultValueSerializerContext()
This factory method can be used to provide custom ValueSerializer
s in cases where no ValueSerializer
can be used.
IValueSerializerContext
interface.protected IGraphElementFactory createGraphElementFactory(GraphMLParser parser, IGraph graph)
IGraphElementFactory
instance that creates the graph elements for the graph
instance.
This method is called for each parse process.
parser
- The parser to use.graph
- The graph that is populated.IGraphElementFactory
instance that is configured for the given parameters.protected GraphMLParser createGraphMLParser(IGraph graph)
GraphMLParser
that can handle the given graph.
This method is called for each parse process.
It delegates the configuration of the parser to configureGraphMLParser(GraphMLParser, IGraph)
.
graph
- The graph that should be filled by this instanceGraphMLParser
that can handle the given graphprotected GraphMLWriter createGraphMLWriter(IGraph graph)
GraphMLWriter
that is used for writing graph
.
This method is called for each write process. It delegates the configuration of the writer to
configureGraphMLWriter(GraphMLWriter, IGraph)
.
graph
- The graph that will be written.GraphMLWriter
instance that is configured for graph
.protected <TKey,TData> IMapper<TKey,TData> createMapper(Class<TKey> keyType, Class<TData> dataType, IParseContext context, Object registryTag)
addRegistryInputMapper(Class, Class, String)
and its overloads to creates the mapper
instance.
This method creates the mapper instance, unless there is an existing mapper in the target graph with a matching type. In
this case the existing mapper is returned. In all other cases a new mapper will be created using IMapperRegistry.createWeakMapper(Class, Class, Object)
and returned. If a mapper is already registered with the same registryTag
but wrong types it will be replaced.
TKey
- The type of the keys.TData
- The type of the data.dataType
- The type of the data.keyType
- The type of the keys.registryTag
- The tag for the mapper in the registry.public static final <TKey,TData> MapperInputHandler<TKey,TData> createMapperInputHandler(Class<TKey> modelItemType, Class<TData> dataType, IMapper<TKey,TData> mapper, IEventHandler<HandleDeserializationEventArgs> deserializationCallback)
IInputHandler
implementations that
match the provided TKey
and TData
.TKey
- The type of the mapper keysTData
- The type of the mapper entriesdataType
- The type of the mapper entriesmodelItemType
- The type of the mapper keysmapper
- The mapper to use.deserializationCallback
- Optional deserialization callback for complex data.MapperInputHandler
implementationpublic static final <TKey,TData> MapperOutputHandler<TKey,TData> createMapperOutputHandler(Class<TKey> modelItemType, Class<TData> dataType, String name, IMapper<TKey,TData> mapper, IEventHandler<HandleSerializationEventArgs> serializationCallback)
IOutputHandler
implementations that
match the provided TKey
and TData
.TKey
- The type of the mapper keysTData
- The type of the mapper entriesdataType
- The type of the mapper entriesmodelItemType
- The type of the mapper keysname
- The name of the graphml attributemapper
- The mapper to use.serializationCallback
- Optional serialization callback for complex data.MapperOutputHandler
implementationprotected IXamlNameMapper createXamlNameMapper()
This method is called for each read or write process.
protected IXamlPrefixMapper createXamlPrefixMapper()
This method is called for each write process.
protected IXmlWriter createXMLWriter(OutputStream os, Charset encoding)
IXmlWriter
implementation that can write the graph to the
given InputStream
with the given settings.
This method is called for each write process. The IXmlWriter
implementation is used by default for all low-level
write operations.
os
- The serialization destinationencoding
- The encoding of the streamIXmlWriter
instance for the serializationIWriteContext.getWriter()
protected IXmlWriter createXMLWriter(Writer os)
IXmlWriter
implementation that can write the graph to the
given Writer
with the given settings.
This method is called for each write process. The IXmlWriter
implementation is used by default for all low-level
write operations.
os
- The serialization destinationIXmlWriter
instance for the serializationIWriteContext.getWriter()
public final TypedKeyMapper getDeserializationPropertyOverrides()
Using this mapper deserialization properties
can be
specified.
configureDeserializationPropertyOverrides(GraphMLParser)
public final TypedKeyMapper getSerializationPropertyOverrides()
Using this mapper serialization properties
can be
specified.
configureSerializationPropertyOverrides(GraphMLWriter)
protected void handleArraySerialization(Object sender, HandleSerializationEventArgs e)
This sets Handled
to true
iff Item
is an array. This handler is registered by default.
sender
- The origin of the event.e
- The event handler arguments.protected void handleListSerialization(Object sender, HandleSerializationEventArgs e)
Iterable
instances.
This sets Handled
to true
iff Item
is an Iterable
instance. This handler is registered by default.
sender
- The origin of the event.e
- The event handler arguments.protected void handleMarkupExtensionBasedSerialization(Object sender, HandleSerializationEventArgs e)
MarkupExtension
convertible instances.
This sets Handled
to true
iff Item
can be converted to a MarkupExtension
instance. This handler is registered by default.
sender
- The origin of the event.e
- The event handler arguments.protected void handleNullSerialization(Object sender, HandleSerializationEventArgs e)
null
references.
This sets Handled
to true
iff Item
is a null
reference. This handler is registered by default and is only used to write null
references in
XML element syntax.
sender
- The origin of the event.e
- The event handler arguments.protected void handlePrimitivesDeserialization(Object sender, HandleDeserializationEventArgs e)
sender
- The origin of the event.e
- The event handler arguments.protected void handleReferenceHandleSerialization(Object sender, HandleSerializationEventArgs e)
IReferenceHandle
instances.
This sets Handled
to true
iff Item
is a IReferenceHandle
instance. This handler is registered by default and should not be removed if WritingSharedReferencesEnabled
is enabled.
sender
- The origin of the event.e
- The event handler arguments.protected void handleTextConvertibleSerialization(Object sender, HandleSerializationEventArgs e)
ValueSerializer
.
This sets Handled
to true
iff Item
can be converted to a string with a
ValueSerializer
. This serializer is only called from element property syntax and is registered by default.
sender
- The origin of the event.e
- The event handler arguments.protected void handleTextNodeDeserialization(Object source, HandleDeserializationEventArgs args)
HandleDeserialization
event.source
- The source of the event.args
- The event arguments.HandleDeserializationEventArgs
protected void handleTypeExtensionSerialization(Object sender, HandleSerializationEventArgs e)
This sets Handled
to true
iff Item
is an array. This handler is registered by default.
sender
- The origin of the event.e
- The event handler arguments.protected void handleTypeSerialization(Object sender, HandleSerializationEventArgs e)
This sets Handled
to true
iff Item
is an array. This handler is registered by default.
sender
- The origin of the event.e
- The event handler arguments.protected void handleXamlDeserialization(Object source, HandleDeserializationEventArgs args)
HandleDeserialization
event.source
- The source of the event.args
- The event arguments.HandleDeserializationEventArgs
protected void handleXamlSerialization(Object sender, HandleSerializationEventArgs e)
This sets Handled
to true
iff Item
is not a null
reference. This handler is registered by default and uses XamlSerializer
to create XAML
output.
sender
- The origin of the event.e
- The event handler arguments.public final boolean isClearingGraphBeforeReadEnabled()
If set
totrue
, 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
setClearingGraphBeforeReadEnabled(boolean)
public final boolean isWritingSharedReferencesEnabled()
If enabled, multiple object references will be correctly represented in the output document, otherwise, each object reference will be serialized independently.
Note: Reading of shared references is always supported
true
setWritingSharedReferencesEnabled(boolean)
public final boolean isWritingXMLSchemaEnabled()
true
if schema descriptions should be written.true
setWritingXMLSchemaEnabled(boolean)
public static final boolean matchesName(Element definition, String name)
name
attribute in definition
matches name
.definition
- The key definition to checkname
- The name that should be matchedtrue
if the name attribute in definition
matches name
public static final boolean matchesScope(Element definition, KeyScope scope)
scope
attribute in definition
matches scope
.definition
- The key definition to checkscope
- The scope that should be matchedtrue
if the scope attribute in definition
matches scope
public static final boolean matchesType(Element definition, KeyType type)
type
attribute in definition
matches type
.definition
- The key definition to checktype
- The type that should be matchedtrue
if the type attribute in definition
matches type
public static final boolean matchesUri(Element definition, String uri)
uri
attribute in definition
matches uri
.definition
- The key definition to checkuri
- The uri that should be matchedtrue
if the uri attribute in definition
matches uri
protected void onGraphMLParserHandleDeserialization(Object sender, HandleDeserializationEventArgs e)
HandleDeserialization
event.
This event handler is used to propagate the HandleDeserialization
event to subscribers of HandleDeserialization
. This
implementation just calls onHandleDeserialization(HandleDeserializationEventArgs)
, which in turn raises the HandleDeserialization
event.
protected void onGraphMLParserQueryInputHandlers(Object sender, QueryInputHandlersEventArgs e)
QueryInputHandlers
event.
This event handler is used to propagate the QueryInputHandlers
event to subscribers of QueryInputHandlers
. This implementation
just calls onQueryInputHandlers(QueryInputHandlersEventArgs)
, which in turn raises the QueryInputHandlers
event.
protected void onGraphMLWriterHandleSerialization(Object sender, HandleSerializationEventArgs e)
HandleSerialization
event.
This event handler is used to propagate the HandleSerialization
event to subscribers of HandleSerialization
. This implementation
just calls onHandleSerialization(HandleSerializationEventArgs)
, which in turn raises the HandleSerialization
event.
protected void onGraphMLWriterQueryOutputHandlers(Object sender, QueryOutputHandlersEventArgs e)
QueryOutputHandlers
event.
This event handler is used to propagate the QueryOutputHandlers
event to subscribers of QueryOutputHandlers
. This implementation
just calls onQueryOutputHandlers(QueryOutputHandlersEventArgs)
, which in turn raises the QueryOutputHandlers
event.
protected void onHandleDeserialization(HandleDeserializationEventArgs args)
HandleDeserialization
event.args
- The arguments for the HandleDeserialization
event.protected void onHandleSerialization(HandleSerializationEventArgs args)
HandleSerialization
event.args
- The arguments for the HandleSerialization
event.protected void onOverrideResolveReference(ResolveReferenceEventArgs args)
OverrideResolveReference
event.args
- The arguments that get passed to the OverrideResolveReference
event.protected void onParsed(ParseEventArgs args)
Parsed
event.
This method is called when the document has been parsed and after DocumentParsed
is called.
args
- The ParseEventArgs
instance containing the event data.addParsedListener(IEventHandler)
protected void onParsing(ParseEventArgs args)
Parsing
event.
This method is called just before the parsing starts and before DocumentParsing
is called.
args
- The ParseEventArgs
instance containing the event data.addParsingListener(IEventHandler)
protected void onQueryInputHandlers(QueryInputHandlersEventArgs args)
QueryInputHandlers
event.args
- The arguments for the QueryInputHandlers
event.protected void onQueryOutputHandlers(QueryOutputHandlersEventArgs args)
QueryOutputHandlers
event.args
- The arguments for the QueryOutputHandlers
event.protected void onQueryReferenceId(QueryReferenceIdEventArgs args)
QueryReferenceId
event.NullPointerException
- args
is null.args
- The arguments that get passed to the QueryReferenceId
event.GraphMLWriter.onQueryReferenceId(QueryReferenceIdEventArgs)
protected void onResolveReference(ResolveReferenceEventArgs args)
ResolveReference
event.args
- The arguments that get passed to the ResolveReference
event.protected void onWriting(WriteEventArgs args)
Writing
event.
This method is called just before the writing starts and before DocumentWriting
is called.
args
- The WriteEventArgs
instance containing the event data.addWritingListener(IEventHandler)
protected void onWritten(WriteEventArgs args)
Written
event.
This method is called just after the writing finishes and after DocumentWritten
is called.
args
- The WriteEventArgs
instance containing the event data.addWrittenListener(IEventHandler)
public void read(IGraph graph, Document document) throws IOException
NullPointerException
- doc
is null.NullPointerException
- graph
is null.IOException
graph
- The Graph object that is to be populated with nodes and edges as read from the document.document
- The XML document.public void read(IGraph graph, InputStream stream) throws IOException
Note this method only supports GraphML with absolute paths.
For importing GraphML with relative paths, use read(com.yworks.yfiles.graph.IGraph, java.io.InputStream, java.net.URI)
instead.
NullPointerException
- stream
is null.NullPointerException
- graph
is null.IOException
- If the graph could not be read.graph
- The Graph object that is to be populated with nodes and edges as read from the stream.stream
- The input stream that holds the GraphML file to be read.public void read(IGraph graph, InputStream stream, URI baseUri) throws IOException
NullPointerException
- stream
is null.NullPointerException
- graph
is null.IOException
- If the graph could not be read.graph
- The Graph object that is to be populated with nodes and edges as read from
the stream.stream
- The input stream that holds the GraphML file to be read.baseUri
- The base URI which is used for the GraphML file being parsed to resolve relative paths.public void read(IGraph graph, Reader reader) throws IOException
Note this method only supports GraphML with absolute paths.
For importing GraphML with relative paths, use read(com.yworks.yfiles.graph.IGraph, java.io.Reader, java.net.URI)
instead.
NullPointerException
- reader
is null.NullPointerException
- graph
is null.IOException
- If the graph could not be read.graph
- The Graph object that is to be populated with nodes and edges as read from reader
.reader
- The input stream that holds the GraphML file to be read.public void read(IGraph graph, Reader reader, URI baseUri) throws IOException
NullPointerException
- reader
is null.NullPointerException
- graph
is null.IOException
- If the graph could not be read.graph
- The Graph object that is to be populated with nodes and edges as read from
reader
.reader
- The input stream that holds the GraphML file to be read.baseUri
- The base URI which is used for the GraphML file being parsed to resolve relative paths.public void read(IGraph graph, String filename) throws IOException
IGraph
object.NullPointerException
- filename
is null.NullPointerException
- graph
is null.IOException
- If the graph could not be read.graph
- The Graph object that is to be populated with nodes and edges as read from the GraphML file.filename
- The name of the file to be read.public void read(IGraph graph, URL url) throws IOException
NullPointerException
- graph
is null.IOException
- If the graph could not be read.URISyntaxException
- if the url is not formatted to be convertible into urigraph
- The Graph object that is to be populated with nodes and edges as read from
the GraphML file.url
- The url of the file to be read from the applications xap.protected void registerEdgeBendsInputHandler(Object sender, QueryInputHandlersEventArgs e)
This handler is by default registered for the QueryInputHandlers
event
protected void registerEdgeBendsOutputHandler(Object sender, QueryOutputHandlersEventArgs e)
This handler is by default registered for the QueryOutputHandlers
event
protected void registerEdgeLabelsInputHandler(Object sender, QueryInputHandlersEventArgs e)
This handler is by default registered for the QueryInputHandlers
event
protected void registerEdgeLabelsOutputHandler(Object sender, QueryOutputHandlersEventArgs e)
This handler is by default registered for the QueryOutputHandlers
event
protected void registerEdgeStyleInputHandler(Object sender, QueryInputHandlersEventArgs e)
This handler is by default registered for the QueryInputHandlers
event
protected void registerEdgeStyleOutputHandler(Object sender, QueryOutputHandlersEventArgs e)
This handler is by default registered for the QueryOutputHandlers
event
protected void registerGraphSettingsInputHandler(Object sender, QueryInputHandlersEventArgs e)
IGraph
graph default settings.
This handler is by default registered for the QueryInputHandlers
event
protected void registerGraphSettingsOutputHandler(Object sender, QueryOutputHandlersEventArgs e)
This handler is by default registered for the QueryOutputHandlers
event.
protected void registerNodeLabelsInputHandler(Object sender, QueryInputHandlersEventArgs e)
This handler is by default registered for the QueryInputHandlers
event
protected void registerNodeLabelsOutputHandler(Object sender, QueryOutputHandlersEventArgs e)
This handler is by default registered for the QueryOutputHandlers
event
protected void registerNodeLayoutInputHandler(Object sender, QueryInputHandlersEventArgs e)
This handler is by default registered for the QueryInputHandlers
event
protected void registerNodeLayoutOutputHandler(Object sender, QueryOutputHandlersEventArgs e)
This handler is by default registered for the QueryOutputHandlers
event
protected void registerNodeStyleInputHandler(Object sender, QueryInputHandlersEventArgs e)
This handler is by default registered for the QueryInputHandlers
event
protected void registerNodeStyleOutputHandler(Object sender, QueryOutputHandlersEventArgs e)
This handler is by default registered for the QueryOutputHandlers
event
protected void registerPortLocationInputHandler(Object sender, QueryInputHandlersEventArgs e)
This handler is by default registered for the QueryInputHandlers
event
protected void registerPortLocationOutputHandler(Object sender, QueryOutputHandlersEventArgs e)
This handler is by default registered for the QueryOutputHandlers
event
protected void registerPortStyleInputHandler(Object sender, QueryInputHandlersEventArgs e)
This handler is by default registered for the QueryInputHandlers
event
protected void registerPortStyleOutputHandler(Object sender, QueryOutputHandlersEventArgs e)
This handler is by default registered for the QueryOutputHandlers
event
protected void registerTagInputHandler(Object sender, QueryInputHandlersEventArgs e)
ITagOwner
tags.
This handler is by default registered for the QueryInputHandlers
event
protected void registerTagOutputHandler(Object sender, QueryOutputHandlersEventArgs e)
ITagOwner
tags.
This handler is by default registered for the QueryOutputHandlers
event
public final void removeHandleDeserializationListener(IEventHandler<HandleDeserializationEventArgs> handleDeserializationEvent)
HandleDeserialization
event that occurs when XML content is about to be
deserialized.
Subscribe to this event to provide custom deserialization handling for XML content.
The event handlers added to this event are called in inverse order, i.e. handlers that have been added later are called earlier.
The current XML content is provided by XmlNode
. If you want to
return deserialized content, set the value of the Result
property.
handleDeserializationEvent
- The listener to remove.GraphMLParser.addHandleDeserializationListener(IEventHandler)
,
addHandleDeserializationListener(IEventHandler)
public final void removeHandleSerializationListener(IEventHandler<HandleSerializationEventArgs> handleSerializationEvent)
HandleSerialization
event that occurs when XML content is about to be
serialized.
Subscribe to this event to provide custom serialization handling for XML content.
The event handlers added to this event are called in inverse order, i.e. handlers that have been added later are called earlier.
The current item is provided by Item
.
handleSerializationEvent
- The listener to remove.addHandleSerializationListener(IEventHandler)
public final void removeOverrideResolveReferenceListener(IEventHandler<ResolveReferenceEventArgs> overrideResolveReferenceEvent)
OverrideResolveReference
event that occurs before inline references are
evaluated.
Subscribe to this event to customize resolving of GraphML object references. This event is fired before the framework tries to resolve internal references and can therefore be used to override internal references, for example.
overrideResolveReferenceEvent
- The listener to remove.addResolveReferenceListener(IEventHandler)
,
addOverrideResolveReferenceListener(IEventHandler)
public final void removeParsedListener(IEventHandler<ParseEventArgs> parsedEvent)
Parsed
event that occurs when the the document has been parsed.parsedEvent
- The listener to remove.onParsed(ParseEventArgs)
,
GraphMLParser.addParsedListener(IEventHandler)
,
addParsedListener(IEventHandler)
public final void removeParsingListener(IEventHandler<ParseEventArgs> parsingEvent)
Parsing
event that occurs when the parsing of a document is just about to
begin.
This event can be used to register to the fine-grained events available in the
Context
's ParseEvents
and to configure
the parsing process on a per parse case.
parsingEvent
- The listener to remove.onParsing(ParseEventArgs)
,
GraphMLParser.addParsingListener(IEventHandler)
,
addParsingListener(IEventHandler)
public final void removeQueryInputHandlersListener(IEventHandler<QueryInputHandlersEventArgs> queryInputHandlersEvent)
QueryInputHandlers
event that occurs when a GraphML attribute is about to be
read.
Subscribe to this event to dynamically register one or more IInputHandler
instance(s) for a given GraphML
attribute key definition.
The current key definition is provided by KeyDefinition
. If you
want to register an IInputHandler
for this GraphML attribute, you can add the handler with QueryInputHandlersEventArgs.addInputHandler(IInputHandler)
method. Implementations should also consider the Handled
property.
queryInputHandlersEvent
- The listener to remove.GraphMLParser.addQueryInputHandlersListener(IEventHandler)
,
addQueryInputHandlersListener(IEventHandler)
public final void removeQueryOutputHandlersListener(IEventHandler<QueryOutputHandlersEventArgs> queryOutputHandlersEvent)
QueryOutputHandlers
event that occurs when a GraphML attribute is about to be
written.
Subscribe to this event to dynamically register one or more IOutputHandler
instance(s) for a given GraphML
attribute key definition.
The event handlers added to this event are called in inverse order, i.e. handlers that have been added later are called earlier.
If you want to register an IOutputHandler
for this GraphML attribute, you can add the handler with
QueryOutputHandlersEventArgs.addOutputHandler(IOutputHandler)
.
queryOutputHandlersEvent
- The listener to remove.addQueryOutputHandlersListener(IEventHandler)
public final void removeQueryReferenceIdListener(IEventHandler<QueryReferenceIdEventArgs> queryReferenceIdEvent)
QueryReferenceId
event that occurs when a reference is queried.
This event can be used to provide names of external or internal references for objects.
The reference targets are not serialized to the GraphML file if they are set to
GraphMLReferenceType.EXTERNAL
. To resolve these references when parsing, you
typically have to subscribe to the ResolveReference
event.
queryReferenceIdEvent
- The listener to remove.QueryReferenceIdEventArgs.getReferenceId()
,
QueryReferenceIdEventArgs.getReferenceType()
,
addQueryReferenceIdListener(IEventHandler)
public final void removeResolveReferenceListener(IEventHandler<ResolveReferenceEventArgs> resolveReferenceEvent)
ResolveReference
event that occurs after references are evaluated.
Subscribe to this event to customize resolving of GraphML object references. This event is fired when the framework could not resolve an object reference by an internal one.
resolveReferenceEvent
- The listener to remove.addOverrideResolveReferenceListener(IEventHandler)
,
addResolveReferenceListener(IEventHandler)
public final void removeWritingListener(IEventHandler<WriteEventArgs> writingEvent)
Writing
event that occurs when the writing of a document is just about to
begin.
This event can be used to register to the fine-grained events available in the
Context
's WriteEvents
and to configure
the writing process on a per write case.
writingEvent
- The listener to remove.onWriting(WriteEventArgs)
,
GraphMLWriter.addWritingListener(IEventHandler)
,
addWritingListener(IEventHandler)
public final void removeWrittenListener(IEventHandler<WriteEventArgs> writtenEvent)
Written
event that occurs when the writing of a document has been finished.writtenEvent
- The listener to remove.onWritten(WriteEventArgs)
,
GraphMLWriter.addWrittenListener(IEventHandler)
,
addWrittenListener(IEventHandler)
public final void setClearingGraphBeforeReadEnabled(boolean value)
If set
totrue
, 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.
value
- Default value is true
isClearingGraphBeforeReadEnabled()
public final void setWritingSharedReferencesEnabled(boolean value)
If enabled, multiple object references will be correctly represented in the output document, otherwise, each object reference will be serialized independently.
Note: Reading of shared references is always supported
value
- Default value is true
isWritingSharedReferencesEnabled()
public final void setWritingXMLSchemaEnabled(boolean value)
true
if schema descriptions should be written.value
- Default is true
isWritingXMLSchemaEnabled()
public final void write(IGraph graph, OutputStream os) throws IOException
NullPointerException
- graph
is null.NullPointerException
- os
is null.IOException
graph
- The Graph object that is to be written to a GraphML file.os
- The output stream where the output is written.public void write(IGraph graph, OutputStream os, Charset encoding) throws IOException
NullPointerException
- graph
is null.NullPointerException
- os
is null.IOException
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 writingpublic void write(IGraph graph, String filename) throws IOException
NullPointerException
- graph
is null.IllegalArgumentException
- Need a non-empty filenameIOException
graph
- The Graph object that is to be written to a GraphML file.filename
- The filename where the output is written.public void write(IGraph graph, Writer os) throws IOException
NullPointerException
- graph
is null.NullPointerException
- os
is null.IOException
graph
- The Graph object that is to be written to a GraphML file.os
- The text writer where the output is written.