<!-- saved from url=(0026)http://www.naturaldocs.org -->
<divid=Content><divclass="CClass"><divclass=CTopicid=MainTopic><h1class=CTitle><aname="mxCodec"></a>mxCodec</h1><divclass=CBody><p>XML codec for JavaScript object graphs. See <ahref="mxObjectCodec-js.html#mxObjectCodec"class=LClassid=link20onMouseOver="ShowTip(event, 'tt18', 'link20')"onMouseOut="HideTip('tt18')">mxObjectCodec</a> for a description of the general encoding/decoding scheme. This class uses the codecs registered in <ahref="mxCodecRegistry-js.html#mxCodecRegistry"class=LClassid=link21onMouseOver="ShowTip(event, 'tt19', 'link21')"onMouseOut="HideTip('tt19')">mxCodecRegistry</a> for encoding/decoding each object.</p><h4class=CHeading>References</h4><p>In order to resolve references, especially forward references, the mxCodec constructor must be given the document that contains the referenced elements.</p><h4class=CHeading>Examples</h4><p>The following code is used to encode a graph model.</p><blockquote><preclass="prettyprint">var encoder = new mxCodec();
var result = encoder.encode(graph.getModel());
var xml = mxUtils.getXml(result);</pre></blockquote><h4class=CHeading>Example</h4><p>Using the following code, the selection cells of a graph are encoded and the output is displayed in a dialog box.</p><blockquote><preclass="prettyprint">var enc = new mxCodec();
var cells = graph.getSelectionCells();
mxUtils.alert(mxUtils.getPrettyXml(enc.encode(cells)));</pre></blockquote><p>Newlines in the XML can be coverted to <br>, in which case a ‘<br>’ argument must be passed to <ahref="../util/mxUtils-js.html#mxUtils.getXml"class=LFunctionid=link22onMouseOver="ShowTip(event, 'tt20', 'link22')"onMouseOut="HideTip('tt20')">mxUtils.getXml</a> as the second argument.</p><h4class=CHeading>Example</h4><p>Using the code below, an XML document is decodec into an existing model. The document may be obtained using one of the functions in mxUtils for loading an XML file, eg. <ahref="../util/mxUtils-js.html#mxUtils.get"class=LFunctionid=link23onMouseOver="ShowTip(event, 'tt21', 'link23')"onMouseOut="HideTip('tt21')">mxUtils.get</a>, or using <ahref="../util/mxUtils-js.html#mxUtils.parseXml"class=LFunctionid=link24onMouseOver="ShowTip(event, 'tt22', 'link24')"onMouseOut="HideTip('tt22')">mxUtils.parseXml</a> for parsing an XML string.</p><blockquote><preclass="prettyprint">var decoder = new mxCodec(doc)
decoder.decode(doc.documentElement, graph.getModel());</pre></blockquote><h4class=CHeading>Debugging</h4><p>For debugging I/O you can use the following code to get the sequence of encoded objects:</p><blockquote><preclass="prettyprint">var oldEncode = mxCodec.prototype.encode;
};</pre></blockquote><p>Note that the I/O system adds object codecs for new object automatically. For decoding those objects, the constructor should be written as follows:</p><blockquote><preclass="prettyprint">var MyObj = function(name)
};</pre></blockquote><!--START_ND_SUMMARY--><divclass=Summary><divclass=STitle>Summary</div><divclass=SBorder><tableborder=0cellspacing=0cellpadding=0class=STable><trclass="SMain"><tdclass=SEntry><ahref="#mxCodec">mxCodec</a></td><tdclass=SDescription>XML codec for JavaScript object graphs. </td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxCodec.Functions">Functions</a></td><tdclass=SDescription></td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.mxCodec"id=link1onMouseOver="ShowTip(event, 'tt1', 'link1')"onMouseOut="HideTip('tt1')">mxCodec</a></td><tdclass=SDescription>Constructs an XML encoder/decoder for the specified owner document.</td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxCodec.Variables">Variables</a></td><tdclass=SDescription></td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.document"id=link2onMouseOver="ShowTip(event, 'tt2', 'link2')"onMouseOut="HideTip('tt2')">document</a></td><tdclass=SDescription>The owner document of the codec.</td></tr><trclass="SVariable SIndent2"><tdclass=SEntry><ahref="#mxCodec.objects"id=link3onMouseOver="ShowTip(event, 'tt3', 'link3')"onMouseOut="HideTip('tt3')">objects</a></td><tdclass=SDescription>Maps from IDs to objects.</td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.encodeDefaults"id=link4onMouseOver="ShowTip(event, 'tt4', 'link4')"onMouseOut="HideTip('tt4')">encodeDefaults</a></td><tdclass=SDescription>Specifies if default values should be encoded. </td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxCodec.Functions">Functions</a></td><tdclass=SDescription></td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.putObject"id=link5onMouseOver="ShowTip(event, 'tt5', 'link5')"onMouseOut="HideTip('tt5')">putObject</a></td><tdclass=SDescription>Assoiates the given object with the given ID and returns the given object.</td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxCodec.getObject"id=link6onMouseOver="ShowTip(event, 'tt6', 'link6')"onMouseOut="HideTip('tt6')">getObject</a></td><tdclass=SDescription>Returns the decoded object for the element with the specified ID in <ahref="#mxCodec.document"class=LVariableid=link7onMouseOver="ShowTip(event, 'tt2', 'link7')"onMouseOut="HideTip('tt2')">document</a>. </td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.lookup"id=link8onMouseOver="ShowTip(event, 'tt7', 'link8')"onMouseOut="HideTip('tt7')">lookup</a></td><tdclass=SDescription>Hook for subclassers to implement a custom lookup mechanism for cell IDs. </td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxCodec.getElementById"id=link9onMouseOver="ShowTip(event, 'tt8', 'link9')"onMouseOut="HideTip('tt8')">getElementById</a></td><tdclass=SDescription>Returns the element with the given ID from <ahref="#mxCodec.document"class=LVariableid=link10onMouseOver="ShowTip(event, 'tt2', 'link10')"onMouseOut="HideTip('tt2')">document</a>. </td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.getId"id=link11onMouseOver="ShowTip(event, 'tt9', 'link11')"onMouseOut="HideTip('tt9')">getId</a></td><tdclass=SDescription>Returns the ID of the specified object. </td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxCodec.reference"id=link12onMouseOver="ShowTip(event, 'tt10', 'link12')"onMouseOut="HideTip('tt10')">reference</a></td><tdclass=SDescription>Hook for subclassers to implement a custom method for retrieving IDs from objects. </td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.encode"id=link13onMouseOver="ShowTip(event, 'tt11', 'link13')"onMouseOut="HideTip('tt11')">encode</a></td><tdclass=SDescription>Encodes the specified object and returns the resulting XML node.</td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxCodec.decode"id=link14onMouseOver="ShowTip(event, 'tt12', 'link14')"onMouse
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.mxCodec"></a>mxCodec</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>function mxCodec(</td><tdclass=PParameternowrap>document</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Constructs an XML encoder/decoder for the specified owner document.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>document</td><tdclass=CDLDescription>Optional XML document that contains the data. If no document is specified then a new document is created using <ahref="../util/mxUtils-js.html#mxUtils.createXmlDocument"class=LFunctionid=link25onMouseOver="ShowTip(event, 'tt23', 'link25')"onMouseOut="HideTip('tt23')">mxUtils.createXmlDocument</a>.</td></tr></table></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxCodec.document"></a>document</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.document</td></tr></table></blockquote><p>The owner document of the codec.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxCodec.objects"></a>objects</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.objects</td></tr></table></blockquote><p>Maps from IDs to objects.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxCodec.encodeDefaults"></a>encodeDefaults</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.encodeDefaults</td></tr></table></blockquote><p>Specifies if default values should be encoded. Default is false.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.putObject"></a>putObject</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.putObject = function(</td><tdclass=PParameternowrap>id,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Assoiates the given object with the given ID and returns the given object.</p><p>Parameters</p><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>id</td><tdclass=CDLDescription>ID for the object to be associated with.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object to be associated with the ID.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.getObject"></a>getObject</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.getObject = function(</td><tdclass=PParameternowrap>id</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the decoded object for the element with the specified ID in <ahref="#mxCodec.document"class=LVariableid=link26onMouseOver="ShowTip(event, 'tt2', 'link26')"onMouseOut="HideTip('tt2')">document</a>. If the object is not known then <ahref="#mxCodec.lookup"class=LFunctionid=link27onMouseOver="ShowTip(event, 'tt7', 'link27')"onMouseOut="HideTip('tt7')">lookup</a> is used to find an object. If no object is found, then the element with the respective ID from the document is parsed using <ahref="#mxCodec.decode"class=LFunctionid=link28onMouseOver="ShowTip(event, 'tt12', 'link28')"onMouseOut="HideTip('tt12')">decode</a>.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.lookup"></a>lookup</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.lookup = function(</td><tdclass=PParameternowrap>id</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to implement a custom lookup mechanism for cell IDs. This implementation always returns null.</p><h4class=CHeading>Example</h4><blockquote><preclass="prettyprint">var codec = new mxCodec();
codec.lookup = function(id)
{
return model.getCell(id);
};</pre></blockquote><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>id</td><tdclass=CDLDescription>ID of the object to be returned.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.getElementById"></a>getElementById</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.getElementById = function(</td><tdclass=PParameternowrap>id,</td></tr><tr><td></td><tdclass=PParameternowrap>attr</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the element with the given ID from <ahref="#mxCodec.document"class=LVariableid=link29onMouseOver="ShowTip(event, 'tt2', 'link29')"onMouseOut="HideTip('tt2')">document</a>. The optional attr argument specifies the name of the ID attribute. Default is “id”. The XPath expression used to find the element is //*[@attr=’arg’] where attr is the name of the ID attribute and arg is the given id.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>id</td><tdclass=CDLDescription>String that contains the ID.</td></tr><tr><tdclass=CDLEntry>attr</td><tdclass=CDLDescription>Optional string for the attributename. Default is “id”.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.getId"></a>getId</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.getId = function(</td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the ID of the specified object. This implementation calls <ahref="#mxCodec.reference"class=LFunctionid=link30onMouseOver="ShowTip(event, 'tt10', 'link30')"onMouseOut="HideTip('tt10')">reference</a> first and if that returns null handles the object as an <ahref="../model/mxCell-js.html#mxCell"class=LClassid=link31onMouseOver="ShowTip(event, 'tt24', 'link31')"onMouseOut="HideTip('tt24')">mxCell</a> by returning their IDs using <ahref="../model/mxCell-js.html#mxCell.getId"class=LFunctionid=link32onMouseOver="ShowTip(event, 'tt25', 'link32')"onMouseOut="HideTip('tt25')">mxCell.getId</a>. If no ID exists for the given cell, then an on-the-fly ID is generated using <ahref="../model/mxCellPath-js.html#mxCellPath.create"class=LFunctionid=link33onMouseOver="ShowTip(event, 'tt26', 'link33')"onMouseOut="HideTip('tt26')">mxCellPath.create</a>.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object to return the ID for.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.reference"></a>reference</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.reference = function(</td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to implement a custom method for retrieving IDs from objects. This implementation always returns null.</p><h4class=CHeading>Example</h4><blockquote><preclass="prettyprint">var codec = new mxCodec();
codec.reference = function(obj)
{
return obj.getCustomId();
};</pre></blockquote><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object whose ID should be returned.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.encode"></a>encode</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.encode = function(</td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Encodes the specified object and returns the resulting XML node.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object to be encoded.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.decode"></a>decode</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.decode = function(</td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>into</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>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.</p><p>The function returns the passed in object or the new instance if no object was given.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to be decoded.</td></tr><tr><tdclass=CDLEntry>into</td><tdclass=CDLDescription>Optional object to be decodec into.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.encodeCell"></a>encodeCell</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.encodeCell = function(</td><tdclass=PParameternowrap>cell,</td></tr><tr><td></td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>includeChildren</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>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. <ahref="mxModelCodec-js.html#mxModelCodec"class=LClassid=link34onMouseOver="ShowTip(event, 'tt27', 'link34')"onMouseOut="HideTip('tt27')">mxModelCodec</a>, <ahref="mxChildChangeCodec-js.html#mxChildChangeCodec"class=LClassid=link35onMouseOver="ShowTip(event, 'tt28', 'link35')"onMouseOut="HideTip('tt28')">mxChildChangeCodec</a> and <ahref="mxRootChangeCodec-js.html#mxRootChangeCodec"class=LClassid=link36onMouseOver="ShowTip(event, 'tt29', 'link36')"onMouseOut="HideTip('tt29')">mxRootChangeCodec</a>). 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.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>cell</td><tdclass=CDLDescription><ahref="../model/mxCell-js.html#mxCell"class=LClassid=link37onMouseOver="ShowTip(event, 'tt24', 'link37')"onMouseOut="HideTip('tt24')">mxCell</a> to be encoded.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>Parent XML node to add the encoded cell into.</td></tr><tr><tdclass=CDLEntry>includeChildren</td><tdclass=CDLDescription>Optional boolean indicating if the function should include all descendents. Default is true.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.isCellCodec"></a>isCellCodec</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.isCellCodec = function(</td><tdclass=PParameternowrap>codec</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns true if the given codec is a cell codec. This uses <ahref="mxCellCodec-js.html#mxCellCodec.isCellCodec"class=LFunctionid=link38onMouseOver="ShowTip(event, 'tt30', 'link38')"onMouseOut="HideTip('tt30')">mxCellCodec.isCellCodec</a> to check if the codec is of the given type.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.decodeCell"></a>decodeCell</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.decodeCell = function(</td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>restoreStructures</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>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 <ahref="../model/mxCell-js.html#mxCell"class=LClassid=link39onMouseOver="ShowTip(event, 'tt24', 'link39')"onMouseOut="HideTip('tt24')">mxCell</a> instance that represents the given node.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node that contains the cell data.</td></tr><tr><tdclass=CDLEntry>restoreStructures</td><tdclass=CDLDescription>Optional boolean indicating whether the graph structure should be restored by calling insert and insertEdge on the parent and terminals, respectively. Default is true.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.insertIntoGraph"></a>insertIntoGraph</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.insertIntoGraph = function(</td><tdclass=PParameternowrap>cell</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Inserts the given cell into its parent and terminal cells.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.setAttribute"></a>setAttribute</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.setAttribute = function(</td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>attribute,</td></tr><tr><td></td><tdclass=PParameternowrap>value</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>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.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to set the attribute for.</td></tr><tr><tdclass=CDLEntry>attributes</td><tdclass=CDLDescription>Attributename to be set.</td></tr><tr><tdclass=CDLEntry>value</td><tdclass=CDLDescription>New value of the attribute.</td></tr></table></div></div></div>
</div><!--Content-->
<divid=Footer><ahref="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->
<divclass=CToolTipid="tt1"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>function mxCodec(</td><tdclass=PParameternowrap>document</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Constructs an XML encoder/decoder for the specified owner document.</div></div><divclass=CToolTipid="tt2"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.document</td></tr></table></blockquote>The owner document of the codec.</div></div><divclass=CToolTipid="tt3"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.objects</td></tr></table></blockquote>Maps from IDs to objects.</div></div><divclass=CToolTipid="tt4"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.encodeDefaults</td></tr></table></blockquote>Specifies if default values should be encoded. </div></div><divclass=CToolTipid="tt5"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.putObject = function(</td><tdclass=PParameternowrap>id,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Assoiates the given object with the given ID and returns the given object.</div></div><divclass=CToolTipid="tt6"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.getObject = function(</td><tdclass=PParameternowrap>id</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Returns the decoded object for the element with the specified ID in document. </div></div><divclass=CToolTipid="tt7"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.lookup = function(</td><tdclass=PParameternowrap>id</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Hook for subclassers to implement a custom lookup mechanism for cell IDs. </div></div><divclass=CToolTipid="tt8"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.getElementById = function(</td><tdclass=PParameternowrap>id,</td></tr><tr><td></td><tdclass=PParameternowrap>attr</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Returns the element with the given ID from document. </div></div><divclass=CToolTipid="tt9"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.getId = function(</td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Returns the ID of the specified object. </div></div><divclass=CToolTipid="tt10"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.reference = function(</td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Hook for subclassers to implement a custom method for retrievin