home *** CD-ROM | disk | FTP | other *** search
Wrap
package com.ibm.xml.parser; import java.io.StringWriter; import org.w3c.dom.Attr; import org.w3c.dom.DOMException; import org.w3c.dom.EntityReference; import org.w3c.dom.Node; import org.w3c.dom.Text; public class TXAttribute extends Parent implements Attr, Namespace { static final long serialVersionUID = 710791704404680525L; String name; String value; int type = 0; String[] typedValue; boolean specified = false; public TXAttribute(String var1, String var2) { this.name = var1; this.value = var2; this.specified = true; } public Object clone() { return this.cloneNode(true); } public synchronized Node cloneNode(boolean var1) { ((Child)this).checkFactory(); TXAttribute var2 = (TXAttribute)super.factory.createAttribute(this.name); ((Child)var2).setFactory(((Child)this).getFactory()); if (var1) { var2.children.ensureCapacity(super.children.getLength()); for(int var3 = 0; var3 < super.children.getLength(); ++var3) { ((Parent)var2).insertBefore(super.children.item(var3).cloneNode(true), (Node)null); } } var2.setType(this.getType(), this.getTypedValue()); var2.setSpecified(this.getSpecified()); return var2; } public synchronized boolean equals(Node var1, boolean var2) { if (var1 == null) { return false; } else if (!(var1 instanceof TXAttribute)) { return false; } else { TXAttribute var3 = (TXAttribute)var1; if (!var3.getName().equals(this.getName())) { return false; } else if (!var3.getValue().equals(this.getValue())) { return false; } else { return !var2 || var3.children.equals(super.children, var2); } } } public short getNodeType() { return 2; } public String getNodeName() { return this.name; } public String getName() { return this.name; } public String getValue() { if (this.value != null) { return this.value; } else { this.value = ((Parent)this).getText(); return this.value; } } public String getNodeValue() { return this.getValue(); } public String toString() { return this.getValue(); } public void setValue(String var1) { this.setNodeValue(var1); } public void setNodeValue(String var1) { this.value = var1; if (var1 != null) { TXNodeList var2 = super.children; synchronized(var2){} try { while(((Parent)this).getFirstChild() != null) { this.removeChild(((Parent)this).getFirstChild()); } ((Child)this).checkFactory(); ((Parent)this).appendChild(super.factory.createAttributeValue(var1)); } catch (Throwable var4) { throw var4; } } ((Child)this).clearDigest(); } protected void realInsert(Node var1, int var2) throws LibraryException { if (!(var1 instanceof Text) && !(var1 instanceof EntityReference)) { throw new TXDOMException((short)3, "com.ibm.xml.parser.TXAttribute#realInsert(): Nodes except Text/EntityReference are not allowed as attribute children."); } else { super.realInsert(var1, var2); this.value = null; } } public Node replaceChild(Node var1, Node var2) throws DOMException { if (!(var1 instanceof Text) && !(var1 instanceof EntityReference)) { throw new TXDOMException((short)3, "com.ibm.xml.parser.TXAttribute#realInsert(): Nodes except Text/EntityReference are not allowed as attribute children."); } else { this.value = null; return super.replaceChild(var1, var2); } } public Node removeChild(Node var1) throws DOMException { this.value = null; return super.removeChild(var1); } public boolean getSpecified() { return this.specified; } public void setSpecified(boolean var1) { this.specified = var1; } public String getNSLocalName() { return TXElement.getLocalNameForQName(this.getNodeName()); } public String getNSName() { Node var1 = super.parent; if (var1 == null) { new LibraryException("This attribute isn't assigned to any Element."); } return this.getNodeName().indexOf(58) < 0 ? null : ((TXElement)var1).getNamespaceForQName(this.getNodeName()); } /** @deprecated */ public String getUniversalName() { return this.getNSName() == null ? this.getNSLocalName() : this.getNSName() + ":" + this.getNSLocalName(); } public String createExpandedName() { if ("xmlns".equals(this.getNodeName())) { return "xmlns"; } else { String var1 = this.getNSName(); return var1 != null && var1.length() != 0 ? var1 + ((Child)this).getFactory().expandedNameSeparator + this.getNSLocalName() : ((TXElement)super.parent).createExpandedName() + ((Child)this).getFactory().expandedNameSeparator + this.getNodeName(); } } public int getType() { return this.type; } public String[] getTypedValue() { return this.typedValue; } public void setType(int var1, String[] var2) { this.type = var1; this.typedValue = var2; this.value = normalize(var1, this.getValue()); } public String toXMLString(String var1) { String var2 = null; try { StringWriter var3 = new StringWriter(); ToXMLStringVisitor var4 = new ToXMLStringVisitor(var3, var1); (new NonRecursivePreorderTreeTraversal(var4)).traverse(this); var2 = var3.toString(); } catch (Exception var5) { } return var2; } public String toXMLString() { return this.toXMLString((String)null); } public boolean equals(Object var1) { if (var1 == null) { return false; } else if (var1 instanceof Attr) { return this.getName().equals(((Attr)var1).getName()); } else { return var1 instanceof String ? this.getName().equals((String)var1) : false; } } public int hashCode() { return this.getName().hashCode(); } public void acceptPre(Visitor var1) throws Exception { var1.visitAttributePre(this); } public void acceptPost(Visitor var1) throws Exception { var1.visitAttributePost(this); } public Node getOwnerElement() { return super.parent; } public Node getParentNode() { return null; } public Node getPreviousSibling() { return null; } public Node getNextSibling() { return null; } static String normalize(int var0, String var1) { if (var0 != 0 && var0 != 1) { var1 = var1.trim(); StringBuffer var2 = new StringBuffer(var1.length()); boolean var3 = false; for(int var4 = 0; var4 < var1.length(); ++var4) { char var5 = var1.charAt(var4); if (var5 == ' ') { if (!var3) { var2.append(var5); } var3 = true; } else { var3 = false; var2.append(var5); } } return var2.toString(); } else { return var1; } } protected void checkChildType(Node var1) throws DOMException { switch (var1.getNodeType()) { case 3: case 5: case 23: return; default: throw new TXDOMException((short)3, "Specified node type (" + var1.getNodeType() + ") can't be a child of Attribute."); } } }