/* * Decompiled with CFR 0.152. * * Could not load the following classes: * net.n3.nanoxml.IXMLElement * net.n3.nanoxml.XMLAttribute * net.n3.nanoxml.XMLElement */ package net.n3.nanoxml; import java.io.Serializable; import java.util.Enumeration; import java.util.Properties; import java.util.Vector; import net.n3.nanoxml.IXMLElement; import net.n3.nanoxml.XMLAttribute; public class XMLElement implements IXMLElement, Serializable { static final long serialVersionUID = -2383376380548624920L; public static final int NO_LINE = -1; private IXMLElement parent; private Vector attributes = new Vector(); private Vector children = new Vector(8); private String name; private String fullName; private String namespace; private String content; private String systemID; private int lineNr; public XMLElement() { this(null, null, null, -1); } public XMLElement(String string) { this(string, null, null, -1); } public XMLElement(String string, String string2, int n) { this(string, null, string2, n); } public XMLElement(String string, String string2) { this(string, string2, null, -1); } public XMLElement(String string, String string2, String string3, int n) { int n2; this.fullName = string; this.name = string2 == null ? string : ((n2 = string.indexOf(58)) >= 0 ? string.substring(n2 + 1) : string); this.namespace = string2; this.content = null; this.lineNr = n; this.systemID = string3; this.parent = null; } public IXMLElement createPCDataElement() { return new XMLElement(); } public IXMLElement createElement(String string) { return new XMLElement(string); } public IXMLElement createElement(String string, String string2, int n) { return new XMLElement(string, string2, n); } public IXMLElement createElement(String string, String string2) { return new XMLElement(string, string2); } public IXMLElement createElement(String string, String string2, String string3, int n) { return new XMLElement(string, string2, string3, n); } protected void finalize() throws Throwable { this.attributes.clear(); this.attributes = null; this.children = null; this.fullName = null; this.name = null; this.namespace = null; this.content = null; this.systemID = null; this.parent = null; super.finalize(); } public IXMLElement getParent() { return this.parent; } public String getFullName() { return this.fullName; } public String getName() { return this.name; } public String getNamespace() { return this.namespace; } public void setName(String string) { this.name = string; this.fullName = string; this.namespace = null; } public void setName(String string, String string2) { int n = string.indexOf(58); this.name = string2 == null || n < 0 ? string : string.substring(n + 1); this.fullName = string; this.namespace = string2; } public void addChild(IXMLElement iXMLElement) { IXMLElement iXMLElement2; if (iXMLElement == null) { throw new IllegalArgumentException("child must not be null"); } if (iXMLElement.getName() == null && !this.children.isEmpty() && (iXMLElement2 = (IXMLElement)this.children.lastElement()).getName() == null) { iXMLElement2.setContent(iXMLElement2.getContent() + iXMLElement.getContent()); return; } ((XMLElement)iXMLElement).parent = this; this.children.addElement(iXMLElement); } public void insertChild(IXMLElement iXMLElement, int n) { IXMLElement iXMLElement2; if (iXMLElement == null) { throw new IllegalArgumentException("child must not be null"); } if (iXMLElement.getName() == null && !this.children.isEmpty() && (iXMLElement2 = (IXMLElement)this.children.lastElement()).getName() == null) { iXMLElement2.setContent(iXMLElement2.getContent() + iXMLElement.getContent()); return; } ((XMLElement)iXMLElement).parent = this; this.children.insertElementAt(iXMLElement, n); } public void removeChild(IXMLElement iXMLElement) { if (iXMLElement == null) { throw new IllegalArgumentException("child must not be null"); } this.children.removeElement(iXMLElement); } public void removeChildAtIndex(int n) { this.children.removeElementAt(n); } public Enumeration enumerateChildren() { return this.children.elements(); } public boolean isLeaf() { return this.children.isEmpty(); } public boolean hasChildren() { return !this.children.isEmpty(); } public int getChildrenCount() { return this.children.size(); } public Vector getChildren() { return this.children; } public IXMLElement getChildAtIndex(int n) throws ArrayIndexOutOfBoundsException { return (IXMLElement)this.children.elementAt(n); } public IXMLElement getFirstChildNamed(String string) { Enumeration enumeration = this.children.elements(); while (enumeration.hasMoreElements()) { IXMLElement iXMLElement = (IXMLElement)enumeration.nextElement(); String string2 = iXMLElement.getFullName(); if (string2 == null || !string2.equals(string)) continue; return iXMLElement; } return null; } public IXMLElement getFirstChildNamed(String string, String string2) { Enumeration enumeration = this.children.elements(); while (enumeration.hasMoreElements()) { IXMLElement iXMLElement = (IXMLElement)enumeration.nextElement(); String string3 = iXMLElement.getName(); boolean bl = string3 != null && string3.equals(string); string3 = iXMLElement.getNamespace(); bl = string3 == null ? (bl &= string == null) : (bl &= string3.equals(string2)); if (!bl) continue; return iXMLElement; } return null; } public Vector getChildrenNamed(String string) { Vector vector = new Vector(this.children.size()); Enumeration enumeration = this.children.elements(); while (enumeration.hasMoreElements()) { IXMLElement iXMLElement = (IXMLElement)enumeration.nextElement(); String string2 = iXMLElement.getFullName(); if (string2 == null || !string2.equals(string)) continue; vector.addElement(iXMLElement); } return vector; } public Vector getChildrenNamed(String string, String string2) { Vector vector = new Vector(this.children.size()); Enumeration enumeration = this.children.elements(); while (enumeration.hasMoreElements()) { IXMLElement iXMLElement = (IXMLElement)enumeration.nextElement(); String string3 = iXMLElement.getName(); boolean bl = string3 != null && string3.equals(string); string3 = iXMLElement.getNamespace(); bl = string3 == null ? (bl &= string == null) : (bl &= string3.equals(string2)); if (!bl) continue; vector.addElement(iXMLElement); } return vector; } private XMLAttribute findAttribute(String string) { Enumeration enumeration = this.attributes.elements(); while (enumeration.hasMoreElements()) { XMLAttribute xMLAttribute = (XMLAttribute)enumeration.nextElement(); if (!xMLAttribute.getFullName().equalsIgnoreCase(string)) continue; return xMLAttribute; } return null; } private XMLAttribute findAttribute(String string, String string2) { Enumeration enumeration = this.attributes.elements(); while (enumeration.hasMoreElements()) { XMLAttribute xMLAttribute = (XMLAttribute)enumeration.nextElement(); boolean bl = xMLAttribute.getName().equals(string); bl = string2 == null ? (bl &= xMLAttribute.getNamespace() == null) : (bl &= string2.equalsIgnoreCase(xMLAttribute.getNamespace())); if (!bl) continue; return xMLAttribute; } return null; } public int getAttributeCount() { return this.attributes.size(); } public String getAttribute(String string) { return this.getAttribute(string, null); } public String getAttribute(String string, String string2) { XMLAttribute xMLAttribute = this.findAttribute(string); if (xMLAttribute == null) { return string2; } return xMLAttribute.getValue(); } public String getAttribute(String string, String string2, String string3) { XMLAttribute xMLAttribute = this.findAttribute(string, string2); if (xMLAttribute == null) { return string3; } return xMLAttribute.getValue(); } public int getAttribute(String string, int n) { String string2 = this.getAttribute(string, Integer.toString(n)); return Integer.parseInt(string2); } public int getAttribute(String string, String string2, int n) { String string3 = this.getAttribute(string, string2, Integer.toString(n)); return Integer.parseInt(string3); } public String getAttributeType(String string) { XMLAttribute xMLAttribute = this.findAttribute(string); if (xMLAttribute == null) { return null; } return xMLAttribute.getType(); } public String getAttributeNamespace(String string) { XMLAttribute xMLAttribute = this.findAttribute(string); if (xMLAttribute == null) { return null; } return xMLAttribute.getNamespace(); } public String getAttributeType(String string, String string2) { XMLAttribute xMLAttribute = this.findAttribute(string, string2); if (xMLAttribute == null) { return null; } return xMLAttribute.getType(); } public void setAttribute(String string, String string2) { XMLAttribute xMLAttribute = this.findAttribute(string); if (xMLAttribute == null) { xMLAttribute = new XMLAttribute(string, string, null, string2, "CDATA"); this.attributes.addElement(xMLAttribute); } else { xMLAttribute.setValue(string2); } } public void setAttribute(String string, String string2, String string3) { int n = string.indexOf(58); String string4 = string.substring(n + 1); XMLAttribute xMLAttribute = this.findAttribute(string4, string2); if (xMLAttribute == null) { xMLAttribute = new XMLAttribute(string, string4, string2, string3, "CDATA"); this.attributes.addElement(xMLAttribute); } else { xMLAttribute.setValue(string3); } } public void removeAttribute(String string) { for (int i = 0; i < this.attributes.size(); ++i) { XMLAttribute xMLAttribute = (XMLAttribute)this.attributes.elementAt(i); if (!xMLAttribute.getFullName().equals(string)) continue; this.attributes.removeElementAt(i); return; } } public void removeAttribute(String string, String string2) { for (int i = 0; i < this.attributes.size(); ++i) { XMLAttribute xMLAttribute = (XMLAttribute)this.attributes.elementAt(i); boolean bl = xMLAttribute.getName().equals(string); bl = string2 == null ? (bl &= xMLAttribute.getNamespace() == null) : (bl &= xMLAttribute.getNamespace().equals(string2)); if (!bl) continue; this.attributes.removeElementAt(i); return; } } public Enumeration enumerateAttributeNames() { Vector vector = new Vector(); Enumeration enumeration = this.attributes.elements(); while (enumeration.hasMoreElements()) { XMLAttribute xMLAttribute = (XMLAttribute)enumeration.nextElement(); vector.addElement(xMLAttribute.getFullName()); } return vector.elements(); } public boolean hasAttribute(String string) { return this.findAttribute(string) != null; } public boolean hasAttribute(String string, String string2) { return this.findAttribute(string, string2) != null; } public Properties getAttributes() { Properties properties = new Properties(); Enumeration enumeration = this.attributes.elements(); while (enumeration.hasMoreElements()) { XMLAttribute xMLAttribute = (XMLAttribute)enumeration.nextElement(); properties.put(xMLAttribute.getFullName(), xMLAttribute.getValue()); } return properties; } public Properties getAttributesInNamespace(String string) { Properties properties = new Properties(); Enumeration enumeration = this.attributes.elements(); while (enumeration.hasMoreElements()) { XMLAttribute xMLAttribute = (XMLAttribute)enumeration.nextElement(); if (string == null) { if (xMLAttribute.getNamespace() != null) continue; properties.put(xMLAttribute.getName(), xMLAttribute.getValue()); continue; } if (!string.equals(xMLAttribute.getNamespace())) continue; properties.put(xMLAttribute.getName(), xMLAttribute.getValue()); } return properties; } public String getSystemID() { return this.systemID; } public int getLineNr() { return this.lineNr; } public String getContent() { return this.content; } public void setContent(String string) { this.content = string; } public boolean equals(Object object) { try { return this.equalsXMLElement((IXMLElement)object); } catch (ClassCastException classCastException) { return false; } } public boolean equalsXMLElement(IXMLElement iXMLElement) { Object object; Object object2; if (!this.name.equals(iXMLElement.getName())) { return false; } if (this.attributes.size() != iXMLElement.getAttributeCount()) { return false; } Enumeration enumeration = this.attributes.elements(); while (enumeration.hasMoreElements()) { XMLAttribute xMLAttribute = (XMLAttribute)enumeration.nextElement(); if (!iXMLElement.hasAttribute(xMLAttribute.getName(), xMLAttribute.getNamespace())) { return false; } object2 = iXMLElement.getAttribute(xMLAttribute.getName(), xMLAttribute.getNamespace(), null); if (!xMLAttribute.getValue().equals(object2)) { return false; } object = iXMLElement.getAttributeType(xMLAttribute.getName(), xMLAttribute.getNamespace()); if (xMLAttribute.getType().equals(object)) continue; return false; } if (this.children.size() != iXMLElement.getChildrenCount()) { return false; } for (int i = 0; i < this.children.size(); ++i) { object2 = this.getChildAtIndex(i); if (object2.equalsXMLElement(object = iXMLElement.getChildAtIndex(i))) continue; return false; } return true; } }