{
Element inner = (Element) node;
if (obj instanceof mxCell)
{
mxCell cell = (mxCell) obj;
String classname = getName();
String nodeName = node.getNodeName();
// Handles aliased names
if (!nodeName.equals(classname))
{
String tmp = mxCodecRegistry.aliases.get(nodeName);
if (tmp != null)
{
nodeName = tmp;
}
}
if (!nodeName.equals(classname))
{
// Passes the inner graphical annotation node to the
// object codec for further processing of the cell.
Node tmp = inner.getElementsByTagName(classname).item(0);
if (tmp != null && tmp.getParentNode() == node)
{
inner = (Element) tmp;
// Removes annotation and whitespace from node
Node tmp2 = tmp.getPreviousSibling();
while (tmp2 != null && tmp2.getNodeType() == Node.TEXT_NODE)
{
Node tmp3 = tmp2.getPreviousSibling();
if (tmp2.getTextContent().trim().length() == 0)
{
tmp2.getParentNode().removeChild(tmp2);
}
tmp2 = tmp3;
}
// Removes more whitespace
tmp2 = tmp.getNextSibling();
while (tmp2 != null && tmp2.getNodeType() == Node.TEXT_NODE)
{
Node tmp3 = tmp2.getPreviousSibling();
if (tmp2.getTextContent().trim().length() == 0)
{
tmp2.getParentNode().removeChild(tmp2);
}
tmp2 = tmp3;
}
tmp.getParentNode().removeChild(tmp);
}
else
{
inner = null;
}
// Creates the user object out of the XML node
Element value = (Element) node.cloneNode(true);
cell.setValue(value);
String id = value.getAttribute("id");
if (id != null)
{
cell.setId(id);
value.removeAttribute("id");
}
}
else
{
cell.setId(((Element) node).getAttribute("id"));
}
// Preprocesses and removes all Id-references
// in order to use the correct encoder (this)
// for the known references to cells (all).