public class mxCodec
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected org.w3c.dom.Document |
document
Holds the owner document of the codec.
|
protected java.util.Map<java.lang.String,org.w3c.dom.Node> |
elements
Maps from IDs to elements.
|
protected boolean |
encodeDefaults
Specifies if default values should be encoded.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
objects
Maps from IDs to objects.
|
Constructor and Description |
---|
mxCodec()
Constructs an XML encoder/decoder with a new owner document.
|
mxCodec(org.w3c.dom.Document document)
Constructs an XML encoder/decoder for the specified owner document.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addElement(org.w3c.dom.Node node)
Adds the given element to
|
java.lang.Object |
decode(org.w3c.dom.Node node)
Decodes the given XML node using
decode(Node, Object) . |
java.lang.Object |
decode(org.w3c.dom.Node node,
java.lang.Object into)
Decodes the given XML node.
|
mxICell |
decodeCell(org.w3c.dom.Node node,
boolean restoreStructures)
Decodes cells that have been encoded using inversion, ie.
|
org.w3c.dom.Node |
encode(java.lang.Object obj)
Encodes the specified object and returns the resulting XML node.
|
void |
encodeCell(mxICell cell,
org.w3c.dom.Node node,
boolean 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.
|
org.w3c.dom.Document |
getDocument()
Returns the owner document of the codec.
|
org.w3c.dom.Node |
getElementById(java.lang.String id)
Returns the element with the given ID from the document.
|
java.lang.String |
getId(java.lang.Object obj)
Returns the ID of the specified object.
|
java.lang.Object |
getObject(java.lang.String id)
Returns the decoded object for the element with the specified ID in
document . |
java.util.Map<java.lang.String,java.lang.Object> |
getObjects()
Returns the object lookup table.
|
void |
insertIntoGraph(mxICell cell)
Inserts the given cell into its parent and terminal cells.
|
boolean |
isEncodeDefaults()
Returns if default values of member variables should be encoded.
|
java.lang.Object |
lookup(java.lang.String id)
Hook for subclassers to implement a custom lookup mechanism for cell IDs.
|
java.lang.Object |
putObject(java.lang.String id,
java.lang.Object object)
Assoiates the given object with the given ID.
|
java.lang.String |
reference(java.lang.Object obj)
Hook for subclassers to implement a custom method for retrieving IDs from
objects.
|
static void |
setAttribute(org.w3c.dom.Node node,
java.lang.String attribute,
java.lang.Object value)
Sets the attribute on the specified node to value.
|
void |
setDocument(org.w3c.dom.Document value)
Sets the owner document of the codec.
|
void |
setEncodeDefaults(boolean encodeDefaults)
Sets if default values of member variables should be encoded.
|
protected org.w3c.dom.Document document
protected java.util.Map<java.lang.String,java.lang.Object> objects
protected java.util.Map<java.lang.String,org.w3c.dom.Node> elements
protected boolean encodeDefaults
public mxCodec()
public mxCodec(org.w3c.dom.Document document)
document
- Optional XML document that contains the data. If no document
is specified then a new document is created using mxUtils.createDocumentpublic org.w3c.dom.Document getDocument()
public void setDocument(org.w3c.dom.Document value)
public boolean isEncodeDefaults()
public void setEncodeDefaults(boolean encodeDefaults)
public java.util.Map<java.lang.String,java.lang.Object> getObjects()
public java.lang.Object putObject(java.lang.String id, java.lang.Object object)
id
- ID for the object to be associated with.object
- Object to be associated with the ID.public java.lang.Object getObject(java.lang.String id)
document
. If the object is not known then lookup(String)
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(Node)
.id
- ID of the object to be returned.public java.lang.Object lookup(java.lang.String id)
id
- ID of the object to be returned.public org.w3c.dom.Node getElementById(java.lang.String id)
id
- ID of the element to be returned.protected void addElement(org.w3c.dom.Node node)
public java.lang.String getId(java.lang.Object obj)
obj
- Object to return the ID for.public java.lang.String reference(java.lang.Object obj)
obj
- Object whose ID should be returned.public org.w3c.dom.Node encode(java.lang.Object obj)
obj
- Object to be encoded.public java.lang.Object decode(org.w3c.dom.Node node)
decode(Node, Object)
.node
- XML node to be decoded.public java.lang.Object decode(org.w3c.dom.Node node, java.lang.Object into)
node
- XML node to be decoded.into
- Optional object to be decodec into.public void encodeCell(mxICell cell, org.w3c.dom.Node node, boolean includeChildren)
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.public mxICell decodeCell(org.w3c.dom.Node node, boolean restoreStructures)
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.public void insertIntoGraph(mxICell cell)
public static void setAttribute(org.w3c.dom.Node node, java.lang.String attribute, java.lang.Object value)
node
- XML node to set the attribute for.attribute
- Name of the attribute whose value should be set.value
- New value of the attribute.Copyright (c) 2010-2017 Gaudenz Alder, JGraph Ltd. All rights reserved.