1 7 8 package org.dom4j.rule.pattern; 9 10 import org.dom4j.Node; 11 import org.dom4j.rule.Pattern; 12 13 22 public class NodeTypePattern implements Pattern { 23 24 public static final NodeTypePattern ANY_ATTRIBUTE = new NodeTypePattern( 25 Node.ATTRIBUTE_NODE); 26 27 28 public static final NodeTypePattern ANY_COMMENT = new NodeTypePattern( 29 Node.COMMENT_NODE); 30 31 32 public static final NodeTypePattern ANY_DOCUMENT = new NodeTypePattern( 33 Node.DOCUMENT_NODE); 34 35 36 public static final NodeTypePattern ANY_ELEMENT = new NodeTypePattern( 37 Node.ELEMENT_NODE); 38 39 40 public static final NodeTypePattern ANY_PROCESSING_INSTRUCTION = 41 new NodeTypePattern(Node.PROCESSING_INSTRUCTION_NODE); 42 43 44 public static final NodeTypePattern ANY_TEXT = new NodeTypePattern( 45 Node.TEXT_NODE); 46 47 private short nodeType; 48 49 public NodeTypePattern(short nodeType) { 50 this.nodeType = nodeType; 51 } 52 53 public boolean matches(Node node) { 54 return node.getNodeType() == nodeType; 55 } 56 57 public double getPriority() { 58 return Pattern.DEFAULT_PRIORITY; 59 } 60 61 public Pattern[] getUnionPatterns() { 62 return null; 63 } 64 65 public short getMatchType() { 66 return nodeType; 67 } 68 69 public String getMatchesNodeName() { 70 return null; 71 } 72 } 73 74 110 | Popular Tags |