1 package com.icl.saxon.tree; 2 import com.icl.saxon.om.NodeInfo; 3 import com.icl.saxon.om.NamePool; 4 import com.icl.saxon.output.Outputter; 5 6 import javax.xml.transform.TransformerException ; 7 import org.w3c.dom.Node ; 8 9 15 16 final class NamespaceImpl extends NodeImpl { 17 18 private int nsCode; private int nameCode; private int index; 21 22 28 29 public NamespaceImpl(ElementImpl element, int nsCode, int index) { 30 this.parent = element; 31 this.nsCode = nsCode; 32 NamePool pool = getNamePool(); 33 this.nameCode = pool.allocate("", "", pool.getPrefixFromNamespaceCode(nsCode)); 34 this.index = index; 35 } 36 37 40 41 public int getNameCode() { 42 return nameCode; 43 } 44 45 48 49 public int getNamespaceCode() { 50 return nsCode; 51 } 52 53 58 59 public boolean isSameNode(NodeInfo other) { 60 if (!(other instanceof NamespaceImpl)) return false; 61 if (this==other) return true; 62 NamespaceImpl otherN = (NamespaceImpl)other; 63 return (parent.isSameNode(otherN.parent) && 64 this.nsCode==otherN.nsCode); 65 } 66 67 70 71 public String getLocalName() { 72 return getNamePool().getPrefixFromNamespaceCode(nsCode); 73 } 74 75 79 80 public void setNamespaceCode(int nsCode) { 81 NamePool pool = getNamePool(); 82 this.nsCode = nsCode; 83 this.nameCode = pool.allocate("", "", pool.getPrefixFromNamespaceCode(nsCode)); 84 } 85 86 90 91 public final short getNodeType() { 92 return NAMESPACE; 93 } 94 95 99 100 public String getStringValue() { 101 return getNamePool().getURIFromNamespaceCode(nsCode); 102 } 103 104 109 110 public String getNodeName() { 111 return getLocalName(); 112 } 113 114 117 118 public Node getNextSibling() { 119 return null; 120 } 121 122 125 126 public Node getPreviousSibling() { 127 return null; 128 } 129 130 133 134 public NodeImpl getPreviousInDocument() { 135 return (NodeImpl)getParent(); 136 } 137 138 141 142 public NodeImpl getNextInDocument(NodeImpl anchor) { 143 if (this==anchor) return null; 144 return ((NodeImpl)getParent()).getNextInDocument(anchor); 145 } 146 147 148 151 152 public String generateId() { 153 return parent.generateId() + "_xmlns_" + getLocalName(); 154 } 155 156 159 160 public void copy(Outputter out) throws TransformerException { 161 out.copyNamespaceNode(nsCode); 162 } 163 164 170 171 protected long getSequenceNumber() { 172 return parent.getSequenceNumber() + index; 173 } 174 175 } 176 177 | Popular Tags |