C

GraphMLIOHandler

Reads and writes graphs from/to the GraphML format.
Inheritance Hierarchy

Remarks

For more information about the GraphML file format, please refer to the GraphML Primer.

See Also

Developer's Guide

Members

Show:

Constructors

Creates a new instance of GraphMLIOHandler.

Properties

Gets or sets a value indicating whether to clear an existing graph instance before reading

If set to true, an existing graph instance will be cleared before the graph is read into this instance, otherwise the loaded graph will be merged into the existing one.

The default is true.

final
Gets the mapper for the overrides of the deserialization properties.
Using this mapper deserialization properties can be specified.
readonlyfinal
Gets the mapper for the overrides of the serialization properties.
Using this mapper serialization properties can be specified.
readonlyfinal

Methods

Register graphData as an input data target for GraphML data that is present at the graph level.

This method can optionally use a custom event handler for the actual deserialization.

This method creates and configures the necessary handler itself.

final

Parameters

dataType: Constructor<TValue>
The type of the mapper values
keyDefinitionPredicate: function(Element): boolean
Predicate function to select the correct GraphML attribute
graphData: function(IGraph, TValue): void
Delegate that stores the graph data dynamically
deserializationCallback?: function(IParseContext, Node, Constructor): TValue
Custom deserialization callback.
Register graphData as an input data target for GraphML data that is present at the graph level.

This method can optionally use a custom event handler for the actual deserialization.

This method creates and configures the necessary handler itself.

final

Parameters

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.
uri?: string
The optional URI of the key definition to disambiguate keys.
Register graphData as an output data source for data that is written at the graph level.

This method can optionally use a custom event handler for the actual serialization.

This method creates and configures the necessary handler itself.

final

Parameters

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.
declaredKeyType?: KeyType
The key type to write in the declaration. If this is omitted or null, the type is inferred automatically from TValue
uri?: string
The optional URI to add to the key definition to disambiguate keys.
Register graphData as an output data source for data that is written at the graph level.

This method can optionally use a custom event handler for the actual serialization.

This method creates and configures the necessary handler itself.

final

Parameters

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
serializationCallback?: function(IWriteContext, TValue, Constructor): void
custom serialization callback.
declaredKeyType?: KeyType
The key type to write in the declaration. If this is omitted or null, the type is inferred automatically from TValue
uri?: string
The optional URI to add to the key definition to disambiguate keys.
Register an IMapper<K, V> instance for use as an input data target.
This method creates and configures the necessary handler itself.
final

Parameters

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

Developer's Guide
Register an IMapper<K, V> instance for use as an input data target.

This method uses a custom event handler for the actual deserialization.

This method creates and configures the necessary handler itself.

final

Parameters

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.
mapper: IMapper<TKey, TData>
the mapper that serves as data source
deserializationCallback: function(IParseContext, Node, Constructor): TData
custom deserialization callback.
Adds a namespace to the header of a GraphML file.

Parameters

namespaceURI: string
The namespace URI
shortName: string
The namespace prefix

Throws

Exception ({ name: 'ArgumentError' })
If namespaceURI is null.
Register an IMapper<K, V> instance for use as an output data source
This method creates and configures the necessary handler itself
final

Parameters

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

Developer's Guide
Register an IMapper<K, V> instance for use as an output data source.

This method uses a custom event handler for the actual serialization.

This method creates and configures the necessary handler itself.

final

Parameters

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.
declaredKeyType: KeyType
The key type to write in the declaration.
Adds a schema location to the header of a GraphML file.

Parameters

schemaNamespace: string
The namespace URI for this schema location
schemaLocation: string
The schema location

Throws

Exception ({ name: 'ArgumentError' })
If schemaNamespace is null.
Register additional information about a type and its properties.
This can be used to provide additional information to the serialization and deserialization process.
final

Parameters

tType: Constructor<T>
metadata: TypeMetadata<T>
The metadata for the type and its properties.

See Also

Developer's Guide
API
addXamlNamespaceMapping
Add a namespace mapping between an XML namespace and a JavaScript module.

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.

final

Parameters

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

Developer's Guide
API
IXamlNameMapper, createXamlNameMapper, addTypeInformation
Allows for configuration of the initial IParseContext that is used for reading a GraphML file.
This method has to return the given 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.
protected

Parameters

rootContext: IParseContext
The initial parse context that is created by the framework.

Return Value

IParseContext
A suitably configured parse context.
Allows for configuration of the initial IWriteContext that is used for writing a GraphML file.
It is not recommended to return a custom implementation of IWriteContext or configure rootContext via the IWriteContext interface. Instead, create an instance of ChildWriteContext that wraps the provided context and configure that one.
protected

Parameters

rootContext: IWriteContext
The initial write context that is created by the framework.

Return Value

IWriteContext
A suitably configured write context.
Creates the default value serializer context and returns it.
This factory method can be used to provide custom ValueSerializers.
protected

Return Value

IValueSerializerContext
An implementation of the IValueSerializerContext interface.
Configure mappings from CLR to XML names.
This method is called for each read or write process.
protected

Return Value

IXamlNameMapper
The configured IXamlNameMapper.
Configure mappings from XML namespaces to prefixes.
This method is called for each write process.
protected

Return Value

IXamlPrefixMapper
The configured IXamlPrefixMapper.
Factory method that creates and configures a suitable IXmlWriter implementation.
This method is called for each write process. The IXmlWriter implementation is used by default for all low-level write operations.
protected

Return Value

IXmlWriter
A suitable IXmlWriter instance for the serialization

See Also

API
writer
Parses the XML document document into an graph instance.
This method is called from readFromDocument.
protected

Parameters

graph: IGraph
The graph instance that is populated.
document: Document
The XML document instance to parse.
context: IParseContext
The initial parse context.

Return Value

Promise<IGraph>
A Promise that will resolve once the graph is populated with the content read from the document.

See Also

API
readFromDocument
Read GraphML from an existing XML document.

Parameters

graph: IGraph
The graph that is to be populated with nodes and edges as read from the document.
document: Document
The XML document.

Return Value

Promise<IGraph>
A Promise that will resolve once the graph is populated with the content read from the document.

Throws

Exception ({ name: 'ArgumentError' })
document is null.
Exception ({ name: 'ArgumentError' })
graph is null.

See Also

Developer's Guide
Convenience method that imports the graph from an XML data provided in a string data.

Parameters

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.

Return Value

Promise<IGraph>
A Promise that will resolve once the graph is populated with the content read from the data.

See Also

Developer's Guide
Reads GraphML content from the given url and populates the graph.
Note that this is an asynchronous method that returns immediately. Use the returned Promise<void> to get notified when the actual parsing has completed.

Parameters

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.

Return Value

Promise<IGraph>
A Promise that will resolve once the graph is populated with the content read from the url.

Throws

Exception ({ name: 'ArgumentError' })
url is null.
Exception ({ name: 'ArgumentError' })
graph is null.

See Also

Developer's Guide
Writes the given graph object to GraphML.

Parameters

graph: IGraph
The Graph object that is to be written to a GraphML file.

Return Value

Promise<string>
A string containing the GraphML data.

See Also

Developer's Guide

Events

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.

context: IParseContext
Gets the context in which the xmlNode shall be deserialized.
handled: boolean
writable
Gets or sets a value indicating whether this HandleDeserializationEventArgs is handled.
result: any
writable
Gets or sets the result of the deserialization, which is null initially.
targetType: Constructor
Gets the type of the resulting instance that is required by the requesting deserializer or null if the target type is not known in advance.
xmlNode: Node
Gets the XML node that contains the data to deserialize.

See Also

Developer's Guide
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 reverse order, i.e. handlers that have been added later are called earlier.

The current item is provided by item.

context: IWriteContext
Gets the context to be used for writing.
handled: boolean
writable
Gets or sets a value indicating whether this HandleSerializationEventArgs is handled.
item: any
Gets the item that should be serialized.
sourceType: Constructor
Gets the type in the inheritance of the item that should be used for serialization.
writer: IXmlWriter
Gets the writer for writing the XML output.

See Also

Developer's Guide
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.
context: IParseContext
Gets the current parse context that can be used by the event handler for additional information.
handled: boolean
Gets whether the last event handler invocation has actually handled the event.
referenceId: string
Gets the reference ID that should be evaluated by the event handler.
value: any
writable
Gets or sets the reference value that is encapsulated by this instance.

See Also

API
resolve-reference
Occurs when the document has been parsed.

Properties of

ParseEventArgs
context: IParseContext
Gets the context that is being used for parsing.
element: Element
Gets the XML element that is currently parsed.

See Also

Developer's Guide
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.

Properties of

ParseEventArgs
context: IParseContext
Gets the context that is being used for parsing.
element: Element
Gets the XML element that is currently parsed.

See Also

Developer's Guide
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 addInputHandler method. Implementations should also consider the handled property.

context: IParseContext
Gets the IParseContext instance that can be queried for further information.
handled: boolean
writable
Gets or sets whether the current GraphML attribute has been processed.
handlers: IEnumerable<IInputHandler>
Gets the IInputHandlers that have been registered on this event argument instance so far.
keyDefinition: Element
Gets the key definition of the GraphML attribute.

See Also

Developer's Guide
Occurs when a name is queried.

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.

Properties of

QueryNameEventArgs
context: IWriteContext
Gets the context in which the type shall be mapped.
handled: boolean
writable
Gets or sets a value indicating whether this QueryNameEventArgs is handled.
result: XmlName
writable
Gets or sets the result of the name query, which is null initially.
type: Constructor
Gets the type for which the XML name is queried.
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 addOutputHandler.

context: IWriteContext
Gets the context for which the handlers are queried.
handlers: IEnumerable<IOutputHandler>
Gets the IOutputHandlers that have been registered on this event argument instance so far.
scope: KeyScope
Gets the scope where the handlers should be added.

See Also

Developer's Guide
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 EXTERNAL. To resolve these references when parsing, you typically have to subscribe to the resolve-reference event.

context: IWriteContext
Gets the current write context that can be used by the event handler for additional information.
handled: boolean
Gets whether the last event handler invocation has actually handled the event.
referenceId: string
writable
Gets or sets the reference id that should be evaluated by the event handler.
referenceType: GraphMLReferenceType
writable
Gets or sets the type of the reference being queried.
value: any
Gets the reference value that is encapsulated by this instance.

See Also

Developer's Guide
API
referenceId, referenceType
Occurs when a type is queried.
This event can be used to override type resolution for XML names in XAML.

Properties of

QueryTypeEventArgs
context: IParseContext
Gets the context in which the shall be mapped.
handled: boolean
writable
Gets or sets a value indicating whether this QueryTypeEventArgs is handled.
result: Constructor
writable
Gets or sets the result of the type query, which is null initially.
xmlName: XmlName
Gets the fully qualified XML name that should be resolved to a type.

See Also

API
QueryTypeEventArgs
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.
context: IParseContext
Gets the current parse context that can be used by the event handler for additional information.
handled: boolean
Gets whether the last event handler invocation has actually handled the event.
referenceId: string
Gets the reference ID that should be evaluated by the event handler.
value: any
writable
Gets or sets the reference value that is encapsulated by this instance.

See Also

Developer's Guide
API
override-resolve-reference
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.

Properties of

WriteEventArgs
context: IWriteContext
Gets the context that is being used for writing.
item: any
Gets the item that is currently being written or null if nothing is applicable.

See Also

Developer's Guide
Occurs when the writing of a document has been finished.

Properties of

WriteEventArgs
context: IWriteContext
Gets the context that is being used for writing.
item: any
Gets the item that is currently being written or null if nothing is applicable.

See Also

Developer's Guide

Static Methods

Creates an IInputHandler implementation that matches the provided TKey and TData.
This is a factory method that creates an instance of several predefined IInputHandler implementations that match the provided TKey and TData.
static

Parameters

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.

Return Value

MapperInputHandler<TKey, TData>
A suitable MapperInputHandler<TKey, TData> implementation
Creates an IOutputHandler implementation that matches the provided TKey and TData.
This is a factory method that creates an instance of several predefined IOutputHandler implementations that match the provided TKey and TData.
static

Parameters

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.

Return Value

MapperOutputHandler<TKey, TData>
A suitable MapperOutputHandler<TKey, TData> implementation
Checks whether the name attribute in definition matches name
static

Parameters

definition: Element
The key definition to check
name: string
The name that should be matched

Return Value

boolean
true if the name attribute in definition matches name
Checks whether the scope attribute in definition matches scope
static

Parameters

definition: Element
The key definition to check
scope: KeyScope
The scope that should be matched

Return Value

boolean
true if the scope attribute in definition matches scope
Checks whether the type attribute in definition matches type
static

Parameters

definition: Element
The key definition to check
type: KeyType
The type that should be matched

Return Value

boolean
true if the type attribute in definition matches type
Checks whether the uri attribute in definition matches uri
static

Parameters

definition: Element
The key definition to check
uri: string
The uri that should be matched

Return Value

boolean
true if the uri attribute in definition matches uri