com::mxgraph::mxCodec Class Reference

XML codec for .NET object graphs. In order to resolve forward references when reading files the XML document that contains the data must be passed to the constructor. More...

List of all members.

Public Member Functions

 mxCodec ()
 Constructs an XML encoder/decoder with a new owner document.
 mxCodec (XmlDocument document)
 Constructs an XML encoder/decoder for the specified owner document. The document is required to resolve forward ID references. This means if you parse a graphmodel that is represented in XML you must also pass the document that contains the XML to the constructor, otherwise forward references will not be resolved.
Object PutObject (string id, Object obj)
 Assoiates the given object with the given ID.
Object GetObject (string id)
 Returns the decoded object for the element with the specified ID in document. If the object is not known then lookup is used to find an object. If no object is found, then the element with the respective ID from the document is parsed using decode.
Object Lookup (string id)
 Hook for subclassers to implement a custom lookup mechanism for cell IDs. This implementation always returns null.
XmlNode GetElementById (string id)
 Returns the element with the given ID from the document.
XmlNode GetElementById (string id, string attributeName)
 Returns the element with the given ID from document. The optional attr argument specifies the name of the ID attribute. Default is id. The XPath expression used to find the element is //*[@id='arg'] where id is the name of the ID attribute (attributeName) and arg is the given id.
string GetId (Object obj)
 Returns the ID of the specified object. This implementation calls reference first and if that returns null handles the object as an mxCell by returning their IDs using mxCell.getId. If no ID exists for the given cell, then an on-the-fly ID is generated using mxCellPath.create.
string Reference (Object obj)
 Hook for subclassers to implement a custom method for retrieving IDs from objects. This implementation always returns null.
XmlNode Encode (Object obj)
 Encodes the specified object and returns the resulting XML node.
Object Decode (XmlNode node)
 Decodes the given XML node using decode(XmlNode, Object).
Object Decode (XmlNode node, Object into)
 Decodes the given XML node. The optional "into" argument specifies an existing object to be used. If no object is given, then a new instance is created using the constructor from the codec. The function returns the passed in object or the new instance if no object was given.
void EncodeCell (mxICell cell, XmlNode node, bool includeChildren)
 Encoding of cell hierarchies is built-into the core, but is a higher-level function that needs to be explicitely used by the respective object encoders (eg. mxModelCodec, mxChildChangeCodec and mxRootChangeCodec). This implementation writes the given cell and its children as a (flat) sequence into the given node. The children are not encoded if the optional includeChildren is false. The function is in charge of adding the result into the given node and has no return value.
mxICell DecodeCell (XmlNode node, bool restoreStructures)
 Decodes cells that have been encoded using inversion, ie. where the user object is the enclosing node in the XML, and restores the group and graph structure in the cells. Returns a new mxCell instance that represents the given node.
void InsertIntoGraph (mxICell cell)
 Inserts the given cell into its parent and terminal cells.

Static Public Member Functions

static void SetAttribute (XmlNode node, string attribute, Object value)
 Sets the attribute on the specified node to value. This is a helper method that makes sure the attribute and value arguments are not null.

Protected Attributes

XmlDocument document
 Holds the owner document of the codec.
Dictionary< string, object > objects = new Dictionary<string, Object>()
 Maps from IDs to objects.
bool encodeDefaults = false
 Specifies if default values should be encoded. Default is false.

Properties

XmlDocument Document [get, set]
 Sets or returns the owner document of the codec.
bool IsEncodeDefaults [get, set]
 Sets or returns if default values of member variables should be encoded.
Dictionary< string, object > Objects [get]
 Returns the object lookup table.

Detailed Description

XML codec for .NET object graphs. In order to resolve forward references when reading files the XML document that contains the data must be passed to the constructor.


Constructor & Destructor Documentation

com::mxgraph::mxCodec::mxCodec (  )  [inline]

Constructs an XML encoder/decoder with a new owner document.

com::mxgraph::mxCodec::mxCodec ( XmlDocument  document  )  [inline]

Constructs an XML encoder/decoder for the specified owner document. The document is required to resolve forward ID references. This means if you parse a graphmodel that is represented in XML you must also pass the document that contains the XML to the constructor, otherwise forward references will not be resolved.

Parameters:
document Optional XML document that contains the data. If no document is specified then a new document is created using mxUtils.createDocument

Member Function Documentation

Object com::mxgraph::mxCodec::Decode ( XmlNode  node,
Object  into 
) [inline]

Decodes the given XML node. The optional "into" argument specifies an existing object to be used. If no object is given, then a new instance is created using the constructor from the codec. The function returns the passed in object or the new instance if no object was given.

Parameters:
node XML node to be decoded.
into Optional object to be decodec into.
Returns:
Returns an object that represents the given node.
Object com::mxgraph::mxCodec::Decode ( XmlNode  node  )  [inline]

Decodes the given XML node using decode(XmlNode, Object).

Parameters:
node XML node to be decoded.
Returns:
Returns an object that represents the given node.
mxICell com::mxgraph::mxCodec::DecodeCell ( XmlNode  node,
bool  restoreStructures 
) [inline]

Decodes cells that have been encoded using inversion, ie. where the user object is the enclosing node in the XML, and restores the group and graph structure in the cells. Returns a new mxCell instance that represents the given node.

Parameters:
node XML node that contains the cell data.
restoreStructures Boolean indicating whether the graph structure should be restored by calling insert and insertEdge on the parent and terminals, respectively.
Returns:
Graph cell that represents the given node.
XmlNode com::mxgraph::mxCodec::Encode ( Object  obj  )  [inline]

Encodes the specified object and returns the resulting XML node.

Parameters:
obj Object to be encoded.
Returns:
Returns an XML node that represents the given object.
void com::mxgraph::mxCodec::EncodeCell ( mxICell  cell,
XmlNode  node,
bool  includeChildren 
) [inline]

Encoding of cell hierarchies is built-into the core, but is a higher-level function that needs to be explicitely used by the respective object encoders (eg. mxModelCodec, mxChildChangeCodec and mxRootChangeCodec). This implementation writes the given cell and its children as a (flat) sequence into the given node. The children are not encoded if the optional includeChildren is false. The function is in charge of adding the result into the given node and has no return value.

Parameters:
cell mxCell to be encoded.
node Parent XML node to add the encoded cell into.
includeChildren Boolean indicating if the method should include all descendents
XmlNode com::mxgraph::mxCodec::GetElementById ( string  id,
string  attributeName 
) [inline]

Returns the element with the given ID from document. The optional attr argument specifies the name of the ID attribute. Default is id. The XPath expression used to find the element is //*[@id='arg'] where id is the name of the ID attribute (attributeName) and arg is the given id.

Parameters:
id ID of the element to be returned.
attributeName Optional string for the attributename. Default is id.
Returns:
Returns the element for the given ID.
XmlNode com::mxgraph::mxCodec::GetElementById ( string  id  )  [inline]

Returns the element with the given ID from the document.

Parameters:
id ID of the element to be returned.
Returns:
Returns the element for the given ID.
string com::mxgraph::mxCodec::GetId ( Object  obj  )  [inline]

Returns the ID of the specified object. This implementation calls reference first and if that returns null handles the object as an mxCell by returning their IDs using mxCell.getId. If no ID exists for the given cell, then an on-the-fly ID is generated using mxCellPath.create.

Parameters:
obj Object to return the ID for.
Returns:
Returns the ID for the given object.
Object com::mxgraph::mxCodec::GetObject ( string  id  )  [inline]

Returns the decoded object for the element with the specified ID in document. If the object is not known then lookup is used to find an object. If no object is found, then the element with the respective ID from the document is parsed using decode.

Parameters:
id ID of the object to be returned.
Returns:
Returns the object for the given ID.
void com::mxgraph::mxCodec::InsertIntoGraph ( mxICell  cell  )  [inline]

Inserts the given cell into its parent and terminal cells.

Parameters:
cell 
Object com::mxgraph::mxCodec::Lookup ( string  id  )  [inline]

Hook for subclassers to implement a custom lookup mechanism for cell IDs. This implementation always returns null.

Parameters:
id ID of the object to be returned.
Returns:
Returns the object for the given ID.
Object com::mxgraph::mxCodec::PutObject ( string  id,
Object  obj 
) [inline]

Assoiates the given object with the given ID.

Parameters:
id ID for the object to be associated with.
obj Object to be associated with the ID.
Returns:
Returns the given object.
string com::mxgraph::mxCodec::Reference ( Object  obj  )  [inline]

Hook for subclassers to implement a custom method for retrieving IDs from objects. This implementation always returns null.

Parameters:
obj Object whose ID should be returned.
Returns:
Returns the ID for the given object.
static void com::mxgraph::mxCodec::SetAttribute ( XmlNode  node,
string  attribute,
Object  value 
) [inline, static]

Sets the attribute on the specified node to value. This is a helper method that makes sure the attribute and value arguments are not null.

Parameters:
node XML node to set the attribute for.
attribute Attributename to be set.
value New value of the attribute.

Member Data Documentation

XmlDocument com::mxgraph::mxCodec::document [protected]

Holds the owner document of the codec.

bool com::mxgraph::mxCodec::encodeDefaults = false [protected]

Specifies if default values should be encoded. Default is false.

Dictionary<string, object> com::mxgraph::mxCodec::objects = new Dictionary<string, Object>() [protected]

Maps from IDs to objects.


Property Documentation

XmlDocument com::mxgraph::mxCodec::Document [get, set]

Sets or returns the owner document of the codec.

Returns:
Returns the owner document.
bool com::mxgraph::mxCodec::IsEncodeDefaults [get, set]

Sets or returns if default values of member variables should be encoded.

Dictionary<string, object> com::mxgraph::mxCodec::Objects [get]

Returns the object lookup table.


The documentation for this class was generated from the following file:
Generated on Thu Jun 14 13:40:39 2012 for mxGraph by  doxygen 1.6.3