/** * Function: encode * * Encodes the specified object and returns the resulting * XML node. * * Parameters: * * obj - Object to be encoded. */ function encode($obj) { $node = null; if (is_object($obj) || is_array($obj)) { if (is_array($obj)) { $enc = new mxObjectCodec(array()); } else { $enc = mxCodecRegistry::getCodec(mxCodecRegistry::getName($obj)); } if (isset($enc)) { $node = $enc->encode($this, $obj); } else { if (get_class($obj) == "DOMElement") { $node = $obj->cloneNode(true); } else { mxLog::warn("mxCodec.encode: No codec for " . mxCodecRegistry::getName($obj)); } } } return $node; }
/** * Function: decodeAttribute * * Reads the given attribute into the specified object. */ function decodeAttribute($dec, $attr, &$obj) { $name = $attr->nodeName; if ($name != "as" && $name != "id") { // Converts the string true and false to their boolean values. // This may require an additional check on the obj to see if // the existing field is a boolean value or uninitialized, in // which case we may want to convert true and false to a string. $value = $this->convertValueFromXml($attr->nodeValue); $fieldname = $this->getFieldName($name); if ($this->isReference($obj, $fieldname, $value, false)) { $tmp = $dec->getObject($value); if (!isset($tmp)) { mxLog::warn("mxObjectCodec.decode: No object for " . $this->getName() . ".{$fieldname}={$value}"); return; // exit } $value = $tmp; } if (!$this->isExcluded($obj, $fieldname, $value, false)) { //mxLog.debug(mxCodecRegistry::getName($obj)."$name=$value"); $obj->{$fieldname} = $value; } } }