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.type.Type; 5 import net.sf.saxon.tinytree.TinyTree; 6 7 import java.util.Set ; 8 9 17 18 public class SubstitutionGroupTest extends NodeTest { 19 20 private int fingerprint; 21 private Set group; 22 23 28 29 public SubstitutionGroupTest(int fingerprint, Set group) { 30 this.group = group; 31 this.fingerprint = fingerprint; 32 } 33 34 39 40 public boolean matches(int nodeKind, int nameCode, int annotation) { 41 return nodeKind == Type.ELEMENT && 42 group.contains(new Integer (nameCode & NamePool.FP_MASK)); 43 } 44 45 56 57 public boolean matches(TinyTree tree, int nodeNr) { 58 return tree.getNodeKind(nodeNr) == Type.ELEMENT && 59 group.contains(new Integer (tree.getNameCode(nodeNr) & NamePool.FP_MASK)); 60 } 61 62 68 69 public boolean matches(NodeInfo node) { 70 return node.getNodeKind() == Type.ELEMENT && 71 group.contains(new Integer (node.getFingerprint())); 72 } 73 76 77 public final double getDefaultPriority() { 78 return 0.0; 79 } 80 81 86 87 public int getPrimitiveType() { 88 return Type.ELEMENT; 89 } 90 91 95 96 public int getNodeKindMask() { 97 return 1<<Type.ELEMENT; 98 } 99 100 105 106 public Set getRequiredNodeNames() { 107 return group; 108 } 109 110 114 115 public int getHeadFingerprint() { 116 return fingerprint; 117 } 118 119 public String toString(NamePool pool) { 120 return "schema-element(" + pool.getDisplayName(fingerprint) + ')'; 121 } 122 123 126 127 public int hashCode() { 128 return 0; 129 } 130 131 132 } 133 134 | Popular Tags |