1 package com.icl.saxon.tinytree; 2 import com.icl.saxon.om.*; 3 import com.icl.saxon.Context; 4 import com.icl.saxon.output.Outputter; 5 6 import org.w3c.dom.Node ; 7 import org.w3c.dom.Attr ; 8 import org.w3c.dom.Element ; 9 import org.w3c.dom.DOMException ; 10 11 import javax.xml.transform.TransformerException ; 12 13 14 19 20 final class TinyAttributeImpl extends TinyNodeImpl implements Attr { 21 22 public TinyAttributeImpl(TinyDocumentImpl doc, int nodeNr) { 23 this.document = doc; 24 this.nodeNr = nodeNr; 25 } 26 27 30 31 public NodeInfo getParent() { 32 return document.getNode(document.attParent[nodeNr]); 33 } 34 35 41 42 protected long getSequenceNumber() { 43 long z = 45 ((TinyNodeImpl)getParent()).getSequenceNumber() 46 + 0x8000 + 47 (nodeNr - document.offset[document.attParent[nodeNr]]); 48 return z; 49 } 51 52 56 57 public final short getNodeType() { 58 return ATTRIBUTE; 59 } 60 61 65 66 public String getStringValue() { 67 return document.attValue[nodeNr]; 68 } 69 70 73 74 public int getFingerprint() { 75 return document.attCode[nodeNr] & 0xfffff; 76 } 77 78 81 82 public int getNameCode() { 83 return document.attCode[nodeNr]; 84 } 85 86 90 91 public String getPrefix() { 92 int code = document.attCode[nodeNr]; 93 if ((code>>20 & 0xff) == 0) return ""; 94 return document.getNamePool().getPrefix(code); 95 } 96 97 103 104 public String getDisplayName() { 105 return document.getNamePool().getDisplayName(document.attCode[nodeNr]); 106 } 107 108 109 114 115 public String getLocalName() { 116 return document.getNamePool().getLocalName(document.attCode[nodeNr]); 117 } 118 119 124 125 public final String getURI() { 126 return document.getNamePool().getURI(document.attCode[nodeNr]); 127 } 128 129 132 133 public String generateId() { 134 return (getParent()).generateId() + "_" + getDisplayName(); 135 } 136 137 140 141 public void copy(Outputter out) throws TransformerException { 142 int nameCode = document.attCode[nodeNr]; 143 if ((nameCode>>20 & 0xff) != 0) { nameCode = out.checkAttributePrefix(nameCode); 146 } 147 out.writeAttribute(nameCode, getStringValue()); 148 } 149 150 153 154 public int getLineNumber() { 155 return getParent().getLineNumber(); 156 } 157 158 } 159 160 | Popular Tags |