<!-- saved from url=(0026)http://www.naturaldocs.org -->
<divid=Content><divclass="CClass"><divclass=CTopicid=MainTopic><h1class=CTitle><aname="mxObjectCodec"></a>mxObjectCodec</h1><divclass=CBody><p>Generic codec for JavaScript objects that implements a mapping between JavaScript objects and XML nodes that maps each field or element to an attribute or child node, and vice versa.</p><h4class=CHeading>Atomic Values</h4><p>Consider the following example.</p><blockquote><preclass="prettyprint">var obj = new Object();
obj.foo = "Foo";
obj.bar = "Bar";</pre></blockquote><p>This object is encoded into an XML node using the following.</p><blockquote><preclass="prettyprint">var enc = new mxCodec();
var node = enc.encode(obj);</pre></blockquote><p>The output of the encoding may be viewed using <ahref="../util/mxLog-js.html#mxLog"class=LClassid=link47onMouseOver="ShowTip(event, 'tt37', 'link47')"onMouseOut="HideTip('tt37')">mxLog</a> as follows.</p><blockquote><preclass="prettyprint">mxLog.show();
mxLog.debug(mxUtils.getPrettyXml(node));</pre></blockquote><p>Finally, the result of the encoding looks as follows.</p><blockquote><preclass="prettyprint"><Object foo="Foo" bar="Bar"/></pre></blockquote><p>In the above output, the foo and bar fields have been mapped to attributes with the same names, and the name of the constructor was used for the nodename.</p><h4class=CHeading>Booleans</h4><p>Since booleans are numbers in JavaScript, all boolean values are encoded into 1 for true and 0 for false. The decoder also accepts the string true and false for boolean values.</p><h4class=CHeading>Objects</h4><p>The above scheme is applied to all atomic fields, that is, to all non-object fields of an object. For object fields, a child node is created with a special attribute that contains the fieldname. This special attribute is called “as” and hence, as is a reserved word that should not be used for a fieldname.</p><p>Consider the following example where foo is an object and bar is an atomic property of foo.</p><blockquote><preclass="prettyprint">var obj = {foo: {bar: "Bar"}};</pre></blockquote><p>This will be mapped to the following XML structure by mxObjectCodec.</p><blockquote><preclass="prettyprint"><Object>
</Object></pre></blockquote><p>In the above output, the inner Object node contains the as-attribute that specifies the fieldname in the enclosing object. That is, the field foo was mapped to a child node with an as-attribute that has the value foo.</p><h4class=CHeading>Arrays</h4><p>Arrays are special objects that are either associative, in which case each key, value pair is treated like a field where the key is the fieldname, or they are a sequence of atomic values and objects, which is mapped to a sequence of child nodes. For object elements, the above scheme is applied without the use of the special as-attribute for creating each child. For atomic elements, a special add-node is created with the value stored in the value-attribute.</p><p>For example, the following array contains one atomic value and one object with a field called bar. Furthermore it contains two associative entries called bar with an atomic value, and foo with an object value.</p><blockquote><preclass="prettyprint">var obj = ["Bar", {bar: "Bar"}];
obj["bar"] = "Bar";
obj["foo"] = {bar: "Bar"};</pre></blockquote><p>This array is represented by the following XML nodes.</p><blockquote><preclass="prettyprint"><Array bar="Bar">
</Array></pre></blockquote><p>The Array node name is the name of the constructor. The additional as-attribute in the last child contains the key of the associative entry, whereas the second last child is part of the array sequence and does not have an as-attribute.</p><h4class=CHeading>References</h4><p>Objects may be represented as child nodes or attributes with ID values, which are used to lookup the object in a table within <ahref="mxCodec-js.html#mxCodec"class=LClassid=link48onMouseOver="ShowTip(event, 'tt38', 'link48')"onMouseOut="HideTip('tt38')">mxCodec</a>. The <ahref="#mxObjectCodec.isReference"class=LFunctionid=link49onMouseOver="ShowTip(event, 'tt13', 'link49')"onMouseOut="HideTip('tt13')">isReference</a> function is in charge of deciding if a specific field should be encoded as a reference or not. Its default implementation returns true if the fieldname is in <ahref="#mxObjectCodec.idrefs"class=LVariableid=link50onMouseOver="ShowTip(event, 'tt5', 'link50')"onMouseOut="HideTip('tt5')">idrefs</a>, an array of strings that is used to configure the <ahref="#mxObjectCodec.mxObjectCodec"class=LFunctionid=link51onMouseOver="ShowTip(event, 'tt1', 'link51')"onMouseOut="HideTip('tt1')">mxObjectCodec</a>.</p><p>Using this approach, the mapping does not guarantee that the referenced object itself exists in the document. The fields that are encoded as references must be carefully chosen to make sure all referenced objects exist in the document, or may be resolved by some other means if necessary.</p><p>For example, in the case of the graph model all cells are stored in a tree whose root is referenced by the model’s root field. A tree is a structure that is well suited for an XML representation, however, the additional edges in the graph model have a reference to a source and target cell, which are also contained in the tree. To handle this case, the source and target cell of an edge are treated as references, whereas the children are treated as objects. Since all cells are contained in the tree and no edge references a source or target outside the tree, this setup makes sure all referenced objects are contained in the document.</p><p>In the case of a tree structure we must further avoid infinite recursion by ignoring the parent reference of each child. This is done by returning true in <ahref="#mxObjectCodec.isExcluded"class=LFunctionid=link52onMouseOver="ShowTip(event, 'tt12', 'link52')"onMouseOut="HideTip('tt12')">isExcluded</a>, whose default implementation uses the array of excluded fieldnames passed to the mxObjectCodec constructor.</p><p>References are only used for cells in mxGraph. For defining other referencable object types, the codec must be able to work out the ID of an object. This is done by implementing <ahref="mxCodec-js.html#mxCodec.reference"class=LFunctionid=link53onMouseOver="ShowTip(event, 'tt39', 'link53')"onMouseOut="HideTip('tt39')">mxCodec.reference</a>. For decoding a reference, the XML node with the respective id-attribute is fetched from the document, decoded, and stored in a lookup table for later reference. For looking up external objects, <ahref="mxCodec-js.html#mxCodec.lookup"class=LFunctionid=link54onMouseOver="ShowTip(event, 'tt40', 'link54')"onMouseOut="HideTip('tt40')">mxCodec.lookup</a> may be implemented.</p><h4class=CHeading>Expressions</h4><p>For decoding JavaScript expressions, the add-node may be used with a text content that contains the JavaScript expression. For example, the following creates a field called foo in the enclosing object and assigns it the value of <ahref="../util/mxConstants-js.html#mxConstants.ALIGN_LEFT"class=LVariableid=link55onMouseOver="ShowTip(event, 'tt41', 'link55')"onMouseOut="HideTip('tt41')">mxConstants.ALIGN_LEFT</a>.</p><blockquote><preclass="prettyprint"><Object>
</Object></pre></blockquote><p>The resulting object has a field called foo with the value “left”. Its XML representation looks as follows.</p><blockquote><preclass="prettyprint"><Object foo="left"/></pre></blockquote><p>This means the expression is evaluated at decoding time and the result of the evaluation is stored in the respective field. Valid expressions are all JavaScript expressions, including function definitions, which are mapped to functions on the resulting object.</p><p>Expressions are only evaluated if <ahref="#mxObjectCodec.allowEval"class=LVariableid=link56onMouseOver="ShowTip(event, 'tt2', 'link56')"onMouseOut="HideTip('tt2')">allowEval</a> is true.</p><!--START_ND_SUMMARY--><divclass=Summary><divclass=STitle>Summary</div><divclass=SBorder><tableborder=0cellspacing=0cellpadding=0class=STable><trclass="SMain"><tdclass=SEntry><ahref="#mxObjectCodec">mxObjectCodec</a></td><tdclass=SDescription>Generic codec for JavaScript objects that implements a mapping between JavaScript objects and XML nodes that maps each field or element to an attribute or child node, and vice versa.</td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxObjectCodec.Functions">Functions</a></td><tdclass=SDescription></td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxObjectCodec.mxObjectCodec"id=link1onMouseOver="ShowTip(event, 'tt1', 'link1')"onMouseOut="HideTip('tt1')">mxObjectCodec</a></td><tdclass=SDescription>Constructs a new codec for the specified template object. </td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxObjectCodec.Variables">Variables</a></td><tdclass=SDescription></td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxObjectCodec.allowEval"id=link2onMouseOver="ShowTip(event, 'tt2', 'link2')"onMouseOut="HideTip('tt2')">allowEval</a></td><tdclass=SDescription>Static global switch that specifies if expressions in arrays are allowed. </td></tr><trclass="SVariable SIndent2"><tdclass=SEntry><ahref="#mxObjectCodec.template"id=link3onMouseOver="ShowTip(event, 'tt3', 'link3')"onMouseOut="HideTip('tt3')">template</a></td><tdclass=SDescription>Holds the template object associated with this codec.</td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxObjectCodec.exclude"id=link4onMouseOver="ShowTip(event, 'tt4', 'link4')"onMouseOut="HideTip('tt4')">exclude</a></td><tdclass=SDescription>Array containing the variable names that should be ignored by the codec.</td></tr><trclass="SVariable SIndent2"><tdclass=SEntry><ahref="#mxObjectCodec.idrefs"id=link5onMouseOver="ShowTip(event, 'tt5', 'link5')"onMouseOut="HideTip('tt5')">idrefs</a></td><tdclass=SDescription>Array containing the variable names that should be turned into or converted from references. </td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxObjectCodec.mapping"id=link6onMouseOver="ShowTip(event, 'tt6', 'link6')"onMouseOut="HideTip('tt6')">mapping</a></td><tdclass=SDescription>Maps from from fieldnames to XML attribute names.</td></tr><trclass="SVariable SIndent2"><tdclass=SEntry><ahref="#mxObjectCodec.reverse"id=link7onMouseOver="ShowTip(event, 'tt7', 'link7')"onMouseOut="HideTip('tt7')">reverse</a></td><tdclass=SDescription>Maps from from XML attribute names to fieldnames.</td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxObjectCodec.Functions">Functions</a></td><tdclass=SDescription></td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxObjectCodec.getName"id=link8onMouseOver="ShowTip(event, 'tt8', 'link8')"onMouseOut="HideTip('tt8')">getName</a></td><tdclass=SDescription>Returns the name used for the nodenames and lookup of the codec when classes are encoded and nodes are decoded. </td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxObjectCodec.cloneTemplate"id=link9onMouseOver="ShowTip(event, 'tt9', 'link9')"onMouseOut="HideTip('tt9')">cloneTemplate</a></td><tdclass=SDescripti
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.mxObjectCodec"></a>mxObjectCodec</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>function mxObjectCodec(</td><tdclass=PParameternowrap>template,</td></tr><tr><td></td><tdclass=PParameternowrap>exclude,</td></tr><tr><td></td><tdclass=PParameternowrap>idrefs,</td></tr><tr><td></td><tdclass=PParameternowrap>mapping</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Constructs a new codec for the specified template object. The variables in the optional exclude array are ignored by the codec. Variables in the optional idrefs array are turned into references in the XML. The optional mapping may be used to map from variable names to XML attributes. The argument is created as follows:</p><blockquote><preclass="prettyprint">var mapping = new Object();
mapping['variableName'] = 'attribute-name';</pre></blockquote><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>template</td><tdclass=CDLDescription>Prototypical instance of the object to be encoded/decoded.</td></tr><tr><tdclass=CDLEntry>exclude</td><tdclass=CDLDescription>Optional array of fieldnames to be ignored.</td></tr><tr><tdclass=CDLEntry>idrefs</td><tdclass=CDLDescription>Optional array of fieldnames to be converted to/from references.</td></tr><tr><tdclass=CDLEntry>mapping</td><tdclass=CDLDescription>Optional mapping from field- to attributenames.</td></tr></table></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.allowEval"></a>allowEval</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.allowEval</td></tr></table></blockquote><p>Static global switch that specifies if expressions in arrays are allowed. Default is false. NOTE: Enabling this carries a possible security risk.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.template"></a>template</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.template</td></tr></table></blockquote><p>Holds the template object associated with this codec.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.exclude"></a>exclude</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.exclude</td></tr></table></blockquote><p>Array containing the variable names that should be ignored by the codec.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.idrefs"></a>idrefs</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.idrefs</td></tr></table></blockquote><p>Array containing the variable names that should be turned into or converted from references. See <ahref="mxCodec-js.html#mxCodec.getId"class=LFunctionid=link57onMouseOver="ShowTip(event, 'tt42', 'link57')"onMouseOut="HideTip('tt42')">mxCodec.getId</a> and <ahref="mxCodec-js.html#mxCodec.getObject"class=LFunctionid=link58onMouseOver="ShowTip(event, 'tt43', 'link58')"onMouseOut="HideTip('tt43')">mxCodec.getObject</a>.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.mapping"></a>mapping</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.mapping</td></tr></table></blockquote><p>Maps from from fieldnames to XML attribute names.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.reverse"></a>reverse</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.reverse</td></tr></table></blockquote><p>Maps from from XML attribute names to fieldnames.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.getName"></a>getName</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.getName = function()</td></tr></table></blockquote><p>Returns the name used for the nodenames and lookup of the codec when classes are encoded and nodes are decoded. For classes to work with this the codec registry automatically adds an alias for the classname if that is different than what this returns. The default implementation returns the classname of the template class.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.cloneTemplate"></a>cloneTemplate</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.cloneTemplate = function()</td></tr></table></blockquote><p>Returns a new instance of the template for this codec.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.getFieldName"></a>getFieldName</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.getFieldName = function(</td><tdclass=PParameternowrap>attributename</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the fieldname for the given attributename. Looks up the value in the <ahref="#mxObjectCodec.reverse"class=LVariableid=link59onMouseOver="ShowTip(event, 'tt7', 'link59')"onMouseOut="HideTip('tt7')">reverse</a> mapping or returns the input if there is no reverse mapping for the given name.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.getAttributeName"></a>getAttributeName</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.getAttributeName = function(</td><tdclass=PParameternowrap>fieldname</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the attributename for the given fieldname. Looks up the value in the <ahref="#mxObjectCodec.mapping"class=LVariableid=link60onMouseOver="ShowTip(event, 'tt6', 'link60')"onMouseOut="HideTip('tt6')">mapping</a> or returns the input if there is no mapping for the given name.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.isExcluded"></a>isExcluded</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.isExcluded = function(</td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>attr,</td></tr><tr><td></td><tdclass=PParameternowrap>value,</td></tr><tr><td></td><tdclass=PParameternowrap>write</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns true if the given attribute is to be ignored by the codec. This implementation returns true if the given fieldname is in <ahref="#mxObjectCodec.exclude"class=LVariableid=link61onMouseOver="ShowTip(event, 'tt4', 'link61')"onMouseOut="HideTip('tt4')">exclude</a> or if the fieldname equals <ahref="../util/mxObjectIdentity-js.html#mxObjectIdentity.FIELD_NAME"class=LVariableid=link62onMouseOver="ShowTip(event, 'tt44', 'link62')"onMouseOut="HideTip('tt44')">mxObjectIdentity.FIELD_NAME</a>.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object instance that contains the field.</td></tr><tr><tdclass=CDLEntry>attr</td><tdclass=CDLDescription>Fieldname of the field.</td></tr><tr><tdclass=CDLEntry>value</td><tdclass=CDLDescription>Value of the field.</td></tr><tr><tdclass=CDLEntry>write</td><tdclass=CDLDescription>Boolean indicating if the field is being encoded or decoded. Write is true if the field is being encoded, else it is being decoded.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.isReference"></a>isReference</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.isReference = function(</td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>attr,</td></tr><tr><td></td><tdclass=PParameternowrap>value,</td></tr><tr><td></td><tdclass=PParameternowrap>write</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns true if the given fieldname is to be treated as a textual reference (ID). This implementation returns true if the given fieldname is in <ahref="#mxObjectCodec.idrefs"class=LVariableid=link63onMouseOver="ShowTip(event, 'tt5', 'link63')"onMouseOut="HideTip('tt5')">idrefs</a>.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object instance that contains the field.</td></tr><tr><tdclass=CDLEntry>attr</td><tdclass=CDLDescription>Fieldname of the field.</td></tr><tr><tdclass=CDLEntry>value</td><tdclass=CDLDescription>Value of the field.</td></tr><tr><tdclass=CDLEntry>write</td><tdclass=CDLDescription>Boolean indicating if the field is being encoded or decoded. Write is true if the field is being encoded, else it is being decoded.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.encode"></a>encode</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.encode = function(</td><tdclass=PParameternowrap>enc,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Encodes the specified object and returns a node representing then given object. Calls <ahref="#mxObjectCodec.beforeEncode"class=LFunctionid=link64onMouseOver="ShowTip(event, 'tt24', 'link64')"onMouseOut="HideTip('tt24')">beforeEncode</a> after creating the node and <ahref="#mxObjectCodec.afterEncode"class=LFunctionid=link65onMouseOver="ShowTip(event, 'tt25', 'link65')"onMouseOut="HideTip('tt25')">afterEncode</a> with the resulting node after processing.</p><p>Enc is a reference to the calling encoder. It is used to encode complex objects and create references.</p><p>This implementation encodes all variables of an object according to the following rules:</p><ul><li>If the variable name is in <ahref="#mxObjectCodec.exclude"class=LVariableid=link66onMouseOver="ShowTip(event, 'tt4', 'link66')"onMouseOut="HideTip('tt4')">exclude</a> then it is ignored.</li><li>If the variable name is in <ahref="#mxObjectCodec.idrefs"class=LVariableid=link67onMouseOver="ShowTip(event, 'tt5', 'link67')"onMouseOut="HideTip('tt5')">idrefs</a> then <ahref="mxCodec-js.html#mxCodec.getId"class=LFunctionid=link68onMouseOver="ShowTip(event, 'tt42', 'link68')"onMouseOut="HideTip('tt42')">mxCodec.getId</a> is used to replace the object with its ID.</li><li>The variable name is mapped using <ahref="#mxObjectCodec.mapping"class=LVariableid=link69onMouseOver="ShowTip(event, 'tt6', 'link69')"onMouseOut="HideTip('tt6')">mapping</a>.</li><li>If obj is an array and the variable name is numeric (ie. an index) then it is not encoded.</li><li>If the value is an object, then the codec is used to create a child node with the variable name encoded into the “as” attribute.</li><li>Else, if <encodeDefaults> is true or the value differs from the template value, then ...</li><li>... if obj is not an array, then the value is mapped to an attribute.</li><li>... else if obj is an array, the value is mapped to an add child with a value attribute or a text child node, if the value is a function.</li></ul><p>If no ID exists for a variable in <ahref="#mxObjectCodec.idrefs"class=LVariableid=link70onMouseOver="ShowTip(event, 'tt5', 'link70')"onMouseOut="HideTip('tt5')">idrefs</a> or if an object cannot be encoded, a warning is issued using <ahref="../util/mxLog-js.html#mxLog.warn"class=LFunctionid=link71onMouseOver="ShowTip(event, 'tt45', 'link71')"onMouseOut="HideTip('tt45')">mxLog.warn</a>.</p><p>Returns the resulting XML node that represents the given object.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>enc</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link72onMouseOver="ShowTip(event, 'tt38', 'link72')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the encoding process.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object to be encoded.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.encodeObject"></a>encodeObject</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.encodeObject = function(</td><tdclass=PParameternowrap>enc,</td></tr><tr><td></td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>node</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Encodes the value of each member in then given obj into the given node using <ahref="#mxObjectCodec.encodeValue"class=LFunctionid=link73onMouseOver="ShowTip(event, 'tt16', 'link73')"onMouseOut="HideTip('tt16')">encodeValue</a>.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>enc</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link74onMouseOver="ShowTip(event, 'tt38', 'link74')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the encoding process.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object to be encoded.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node that contains the encoded object.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.encodeValue"></a>encodeValue</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.encodeValue = function(</td><tdclass=PParameternowrap>enc,</td></tr><tr><td></td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>name,</td></tr><tr><td></td><tdclass=PParameternowrap>value,</td></tr><tr><td></td><tdclass=PParameternowrap>node</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Converts the given value according to the mappings and id-refs in this codec and uses <ahref="#mxObjectCodec.writeAttribute"class=LFunctionid=link75onMouseOver="ShowTip(event, 'tt17', 'link75')"onMouseOut="HideTip('tt17')">writeAttribute</a> to write the attribute into the given node.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>enc</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link76onMouseOver="ShowTip(event, 'tt38', 'link76')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the encoding process.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object whose property is going to be encoded.</td></tr><tr><tdclass=CDLEntry>name</td><tdclass=CDLDescription>XML node that contains the encoded object.</td></tr><tr><tdclass=CDLEntry>value</td><tdclass=CDLDescription>Value of the property to be encoded.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node that contains the encoded object.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.writeAttribute"></a>writeAttribute</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.writeAttribute = function(</td><tdclass=PParameternowrap>enc,</td></tr><tr><td></td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>name,</td></tr><tr><td></td><tdclass=PParameternowrap>value,</td></tr><tr><td></td><tdclass=PParameternowrap>node</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Writes the given value into node using <ahref="#mxObjectCodec.writePrimitiveAttribute"class=LFunctionid=link77onMouseOver="ShowTip(event, 'tt18', 'link77')"onMouseOut="HideTip('tt18')">writePrimitiveAttribute</a> or <ahref="#mxObjectCodec.writeComplexAttribute"class=LFunctionid=link78onMouseOver="ShowTip(event, 'tt19', 'link78')"onMouseOut="HideTip('tt19')">writeComplexAttribute</a> depending on the type of the value.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.writePrimitiveAttribute"></a>writePrimitiveAttribute</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.writePrimitiveAttribute = function(</td><tdclass=PParameternowrap>enc,</td></tr><tr><td></td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>name,</td></tr><tr><td></td><tdclass=PParameternowrap>value,</td></tr><tr><td></td><tdclass=PParameternowrap>node</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Writes the given value as an attribute of the given node.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.writeComplexAttribute"></a>writeComplexAttribute</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.writeComplexAttribute = function(</td><tdclass=PParameternowrap>enc,</td></tr><tr><td></td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>name,</td></tr><tr><td></td><tdclass=PParameternowrap>value,</td></tr><tr><td></td><tdclass=PParameternowrap>node</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Writes the given value as a child node of the given node.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.convertAttributeToXml"></a>convertAttributeToXml</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.convertAttributeToXml = function(</td><tdclass=PParameternowrap>enc,</td></tr><tr><td></td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>name,</td></tr><tr><td></td><tdclass=PParameternowrap>value</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Converts true to “1” and false to “0” is <ahref="#mxObjectCodec.isBooleanAttribute"class=LFunctionid=link79onMouseOver="ShowTip(event, 'tt21', 'link79')"onMouseOut="HideTip('tt21')">isBooleanAttribute</a> returns true. All other values are not converted.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>enc</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link80onMouseOver="ShowTip(event, 'tt38', 'link80')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the encoding process.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Objec to convert the attribute for.</td></tr><tr><tdclass=CDLEntry>name</td><tdclass=CDLDescription>Name of the attribute to be converted.</td></tr><tr><tdclass=CDLEntry>value</td><tdclass=CDLDescription>Value to be converted.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.isBooleanAttribute"></a>isBooleanAttribute</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.isBooleanAttribute = function(</td><tdclass=PParameternowrap>enc,</td></tr><tr><td></td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>name,</td></tr><tr><td></td><tdclass=PParameternowrap>value</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns true if the given object attribute is a boolean value.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>enc</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link81onMouseOver="ShowTip(event, 'tt38', 'link81')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the encoding process.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Objec to convert the attribute for.</td></tr><tr><tdclass=CDLEntry>name</td><tdclass=CDLDescription>Name of the attribute to be converted.</td></tr><tr><tdclass=CDLEntry>value</td><tdclass=CDLDescription>Value of the attribute to be converted.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.convertAttributeFromXml"></a>convertAttributeFromXml</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.convertAttributeFromXml = function(</td><tdclass=PParameternowrap>dec,</td></tr><tr><td></td><tdclass=PParameternowrap>attr,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Converts booleans and numeric values to the respective types. Values are numeric if <ahref="#mxObjectCodec.isNumericAttribute"class=LFunctionid=link82onMouseOver="ShowTip(event, 'tt23', 'link82')"onMouseOut="HideTip('tt23')">isNumericAttribute</a> returns true.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>dec</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link83onMouseOver="ShowTip(event, 'tt38', 'link83')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the decoding process.</td></tr><tr><tdclass=CDLEntry>attr</td><tdclass=CDLDescription>XML attribute to be converted.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Objec to convert the attribute for.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.isNumericAttribute"></a>isNumericAttribute</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.isNumericAttribute = function(</td><tdclass=PParameternowrap>dec,</td></tr><tr><td></td><tdclass=PParameternowrap>attr,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns true if the given XML attribute is a numeric value.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>dec</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link84onMouseOver="ShowTip(event, 'tt38', 'link84')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the decoding process.</td></tr><tr><tdclass=CDLEntry>attr</td><tdclass=CDLDescription>XML attribute to be converted.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Objec to convert the attribute for.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.beforeEncode"></a>beforeEncode</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.beforeEncode = function(</td><tdclass=PParameternowrap>enc,</td></tr><tr><td></td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>node</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to pre-process the object before encoding. This returns the input object. The return value of this function is used in <ahref="#mxObjectCodec.encode"class=LFunctionid=link85onMouseOver="ShowTip(event, 'tt14', 'link85')"onMouseOut="HideTip('tt14')">encode</a> to perform the default encoding into the given node.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>enc</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link86onMouseOver="ShowTip(event, 'tt38', 'link86')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the encoding process.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object to be encoded.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to encode the object into.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.afterEncode"></a>afterEncode</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.afterEncode = function(</td><tdclass=PParameternowrap>enc,</td></tr><tr><td></td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>node</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to post-process the node for the given object after encoding and return the post-processed node. This implementation returns the input node. The return value of this method is returned to the encoder from <ahref="#mxObjectCodec.encode"class=LFunctionid=link87onMouseOver="ShowTip(event, 'tt14', 'link87')"onMouseOut="HideTip('tt14')">encode</a>.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>enc</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link88onMouseOver="ShowTip(event, 'tt38', 'link88')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the encoding process.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object to be encoded.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node that represents the default encoding.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.decode"></a>decode</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.decode = function(</td><tdclass=PParameternowrap>dec,</td></tr><tr><td></td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>into</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Parses the given node into the object or returns a new object representing the given node.</p><p>Dec is a reference to the calling decoder. It is used to decode complex objects and resolve references.</p><p>If a node has an id attribute then the object cache is checked for the object. If the object is not yet in the cache then it is constructed using the constructor of <ahref="#mxObjectCodec.template"class=LVariableid=link89onMouseOver="ShowTip(event, 'tt3', 'link89')"onMouseOut="HideTip('tt3')">template</a> and cached in <ahref="mxCodec-js.html#mxCodec.objects"class=LVariableid=link90onMouseOver="ShowTip(event, 'tt46', 'link90')"onMouseOut="HideTip('tt46')">mxCodec.objects</a>.</p><p>This implementation decodes all attributes and childs of a node according to the following rules:</p><ul><li>If the variable name is in <ahref="#mxObjectCodec.exclude"class=LVariableid=link91onMouseOver="ShowTip(event, 'tt4', 'link91')"onMouseOut="HideTip('tt4')">exclude</a> or if the attribute name is “id” or “as” then it is ignored.</li><li>If the variable name is in <ahref="#mxObjectCodec.idrefs"class=LVariableid=link92onMouseOver="ShowTip(event, 'tt5', 'link92')"onMouseOut="HideTip('tt5')">idrefs</a> then <ahref="mxCodec-js.html#mxCodec.getObject"class=LFunctionid=link93onMouseOver="ShowTip(event, 'tt43', 'link93')"onMouseOut="HideTip('tt43')">mxCodec.getObject</a> is used to replace the reference with an object.</li><li>The variable name is mapped using a reverse <ahref="#mxObjectCodec.mapping"class=LVariableid=link94onMouseOver="ShowTip(event, 'tt6', 'link94')"onMouseOut="HideTip('tt6')">mapping</a>.</li><li>If the value has a child node, then the codec is used to create a child object with the variable name taken from the “as” attribute.</li><li>If the object is an array and the variable name is empty then the value or child object is appended to the array.</li><li>If an add child has no value or the object is not an array then the child text content is evaluated using <ahref="../util/mxUtils-js.html#mxUtils.eval"class=LFunctionid=link95onMouseOver="ShowTip(event, 'tt47', 'link95')"onMouseOut="HideTip('tt47')">mxUtils.eval</a>.</li></ul><p>For add nodes where the object is not an array and the variable name is defined, the default mechanism is used, allowing to override/add methods as follows:</p><blockquote><preclass="prettyprint"><Object>
</Object></pre></blockquote><p>If no object exists for an ID in <ahref="#mxObjectCodec.idrefs"class=LVariableid=link96onMouseOver="ShowTip(event, 'tt5', 'link96')"onMouseOut="HideTip('tt5')">idrefs</a> a warning is issued using <ahref="../util/mxLog-js.html#mxLog.warn"class=LFunctionid=link97onMouseOver="ShowTip(event, 'tt45', 'link97')"onMouseOut="HideTip('tt45')">mxLog.warn</a>.</p><p>Returns the resulting object that represents the given XML node or the object given to the method as the into parameter.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>dec</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link98onMouseOver="ShowTip(event, 'tt38', 'link98')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the decoding process.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to be decoded.</td></tr><tr><tdclass=CDLEntry>into</td><tdclass=CDLDescription>Optional objec to encode the node into.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.decodeNode"></a>decodeNode</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.decodeNode = function(</td><tdclass=PParameternowrap>dec,</td></tr><tr><td></td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Calls <ahref="#mxObjectCodec.decodeAttributes"class=LFunctionid=link99onMouseOver="ShowTip(event, 'tt28', 'link99')"onMouseOut="HideTip('tt28')">decodeAttributes</a> and <ahref="#mxObjectCodec.decodeChildren"class=LFunctionid=link100onMouseOver="ShowTip(event, 'tt29', 'link100')"onMouseOut="HideTip('tt29')">decodeChildren</a> for the given node.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>dec</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link101onMouseOver="ShowTip(event, 'tt38', 'link101')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the decoding process.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to be decoded.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Objec to encode the node into.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.decodeAttributes"></a>decodeAttributes</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.decodeAttributes = function(</td><tdclass=PParameternowrap>dec,</td></tr><tr><td></td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Decodes all attributes of the given node using <ahref="#mxObjectCodec.decodeAttribute"class=LFunctionid=link102onMouseOver="ShowTip(event, 'tt30', 'link102')"onMouseOut="HideTip('tt30')">decodeAttribute</a>.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>dec</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link103onMouseOver="ShowTip(event, 'tt38', 'link103')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the decoding process.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to be decoded.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Objec to encode the node into.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.decodeAttribute"></a>decodeAttribute</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.decodeAttribute = function(</td><tdclass=PParameternowrap>dec,</td></tr><tr><td></td><tdclass=PParameternowrap>attr,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Reads the given attribute into the specified object.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>dec</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link104onMouseOver="ShowTip(event, 'tt38', 'link104')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the decoding process.</td></tr><tr><tdclass=CDLEntry>attr</td><tdclass=CDLDescription>XML attribute to be decoded.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Objec to encode the attribute into.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.decodeChildren"></a>decodeChildren</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.decodeChildren = function(</td><tdclass=PParameternowrap>dec,</td></tr><tr><td></td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Decodec all children of the given node using <ahref="#mxObjectCodec.decodeChild"class=LFunctionid=link105onMouseOver="ShowTip(event, 'tt31', 'link105')"onMouseOut="HideTip('tt31')">decodeChild</a>.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>dec</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link106onMouseOver="ShowTip(event, 'tt38', 'link106')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the decoding process.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to be decoded.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Objec to encode the node into.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.decodeChild"></a>decodeChild</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.decodeChild = function(</td><tdclass=PParameternowrap>dec,</td></tr><tr><td></td><tdclass=PParameternowrap>child,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Reads the specified child into the given object.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>dec</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link107onMouseOver="ShowTip(event, 'tt38', 'link107')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the decoding process.</td></tr><tr><tdclass=CDLEntry>child</td><tdclass=CDLDescription>XML child element to be decoded.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Objec to encode the node into.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.getFieldTemplate"></a>getFieldTemplate</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.getFieldTemplate = function(</td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>fieldname,</td></tr><tr><td></td><tdclass=PParameternowrap>child</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the template instance for the given field. This returns the value of the field, null if the value is an array or an empty collection if the value is a collection. The value is then used to populate the field for a new instance. For strongly typed languages it may be required to override this to return the correct collection instance based on the encoded child.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.addObjectValue"></a>addObjectValue</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.addObjectValue = function(</td><tdclass=PParameternowrap>obj,</td></tr><tr><td></td><tdclass=PParameternowrap>fieldname,</td></tr><tr><td></td><tdclass=PParameternowrap>value,</td></tr><tr><td></td><tdclass=PParameternowrap>template</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Sets the decoded child node as a value of the given object. If the object is a map, then the value is added with the given fieldname as a key. If the fieldname is not empty, then setFieldValue is called or else, if the object is a collection, the value is added to the collection. For strongly typed languages it may be required to override this with the correct code to add an entry to an object.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.processInclude"></a>processInclude</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.processInclude = function(</td><tdclass=PParameternowrap>dec,</td></tr><tr><td></td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>into</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns true if the given node is an include directive and executes the include by decoding the XML document. Returns false if the given node is not an include directive.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>dec</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link108onMouseOver="ShowTip(event, 'tt38', 'link108')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the encoding/decoding process.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to be checked.</td></tr><tr><tdclass=CDLEntry>into</td><tdclass=CDLDescription>Optional object to pass-thru to the codec.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.beforeDecode"></a>beforeDecode</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.beforeDecode = function(</td><tdclass=PParameternowrap>dec,</td></tr><tr><td></td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to pre-process the node for the specified object and return the node to be used for further processing by <ahref="#mxObjectCodec.decode"class=LFunctionid=link109onMouseOver="ShowTip(event, 'tt26', 'link109')"onMouseOut="HideTip('tt26')">decode</a>. The object is created based on the template in the calling method and is never null. This implementation returns the input node. The return value of this function is used in <ahref="#mxObjectCodec.decode"class=LFunctionid=link110onMouseOver="ShowTip(event, 'tt26', 'link110')"onMouseOut="HideTip('tt26')">decode</a> to perform the default decoding into the given object.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>dec</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link111onMouseOver="ShowTip(event, 'tt38', 'link111')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the decoding process.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to be decoded.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object to encode the node into.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxObjectCodec.afterDecode"></a>afterDecode</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.afterDecode = function(</td><tdclass=PParameternowrap>dec,</td></tr><tr><td></td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to post-process the object after decoding. This implementation returns the given object without any changes. The return value of this method is returned to the decoder from <ahref="#mxObjectCodec.decode"class=LFunctionid=link112onMouseOver="ShowTip(event, 'tt26', 'link112')"onMouseOut="HideTip('tt26')">decode</a>.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>enc</td><tdclass=CDLDescription><ahref="mxCodec-js.html#mxCodec"class=LClassid=link113onMouseOver="ShowTip(event, 'tt38', 'link113')"onMouseOut="HideTip('tt38')">mxCodec</a> that controls the encoding process.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to be decoded.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object that represents the default decoding.</td></tr></table></div></div></div>
<divclass=CToolTipid="tt1"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>function mxObjectCodec(</td><tdclass=PParameternowrap>template,</td></tr><tr><td></td><tdclass=PParameternowrap>exclude,</td></tr><tr><td></td><tdclass=PParameternowrap>idrefs,</td></tr><tr><td></td><tdclass=PParameternowrap>mapping</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Constructs a new codec for the specified template object. </div></div><divclass=CToolTipid="tt2"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.allowEval</td></tr></table></blockquote>Static global switch that specifies if expressions in arrays are allowed. </div></div><divclass=CToolTipid="tt3"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.template</td></tr></table></blockquote>Holds the template object associated with this codec.</div></div><divclass=CToolTipid="tt4"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.exclude</td></tr></table></blockquote>Array containing the variable names that should be ignored by the codec.</div></div><divclass=CToolTipid="tt5"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.idrefs</td></tr></table></blockquote>Array containing the variable names that should be turned into or converted from references. </div></div><divclass=CToolTipid="tt6"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.mapping</td></tr></table></blockquote>Maps from from fieldnames to XML attribute names.</div></div><divclass=CToolTipid="tt7"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.reverse</td></tr></table></blockquote>Maps from from XML attribute names to fieldnames.</div></div><divclass=CToolTipid="tt8"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.getName = function()</td></tr></table></blockquote>Returns the name used for the nodenames and lookup of the codec when classes are encoded and nodes are decoded. </div></div><divclass=CToolTipid="tt9"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxObjectCodec.prototype.cloneTemplate = function()</td></tr></table></blockquote>Returns a new instance of the template for this codec.</div></div><divclass=CToolTipid="tt10"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.getFieldName = function(</td><tdclass=PParameternowrap>attributename</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Returns the fieldname for the given attributename. </div></div><divclass=CToolTipid="tt11"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxObjectCodec.prototype.getAttributeName = function(</td><tdclass=PParameternowrap>fieldname</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Returns the attributename for the given fieldname. </div></div><divclass=CToolTipid="tt12"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><td