<divid=Content><divclass="CClass"><divclass=CTopicid=MainTopic><h1class=CTitle><aname="mxCodecRegistry"></a>mxCodecRegistry</h1><divclass=CBody><p>Singleton class that acts as a global registry for codecs.</p><h4class=CHeading>Adding an <ahref="mxCodec-js.html#mxCodec"class=LClassid=link6onMouseOver="ShowTip(event, 'tt6', 'link6')"onMouseOut="HideTip('tt6')">mxCodec</a></h4><p>1. Define a default codec with a new instance of the object to be handled.</p><blockquote><preclass="prettyprint">var codec = new mxObjectCodec(new mxGraphModel());</pre></blockquote><p>2. Define the functions required for encoding and decoding objects.</p><blockquote><preclass="prettyprint">codec.encode = function(enc, obj) { ... }
codec.decode = function(dec, node, into) { ... }</pre></blockquote><p>3. Register the codec in the <ahref="#mxCodecRegistry"class=LClassid=link7onMouseOver="ShowTip(event, 'tt7', 'link7')"onMouseOut="HideTip('tt7')">mxCodecRegistry</a>.</p><blockquote><preclass="prettyprint">mxCodecRegistry.register(codec);</pre></blockquote><p><ahref="mxObjectCodec-js.html#mxObjectCodec.decode"class=LFunctionid=link8onMouseOver="ShowTip(event, 'tt8', 'link8')"onMouseOut="HideTip('tt8')">mxObjectCodec.decode</a> may be used to either create a new instance of an object or to configure an existing instance, in which case the into argument points to the existing object. In this case, we say the codec “configures” the object.</p><!--START_ND_SUMMARY--><divclass=Summary><divclass=STitle>Summary</div><divclass=SBorder><tableborder=0cellspacing=0cellpadding=0class=STable><trclass="SMain"><tdclass=SEntry><ahref="#mxCodecRegistry">mxCodecRegistry</a></td><tdclass=SDescription>Singleton class that acts as a global registry for codecs.</td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxCodecRegistry.Variables">Variables</a></td><tdclass=SDescription></td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodecRegistry.codecs"id=link1onMouseOver="ShowTip(event, 'tt1', 'link1')"onMouseOut="HideTip('tt1')">codecs</a></td><tdclass=SDescription>Maps from constructor names to codecs.</td></tr><trclass="SVariable SIndent2"><tdclass=SEntry><ahref="#mxCodecRegistry.aliases"id=link2onMouseOver="ShowTip(event, 'tt2', 'link2')"onMouseOut="HideTip('tt2')">aliases</a></td><tdclass=SDescription>Maps from classnames to codecnames.</td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxCodecRegistry.Functions">Functions</a></td><tdclass=SDescription></td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodecRegistry.register"id=link3onMouseOver="ShowTip(event, 'tt3', 'link3')"onMouseOut="HideTip('tt3')">register</a></td><tdclass=SDescription>Registers a new codec and associates the name of the template constructor in the codec with the codec object.</td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxCodecRegistry.addAlias"id=link4onMouseOver="ShowTip(event, 'tt4', 'link4')"onMouseOut="HideTip('tt4')">addAlias</a></td><tdclass=SDescription>Adds an alias for mapping a classname to a codecname.</td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodecRegistry.getCodec"id=link5onMouseOver="ShowTip(event, 'tt5', 'link5')"onMouseOut="HideTip('tt5')">getCodec</a></td><tdclass=SDescription>Returns a codec that handles objects that are constructed using the given constructor.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxCodecRegistry.codecs"></a>codecs</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">codecs: []</td></tr></table></blockquote><p>Maps from constructor names to codecs.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxCodecRegistry.aliases"></a>aliases</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">aliases: []</td></tr></table></blockquote><p>Maps from classnames to codecnames.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodecRegistry.register"></a>register</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>register: function(</td><tdclass="PParameter prettyprint "nowrap>codec</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Registers a new codec and associates the name of the template constructor in the codec with the codec object.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>codec</td><tdclass=CDLDescription><ahref="mxObjectCodec-js.html#mxObjectCodec"class=LClassid=link9onMouseOver="ShowTip(event, 'tt9', 'link9')"onMouseOut="HideTip('tt9')">mxObjectCodec</a> to be registered.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodecRegistry.addAlias"></a>addAlias</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>addAlias: function(</td><tdclass="PParameter prettyprint "nowrap>classname,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>codecname</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Adds an alias for mapping a classname to a codecname.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodecRegistry.getCodec"></a>getCodec</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>getCodec: function(</td><tdclass="PParameter prettyprint "nowrap>ctor</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns a codec that handles objects that are constructed using the given constructor.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>ctor</td><tdclass=CDLDescription>JavaScript constructor function.</td></tr></table></div></div></div>
<divclass=CToolTipid="tt1"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">codecs: []</td></tr></table></blockquote>Maps from constructor names to codecs.</div></div><divclass=CToolTipid="tt2"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">aliases: []</td></tr></table></blockquote>Maps from classnames to codecnames.</div></div><divclass=CToolTipid="tt3"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>register: function(</td><tdclass="PParameter prettyprint "nowrap>codec</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Registers a new codec and associates the name of the template constructor in the codec with the codec object.</div></div><divclass=CToolTipid="tt4"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>addAlias: function(</td><tdclass="PParameter prettyprint "nowrap>classname,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>codecname</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Adds an alias for mapping a classname to a codecname.</div></div><divclass=CToolTipid="tt5"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>getCodec: function(</td><tdclass="PParameter prettyprint "nowrap>ctor</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Returns a codec that handles objects that are constructed using the given constructor.</div></div><divclass=CToolTipid="tt6"><divclass=CClass>XML codec for JavaScript object graphs. </div></div><divclass=CToolTipid="tt7"><divclass=CClass>Singleton class that acts as a global registry for codecs.</div></div><divclass=CToolTipid="tt8"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>mxObjectCodec.prototype.decode = function(</td><tdclass="PParameter prettyprint "nowrap>dec,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>node,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>into</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Parses the given node into the object or returns a new object representing the given node.</div></div><divclass=CToolTipid="tt9"><divclass=CClass>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.</div></div><!--END_ND_TOOLTIPS-->