<!-- saved from url=(0026)http://www.naturaldocs.org -->
<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=link4onMouseOver="ShowTip(event, 'tt4', 'link4')"onMouseOut="HideTip('tt4')">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=link5onMouseOver="ShowTip(event, 'tt5', 'link5')"onMouseOut="HideTip('tt5')">mxCodecRegistry</a>.</p><blockquote><preclass="prettyprint">mxCodecRegistry.register(codec);</pre></blockquote><p><ahref="mxObjectCodec-js.html#mxObjectCodec.decode"class=LFunctionid=link6onMouseOver="ShowTip(event, 'tt6', 'link6')"onMouseOut="HideTip('tt6')">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">codecs</a></td><tdclass=SDescription>Maps from constructor names to codecs.</td></tr><trclass="SVariable SIndent2"><tdclass=SEntry><ahref="#mxCodecRegistry.aliases">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=link1onMouseOver="ShowTip(event, 'tt1', 'link1')"onMouseOut="HideTip('tt1')">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=link2onMouseOver="ShowTip(event, 'tt2', 'link2')"onMouseOut="HideTip('tt2')">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=link3onMouseOver="ShowTip(event, 'tt3', 'link3')"onMouseOut="HideTip('tt3')">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><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><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 prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>register: function(</td><tdclass=PParameternowrap>codec</td><tdclass=PAfterParametersnowrap>)</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=link7onMouseOver="ShowTip(event, 'tt7', 'link7')"onMouseOut="HideTip('tt7')">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 prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>addAlias: function(</td><tdclass=PParameternowrap>classname,</td></tr><tr><td></td><tdclass=PParameternowrap>codecname</td><tdclass=PAfterParametersnowrap>)</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 prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>getCodec: function(</td><tdclass=PParameternowrap>ctor</td><tdclass=PAfterParametersnowrap>)</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>
</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>register: function(</td><tdclass=PParameternowrap>codec</td><tdclass=PAfterParametersnowrap>)</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="tt2"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>addAlias: function(</td><tdclass=PParameternowrap>classname,</td></tr><tr><td></td><tdclass=PParameternowrap>codecname</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Adds an alias for mapping a classname to a codecname.</div></div><divclass=CToolTipid="tt3"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>getCodec: function(</td><tdclass=PParameternowrap>ctor</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Returns a codec that handles objects that are constructed using the given constructor.</div></div><divclass=CToolTipid="tt4"><divclass=CClass>XML codec for JavaScript object graphs. </div></div><divclass=CToolTipid="tt5"><divclass=CClass>Singleton class that acts as a global registry for codecs.</div></div><divclass=CToolTipid="tt6"><divclass=CFunction><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>Parses the given node into the object or returns a new object representing the given node.</div></div><divclass=CToolTipid="tt7"><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-->