Reads and writes graphs from/to the GraphML format.
Remarks
Type Details
- yFiles module
- view
See Also
Constructors
Creates a new instance of GraphMLIOHandler.
Properties
Gets or sets a value indicating whether to clear an existing graph instance before reading
Remarks
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.
The default is true
.
Gets the mapper for the overrides of the deserialization properties.
Remarks
Gets the mapper for the overrides of the serialization properties.
Remarks
Methods
addGraphInputData
<TValue>(dataType: Constructor<TValue>, name: string, graphData: function(IGraph, TValue):void, deserializationCallback?: function(IParseContext, Node, Constructor):TValue, uri?: string)Register graphData
as an input data target for GraphML data that is present at the graph level.
Remarks
This method can optionally use a custom event handler for the actual deserialization.
This method creates and configures the necessary handler itself.
Type Parameters
- TValue
- The type of the mapper values
Parameters
A map of options to pass to the method.
- dataType - Constructor<TValue>
- The type of the mapper values
- name - string
- The name of the attribute
- graphData - function(IGraph, TValue):void
- Delegate that stores the graph data dynamically
- deserializationCallback - function(IParseContext, Node, Constructor):TValue
- custom deserialization callback.
Signature Details
function(arg1: IParseContext, arg2: Node, arg3: Constructor) : TValue
Encapsulates a method that has three parameters and returns a value of the type specified by theTResult
parameter.Parameters
- arg1 - IParseContext
- The first parameter of the method that this delegate encapsulates.
- arg2 - Node
- The second parameter of the method that this delegate encapsulates.
- arg3 - Constructor
- The third parameter of the method that this delegate encapsulates.
Returns
- TValue
- The return value of the method that this delegate encapsulates.
- uri - string
- The optional URI of the key definition to disambiguate keys.
addGraphInputData
<TValue>(dataType: Constructor<TValue>, keyDefinitionPredicate: function(Element):boolean, graphData: function(IGraph, TValue):void, deserializationCallback?: function(IParseContext, Node, Constructor):TValue)Register graphData
as an input data target for GraphML data that is present at the graph level.
Remarks
This method can optionally use a custom event handler for the actual deserialization.
This method creates and configures the necessary handler itself.
Type Parameters
- TValue
- The type of the mapper values
Parameters
A map of options to pass to the method.
- dataType - Constructor<TValue>
- The type of the mapper values
- keyDefinitionPredicate - function(Element):boolean
- Predicate function to select the correct GraphML attribute
Signature Details
function(obj: Element) : boolean
Represents the method that defines a set of criteria and determines whether the specified object meets those criteria.Parameters
- obj - Element
- The object to compare against the criteria defined within the method represented by this delegate.
Returns
- boolean
true
if obj meets the criteria defined within the method represented by this delegate; otherwise,false
.
- graphData - function(IGraph, TValue):void
- Delegate that stores the graph data dynamically
- deserializationCallback - function(IParseContext, Node, Constructor):TValue
- Custom deserialization callback.
Signature Details
function(arg1: IParseContext, arg2: Node, arg3: Constructor) : TValue
Encapsulates a method that has three parameters and returns a value of the type specified by theTResult
parameter.Parameters
- arg1 - IParseContext
- The first parameter of the method that this delegate encapsulates.
- arg2 - Node
- The second parameter of the method that this delegate encapsulates.
- arg3 - Constructor
- The third parameter of the method that this delegate encapsulates.
Returns
- TValue
- The return value of the method that this delegate encapsulates.
addGraphOutputData
<TValue>(dataType: Constructor<TValue>, name: string, graphData: TValue, serializationCallback?: function(IWriteContext, TValue, Constructor):void, declaredKeyType?: KeyType, uri?: string)Register graphData
as an output data source for data that is written at the graph level.
Remarks
This method can optionally use a custom event handler for the actual serialization.
This method creates and configures the necessary handler itself.
Type Parameters
- TValue
- The type of the mapper values
Parameters
A map of options to pass to the method.
- dataType - Constructor<TValue>
- The type of the mapper values
- name - string
- The name of the attribute
- graphData - TValue
- the data that is written at the top level
- serializationCallback - function(IWriteContext, TValue, Constructor):void
- custom serialization callback.
Signature Details
function(arg1: IWriteContext, arg2: TValue, arg3: Constructor)
Encapsulates a method that has two parameters and does not return a value.Parameters
- arg1 - IWriteContext
- The first parameter of the method that this delegate encapsulates.
- arg2 - TValue
- The second parameter of the method that this delegate encapsulates.
- arg3 - Constructor
- The third parameter of the method that this delegate encapsulates.
- declaredKeyType - KeyType
- The key type to write in the declaration. If this is omitted or
null
, the type is inferred automatically fromTValue
- uri - string
- The optional URI to add to the key definition to disambiguate keys.
addGraphOutputData
<TValue>(dataType: Constructor<TValue>, name: string, graphData: function(IGraph):TValue, serializationCallback?: function(IWriteContext, TValue, Constructor):void, declaredKeyType?: KeyType, uri?: string)Register graphData
as an output data source for data that is written at the graph level.
Remarks
This method can optionally use a custom event handler for the actual serialization.
This method creates and configures the necessary handler itself.
Type Parameters
- TValue
- The type of the mapper values
Parameters
A map of options to pass to the method.
- dataType - Constructor<TValue>
- The type of the mapper values
- name - string
- The name of the attribute
- graphData - function(IGraph):TValue
- Delegate that retrieves the graph data dynamically
Signature Details
function(arg: IGraph) : TValue
Encapsulates a method that has one parameters and returns a value of the type specified by theTResult
parameter.Parameters
- arg - IGraph
- The parameter of the method that this delegate encapsulates.
Returns
- TValue
- The return value of the method that this delegate encapsulates.
- serializationCallback - function(IWriteContext, TValue, Constructor):void
- custom serialization callback.
Signature Details
function(arg1: IWriteContext, arg2: TValue, arg3: Constructor)
Encapsulates a method that has two parameters and does not return a value.Parameters
- arg1 - IWriteContext
- The first parameter of the method that this delegate encapsulates.
- arg2 - TValue
- The second parameter of the method that this delegate encapsulates.
- arg3 - Constructor
- The third parameter of the method that this delegate encapsulates.
- declaredKeyType - KeyType
- The key type to write in the declaration. If this is omitted or
null
, the type is inferred automatically fromTValue
- uri - string
- The optional URI to add to the key definition to disambiguate keys.
addInputMapper
<TKey,TData>(keyType: Constructor<TKey>, dataType: Constructor<TData>, name: string, mapper: IMapper<TKey,TData>)Register an IMapper<K,V> instance for use as an input data target.
Remarks
Type Parameters
- TKey
- The type of the mapper keys
- TData
- The type of the mapper values
Parameters
A map of options to pass to the method.
- keyType - Constructor<TKey>
- The type of the mapper keys
- dataType - Constructor<TData>
- The type of the mapper values
- name - string
- The name of the attribute
- mapper - IMapper<TKey,TData>
- the mapper that serves as data source
See Also
addInputMapper
<TKey,TData>(keyType: Constructor<TKey>, dataType: Constructor<TData>, keyDefinitionPredicate: function(Element):boolean, mapper: IMapper<TKey,TData>, deserializationCallback: function(IParseContext, Node, Constructor):TData)Register an IMapper<K,V> instance for use as an input data target.
Remarks
This method uses a custom event handler for the actual deserialization.
This method creates and configures the necessary handler itself.
Type Parameters
- TKey
- The type of the mapper keys
- TData
- The type of the mapper values
Parameters
A map of options to pass to the method.
- keyType - Constructor<TKey>
- The type of the mapper keys
- dataType - Constructor<TData>
- The type of the mapper values
- keyDefinitionPredicate - function(Element):boolean
- The predicate function that will determine whether to create an IInputHandler for the given key definition.
Signature Details
function(obj: Element) : boolean
Represents the method that defines a set of criteria and determines whether the specified object meets those criteria.Parameters
- obj - Element
- The object to compare against the criteria defined within the method represented by this delegate.
Returns
- boolean
true
if obj meets the criteria defined within the method represented by this delegate; otherwise,false
.
- mapper - IMapper<TKey,TData>
- the mapper that serves as data source
- deserializationCallback - function(IParseContext, Node, Constructor):TData
- custom deserialization callback.
Signature Details
function(arg1: IParseContext, arg2: Node, arg3: Constructor) : TData
Encapsulates a method that has three parameters and returns a value of the type specified by theTResult
parameter.Parameters
- arg1 - IParseContext
- The first parameter of the method that this delegate encapsulates.
- arg2 - Node
- The second parameter of the method that this delegate encapsulates.
- arg3 - Constructor
- The third parameter of the method that this delegate encapsulates.
Returns
- TData
- The return value of the method that this delegate encapsulates.
Adds a namespace to the header of a GraphML file.
Parameters
A map of options to pass to the method.
- namespaceURI - string
- The namespace URI
- shortName - string
- The namespace prefix
Throws
- Exception({ name: 'ArgumentError' })
- If
namespaceURI
isnull
.
addOutputMapper
<TModelItem,TValue>(modelItemType: Constructor<TModelItem>, dataType: Constructor<TValue>, name: string, mapper: IMapper<TModelItem,TValue>)Register an IMapper<K,V> instance for use as an output data source
Remarks
Type Parameters
- TModelItem
- The type of the mapper keys
- TValue
- The type of the mapper values
Parameters
A map of options to pass to the method.
- modelItemType - Constructor<TModelItem>
- The type of the mapper keys
- dataType - Constructor<TValue>
- The type of the mapper values
- name - string
- The name of the attribute
- mapper - IMapper<TModelItem,TValue>
- the mapper that serves as data source
See Also
addOutputMapper
<TModelItem,TValue>(modelItemType: Constructor<TModelItem>, dataType: Constructor<TValue>, name: string, uri: string, mapper: IMapper<TModelItem,TValue>, serializationCallback: function(IWriteContext, TValue, Constructor):void, declaredKeyType: KeyType)Register an IMapper<K,V> instance for use as an output data source.
Remarks
This method uses a custom event handler for the actual serialization.
This method creates and configures the necessary handler itself.
Type Parameters
- TModelItem
- The type of the mapper keys
- TValue
- The type of the mapper values
Parameters
A map of options to pass to the method.
- modelItemType - Constructor<TModelItem>
- The type of the mapper keys
- dataType - Constructor<TValue>
- The type of the mapper values
- name - string
- The name of the attribute
- uri - string
- The URI to add to the key definition to disambiguate keys.
- mapper - IMapper<TModelItem,TValue>
- the mapper that serves as data source
- serializationCallback - function(IWriteContext, TValue, Constructor):void
- custom serialization callback.
Signature Details
function(arg1: IWriteContext, arg2: TValue, arg3: Constructor)
Encapsulates a method that has two parameters and does not return a value.Parameters
- arg1 - IWriteContext
- The first parameter of the method that this delegate encapsulates.
- arg2 - TValue
- The second parameter of the method that this delegate encapsulates.
- arg3 - Constructor
- The third parameter of the method that this delegate encapsulates.
- declaredKeyType - KeyType
- The key type to write in the declaration.
Adds a schema location to the header of a GraphML file.
Parameters
A map of options to pass to the method.
- schemaNamespace - string
- The namespace URI for this schema location
- schemaLocation - string
- The schema location
Throws
- Exception({ name: 'ArgumentError' })
- If
schemaNamespace
isnull
.
Register additional information about a type and its properties.
Remarks
Type Parameters
- T
Parameters
A map of options to pass to the method.
- tType - Constructor<T>
- metadata - TypeMetadata<T>
- The metadata for the type and its properties.
See Also
Add a namespace mapping between an XML namespace and a JavaScript module
.
Remarks
The module is an object where the keys are XML tag names and the values are the types to be mapped.
This is used both for writing and parsing objects.
Parameters
A map of options to pass to the method.
- xmlNamespace - string
- The XML namespace that corresponds to
module
. - module - any
- The module that is mapped to the XML namespace. The keys are the names of the XML tags. The values are the types.
See Also
Allows for configuration of the initial IParseContext that is used for reading a GraphML file.
Remarks
rootContext
instance or a new IParseContext instance that wraps the given rootContext
instance. Thus, it is recommended to create an instance of ChildParseContext that wraps the given rootContext
instance if custom configuration is necessary.Parameters
A map of options to pass to the method.
- rootContext - IParseContext
- The initial parse context that is created by the framework.
Returns
- ↪IParseContext
- A suitably configured parse context.
See Also
Allows for configuration of the initial IWriteContext that is used for writing a GraphML file.
Remarks
rootContext
via the IWriteContext interface. Instead, create an instance of ChildWriteContext that wraps the provided context and configure that one.Parameters
A map of options to pass to the method.
- rootContext - IWriteContext
- The initial write context that is created by the framework.
Returns
- ↪IWriteContext
- A suitably configured write context.
See Also
Creates the default value serializer context and returns it.
Remarks
Returns
- ↪IValueSerializerContext
- An implementation of the IValueSerializerContext interface.
Configure mappings from CLR to XML names.
Remarks
Returns
- ↪IXamlNameMapper?
- The configured IXamlNameMapper.
Configure mappings from XML namespaces to prefixes.
Remarks
Returns
- ↪IXamlPrefixMapper
- The configured IXamlPrefixMapper.
Factory method that creates and configures a suitable IXmlWriter implementation.
Remarks
Returns
- ↪IXmlWriter
- A suitable IXmlWriter instance for the serialization
See Also
Parses the XML document document
into an graph
instance.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- The graph instance that is populated.
- document - Document
- The XML document instance to parse.
- context - IParseContext
- The initial parse context.
Returns
- ↪Promise<IGraph>
- A
Promise
that will resolve once thegraph
is populated with the content read from thedocument
.
See Also
Read GraphML from an existing XML document.
Parameters
A map of options to pass to the method.
- graph - IGraph
- The graph that is to be populated with nodes and edges as read from the document.
- document - Document
- The XML document.
Returns
- ↪Promise<IGraph>
- A
Promise
that will resolve once thegraph
is populated with the content read from thedocument
.
Throws
- Exception({ name: 'ArgumentError' })
document
is null.- Exception({ name: 'ArgumentError' })
graph
is null.
See Also
Convenience method that imports the graph
from an XML data provided in a string data
.
Parameters
A map of options to pass to the method.
- graph - IGraph
- The Graph object that is to be populated with nodes and edges as read from the GraphML data.
- data - string
- A string that contains GraphML data.
Returns
- ↪Promise<IGraph>
- A
Promise
that will resolve once thegraph
is populated with the content read from thedata
.
See Also
Reads GraphML content from the given url
and populates the graph
.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- The graph that is to be populated with nodes and edges as read from the URL.
- url - string
- The URL of the file to be read.
Returns
- ↪Promise<IGraph>
- A
Promise
that will resolve once thegraph
is populated with the content read from theurl
.
Throws
See Also
Events
Occurs when XML content is about to be deserialized.
Remarks
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.
See Also
Occurs when XML content is about to be serialized.
Remarks
Subscribe to this event to provide custom serialization handling for XML content.
The event handlers added to this event are called in reverse order, i.e. handlers that have been added later are called earlier.
The current item is provided by item.
See Also
Occurs before inline references are evaluated.
Remarks
See Also
Occurs when the document has been parsed.
See Also
Occurs when the parsing of a document is just about to begin.
Remarks
See Also
Occurs when a GraphML attribute is about to be read.
Remarks
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 addInputHandler method. Implementations should also consider the handled property.
Occurs when a name is queried.
Remarks
This event can be used to override name mappings to XML names in XAML.
If the event handler determines that it map resolve type to a xml name, it should place the result into the result property and thus mark the event as handled.
It is valid to provide only part of the XML name by setting the other part to null. In that case, the default name determination rules are used for that part.
Occurs when a GraphML attribute is about to be written.
Remarks
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 addOutputHandler.
Occurs when a reference is queried.
Remarks
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 EXTERNAL. To resolve these references when parsing, you typically have to subscribe to the resolve-reference event.
See Also
Occurs when a type is queried.
Remarks
See Also
Occurs after references are evaluated.
Remarks
See Also
Occurs when the writing of a document is just about to begin.
Remarks
See Also
Occurs when the writing of a document has been finished.
See Also
Static Methods
createMapperInputHandler
<TKey,TData>(modelItemType: Constructor<TKey>, dataType: Constructor<TData>, mapper: IMapper<TKey,TData>, deserializationCallback: function(IParseContext, Node, Constructor):TData) : MapperInputHandler<TKey,TData>Creates an IInputHandler implementation that matches the provided TKey
and TData
.
Remarks
TKey
and TData
.Type Parameters
- TKey
- The type of the mapper keys
- TData
- The type of the mapper entries
Parameters
A map of options to pass to the method.
- modelItemType - Constructor<TKey>
- The type of the mapper keys
- dataType - Constructor<TData>
- The type of the mapper entries
- mapper - IMapper<TKey,TData>
- The mapper to use.
- deserializationCallback - function(IParseContext, Node, Constructor):TData
- Optional deserialization callback for complex data.
Signature Details
function(arg1: IParseContext, arg2: Node, arg3: Constructor) : TData
Encapsulates a method that has three parameters and returns a value of the type specified by theTResult
parameter.Parameters
- arg1 - IParseContext
- The first parameter of the method that this delegate encapsulates.
- arg2 - Node
- The second parameter of the method that this delegate encapsulates.
- arg3 - Constructor
- The third parameter of the method that this delegate encapsulates.
Returns
- TData
- The return value of the method that this delegate encapsulates.
Returns
- ↪MapperInputHandler<TKey,TData>
- A suitable MapperInputHandler<TKey,TData> implementation
createMapperOutputHandler
<TKey,TData>(modelItemType: Constructor<TKey>, dataType: Constructor<TData>, name: string, mapper: IMapper<TKey,TData>, serializationCallback: function(IWriteContext, TData, Constructor):void) : MapperOutputHandler<TKey,TData>Creates an IOutputHandler implementation that matches the provided TKey
and TData
.
Remarks
TKey
and TData
.Type Parameters
- TKey
- The type of the mapper keys
- TData
- The type of the mapper entries
Parameters
A map of options to pass to the method.
- modelItemType - Constructor<TKey>
- The type of the mapper keys
- dataType - Constructor<TData>
- The type of the mapper entries
- name - string
- The name of the graphml attribute
- mapper - IMapper<TKey,TData>
- The mapper to use.
- serializationCallback - function(IWriteContext, TData, Constructor):void
- Optional serialization callback for complex data.
Signature Details
function(arg1: IWriteContext, arg2: TData, arg3: Constructor)
Encapsulates a method that has two parameters and does not return a value.Parameters
- arg1 - IWriteContext
- The first parameter of the method that this delegate encapsulates.
- arg2 - TData
- The second parameter of the method that this delegate encapsulates.
- arg3 - Constructor
- The third parameter of the method that this delegate encapsulates.
Returns
- ↪MapperOutputHandler<TKey,TData>
- A suitable MapperOutputHandler<TKey,TData> implementation
Checks whether the name
attribute in definition
matches name
Parameters
A map of options to pass to the method.
- definition - Element
- The key definition to check
- name - string
- The name that should be matched
Returns
- ↪boolean
true
if the name attribute indefinition
matchesname
Checks whether the scope
attribute in definition
matches scope
Parameters
A map of options to pass to the method.
- definition - Element
- The key definition to check
- scope - KeyScope
- The scope that should be matched
Returns
- ↪boolean
true
if the scope attribute indefinition
matchesscope
Checks whether the type
attribute in definition
matches type
Parameters
A map of options to pass to the method.
- definition - Element
- The key definition to check
- type - KeyType
- The type that should be matched
Returns
- ↪boolean
true
if the type attribute indefinition
matchestype
Checks whether the uri
attribute in definition
matches uri
Parameters
A map of options to pass to the method.
- definition - Element
- The key definition to check
- uri - string
- The uri that should be matched
Returns
- ↪boolean
true
if the uri attribute indefinition
matchesuri