home *** CD-ROM | disk | FTP | other *** search
- package com.sun.xml.tree;
-
- import com.sun.xml.util.XmlNames;
- import java.io.IOException;
- import java.io.Writer;
- import org.w3c.dom.Attr;
- import org.w3c.dom.DOMException;
- import org.w3c.dom.Node;
-
- final class AttributeNode extends ParentNode implements Attr, NamespaceScoped {
- private String name;
- private String value;
- private boolean specified;
- private String defaultValue;
- private ElementNode nameScope;
-
- public AttributeNode(AttributeNode var1) throws DOMException {
- this(var1.name, var1.value, var1.specified, var1.defaultValue);
- this.nameScope = var1.nameScope;
- ((NodeBase)this).setOwnerDocument((XmlDocument)((NodeBase)var1).getOwnerDocument());
- }
-
- public AttributeNode(String var1, String var2, boolean var3, String var4) throws DOMException {
- if (!XmlNames.isName(var1)) {
- throw new DomEx((short)5);
- } else {
- this.name = var1;
- this.value = var2;
- this.specified = var3;
- this.defaultValue = var4;
- }
- }
-
- void checkChildType(int var1) throws DOMException {
- switch (var1) {
- case 3:
- case 5:
- return;
- case 4:
- default:
- throw new DomEx((short)3);
- }
- }
-
- public Node cloneNode(boolean var1) {
- try {
- AttributeNode var2 = new AttributeNode(this.name, this.value, this.specified, this.defaultValue);
- ((NodeBase)var2).setOwnerDocument((XmlDocument)((NodeBase)this).getOwnerDocument());
- Node var3;
- if (var1) {
- for(int var4 = 0; (var3 = ((ParentNode)this).item(var4)) != null; ++var4) {
- var3 = var3.cloneNode(true);
- ((ParentNode)var2).appendChild(var3);
- }
- }
-
- return var2;
- } catch (DOMException var5) {
- throw new RuntimeException(((NodeBase)this).getMessage("A-002"));
- }
- }
-
- String getDefaultValue() {
- return this.defaultValue;
- }
-
- public String getLocalName() {
- int var1 = this.name.indexOf(58);
- return var1 < 0 ? this.name : this.name.substring(var1 + 1);
- }
-
- public String getName() {
- return this.name;
- }
-
- ElementNode getNameScope() {
- return this.nameScope;
- }
-
- public String getNamespace() {
- if (this.nameScope == null) {
- throw new IllegalStateException(((NodeBase)this).getMessage("A-001"));
- } else {
- String var1;
- if ((var1 = this.getPrefix()) == null) {
- return this.nameScope.getNamespace();
- } else if (!"xml".equals(var1) && !"xmlns".equals(var1)) {
- String var2 = this.nameScope.getInheritedAttribute("xmlns:" + var1);
- if (var2 == null) {
- throw new IllegalStateException();
- } else {
- return var2;
- }
- } else {
- return null;
- }
- }
- }
-
- public Node getNextSibling() {
- return null;
- }
-
- public String getNodeName() {
- return this.name;
- }
-
- public short getNodeType() {
- return 2;
- }
-
- public String getNodeValue() {
- return this.value;
- }
-
- public Node getParentNode() {
- return null;
- }
-
- public String getPrefix() {
- int var1 = this.name.indexOf(58);
- return var1 < 0 ? null : this.name.substring(0, var1);
- }
-
- public Node getPreviousSibling() {
- return null;
- }
-
- public boolean getSpecified() {
- return this.specified;
- }
-
- public String getValue() {
- return this.value;
- }
-
- void setNameScope(ElementNode var1) {
- if (var1 != null && this.nameScope != null) {
- throw new IllegalStateException(((NodeBase)this).getMessage("A-000", new Object[]{var1.getTagName()}));
- } else {
- this.nameScope = var1;
- }
- }
-
- public void setNodeValue(String var1) {
- if (((NodeBase)this).isReadonly()) {
- throw new DomEx((short)7);
- } else {
- this.value = var1;
- this.specified = true;
- }
- }
-
- public void setPrefix(String var1) {
- int var2 = this.name.indexOf(58);
- if (var1 == null) {
- if (var2 >= 0) {
- this.name = this.name.substring(var2 + 1);
- }
- } else {
- StringBuffer var3 = new StringBuffer(var1);
- var3.append(':');
- if (var2 < 0) {
- var3.append(this.name);
- } else {
- var3.append(this.name.substring(var2 + 1));
- }
-
- this.name = var3.toString();
- }
- }
-
- void setSpecified(boolean var1) {
- this.specified = var1;
- }
-
- public void setValue(String var1) {
- this.setNodeValue(var1);
- }
-
- public void writeChildrenXml(XmlWriteContext var1) throws IOException {
- Writer var2 = var1.getWriter();
-
- for(int var3 = 0; var3 < this.value.length(); ++var3) {
- char var4 = this.value.charAt(var3);
- switch (var4) {
- case '"':
- var2.write(""");
- break;
- case '&':
- var2.write("&");
- break;
- case '\'':
- var2.write("'");
- break;
- case '<':
- var2.write("<");
- break;
- case '>':
- var2.write(">");
- break;
- default:
- var2.write(var4);
- }
- }
-
- }
-
- public void writeXml(XmlWriteContext var1) throws IOException {
- Writer var2 = var1.getWriter();
- var2.write(this.name);
- var2.write("=\"");
- this.writeChildrenXml(var1);
- var2.write(34);
- }
- }
-