|
mxGraph 2.4.0.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.mxgraph.io.mxCodec
public class mxCodec
XML codec for Java object graphs. In order to resolve forward references when reading files the XML document that contains the data must be passed to the constructor.
Field Summary | |
---|---|
protected Document |
document
Holds the owner document of the codec. |
protected boolean |
encodeDefaults
Specifies if default values should be encoded. |
protected Map<String,Object> |
objects
Maps from IDs to objects. |
Constructor Summary | |
---|---|
mxCodec()
Constructs an XML encoder/decoder with a new owner document. |
|
mxCodec(Document document)
Constructs an XML encoder/decoder for the specified owner document. |
Method Summary | |
---|---|
Object |
decode(Node node)
Decodes the given XML node using decode(Node, Object) . |
Object |
decode(Node node,
Object into)
Decodes the given XML node. |
mxICell |
decodeCell(Node node,
boolean restoreStructures)
Decodes cells that have been encoded using inversion, ie. |
Node |
encode(Object obj)
Encodes the specified object and returns the resulting XML node. |
void |
encodeCell(mxICell cell,
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. |
Document |
getDocument()
Returns the owner document of the codec. |
Node |
getElementById(String id)
Returns the element with the given ID from the document. |
Node |
getElementById(String id,
String attr)
Returns the element with the given ID from document. |
String |
getId(Object obj)
Returns the ID of the specified object. |
Object |
getObject(String id)
Returns the decoded object for the element with the specified ID in document . |
Map<String,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. |
Object |
lookup(String id)
Hook for subclassers to implement a custom lookup mechanism for cell IDs. |
Object |
putObject(String id,
Object object)
Assoiates the given object with the given ID. |
String |
reference(Object obj)
Hook for subclassers to implement a custom method for retrieving IDs from objects. |
static void |
setAttribute(Node node,
String attribute,
Object value)
Sets the attribute on the specified node to value. |
void |
setDocument(Document value)
Sets the owner document of the codec. |
void |
setEncodeDefaults(boolean encodeDefaults)
Sets if default values of member variables should be encoded. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Document document
protected Map<String,Object> objects
protected boolean encodeDefaults
Constructor Detail |
---|
public mxCodec()
public mxCodec(Document document)
document
- Optional XML document that contains the data. If no document
is specified then a new document is created using mxUtils.createDocumentMethod Detail |
---|
public Document getDocument()
public void setDocument(Document value)
public boolean isEncodeDefaults()
public void setEncodeDefaults(boolean encodeDefaults)
public Map<String,Object> getObjects()
public Object putObject(String id, Object object)
id
- ID for the object to be associated with.object
- Object to be associated with the ID.
public Object getObject(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 Object lookup(String id)
id
- ID of the object to be returned.
public Node getElementById(String id)
id
- ID of the element to be returned.
public Node getElementById(String id, String attr)
public String getId(Object obj)
obj
- Object to return the ID for.
public String reference(Object obj)
obj
- Object whose ID should be returned.
public Node encode(Object obj)
obj
- Object to be encoded.
public Object decode(Node node)
decode(Node, Object)
.
node
- XML node to be decoded.
public Object decode(Node node, Object into)
node
- XML node to be decoded.into
- Optional object to be decodec into.
public void encodeCell(mxICell cell, 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(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(Node node, String attribute, 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.
|
mxGraph 2.4.0.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |