1 package net.sf.saxon.pattern; 2 import net.sf.saxon.om.NamePool; 3 import net.sf.saxon.om.NodeInfo; 4 import net.sf.saxon.tinytree.TinyTree; 5 6 13 14 public final class LocalNameTest extends NodeTest { 15 16 private NamePool namePool; 17 private int nodeKind; 18 private String localName; 19 20 public LocalNameTest(NamePool pool, int nodeType, String localName) { 21 namePool = pool; 22 nodeKind = nodeType; 23 this.localName = localName; 24 } 25 26 31 32 public boolean matches(int nodeType, int fingerprint, int annotation) { 33 if (fingerprint == -1) return false; 34 if (nodeType != nodeKind) return false; 35 return localName.equals(namePool.getLocalName(fingerprint)); 36 } 37 38 48 49 public boolean matches(TinyTree tree, int nodeNr) { 50 int fingerprint = tree.getNameCode(nodeNr) & NamePool.FP_MASK; 51 if (fingerprint == -1) return false; 52 if (tree.getNodeKind(nodeNr) != nodeKind) return false; 53 return localName.equals(namePool.getLocalName(fingerprint)); 54 } 55 56 62 63 public boolean matches(NodeInfo node) { 64 return localName.equals(node.getLocalPart()); 65 } 66 67 68 71 72 public final double getDefaultPriority() { 73 return -0.25; 74 } 75 76 81 82 public int getPrimitiveType() { 83 return nodeKind; 84 } 85 86 90 91 public int getNodeKindMask() { 92 return 1<<nodeKind; 93 } 94 95 public String toString() { 96 return "*:" + localName; 97 } 98 99 102 103 public int hashCode() { 104 return nodeKind<<20 ^ localName.hashCode(); 105 } 106 107 } 108 109 | Popular Tags |