1 package net.sf.saxon.tinytree; 2 import net.sf.saxon.event.Receiver; 3 import net.sf.saxon.om.NodeInfo; 4 import net.sf.saxon.trans.XPathException; 5 import net.sf.saxon.type.Type; 6 7 8 13 14 final class TinyAttributeImpl extends TinyNodeImpl { 15 16 public TinyAttributeImpl(TinyTree tree, int nodeNr) { 17 this.tree = tree; 18 this.nodeNr = nodeNr; 19 } 20 21 24 25 public NodeInfo getParent() { 26 return tree.getNode(tree.attParent[nodeNr]); 27 } 28 29 34 35 public NodeInfo getRoot() { 36 NodeInfo parent = getParent(); 37 if (parent == null) { 38 return this; } else { 40 return parent.getRoot(); 41 } 42 } 43 44 51 52 protected long getSequenceNumber() { 53 long z = 55 ((TinyNodeImpl)getParent()).getSequenceNumber() 56 + 0x8000 + 57 (nodeNr - tree.alpha[tree.attParent[nodeNr]]); 58 return z; 59 } 61 62 66 67 public final int getNodeKind() { 68 return Type.ATTRIBUTE; 69 } 70 71 75 76 public CharSequence getStringValueCS() { 77 return tree.attValue[nodeNr]; 78 } 79 80 84 85 public String getStringValue() { 86 return tree.attValue[nodeNr].toString(); 87 } 88 89 92 93 public int getFingerprint() { 94 return tree.attCode[nodeNr] & 0xfffff; 95 } 96 97 100 101 public int getNameCode() { 102 return tree.attCode[nodeNr]; 103 } 104 105 109 110 public String getPrefix() { 111 int code = tree.attCode[nodeNr]; 112 if ((code>>20 & 0xff) == 0) return ""; 113 return tree.getNamePool().getPrefix(code); 114 } 115 116 122 123 public String getDisplayName() { 124 return tree.getNamePool().getDisplayName(tree.attCode[nodeNr]); 125 } 126 127 128 133 134 public String getLocalPart() { 135 return tree.getNamePool().getLocalName(tree.attCode[nodeNr]); 136 } 137 138 143 144 public final String getURI() { 145 return tree.getNamePool().getURI(tree.attCode[nodeNr]); 146 } 147 148 154 155 public int getTypeAnnotation() { 156 return tree.getAttributeAnnotation(nodeNr); 157 } 158 159 162 163 public String generateId() { 164 return (getParent()).generateId() + 'a' + tree.attCode[nodeNr]; 165 } 169 170 173 174 public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException { 175 int nameCode = tree.attCode[nodeNr]; 176 int typeCode = (copyAnnotations ? getTypeAnnotation() : -1); 177 out.attribute(nameCode, typeCode, getStringValue(), locationId, 0); 178 } 179 180 183 184 public int getLineNumber() { 185 return getParent().getLineNumber(); 186 } 187 188 } 189 190 | Popular Tags |