1
2
3
4
5
6
7
8 package org.dom4j.rule;
9
10 import org.dom4j.Node;
11 import org.dom4j.NodeFilter;
12
13 /***
14 * <p>
15 * <code>Pattern</code> defines the behaviour for pattern in the XSLT
16 * processing model.
17 * </p>
18 *
19 * @author <a href="mailto:james.strachan@metastuff.com">James Strachan </a>
20 * @version $Revision: 1.6 $
21 */
22 public interface Pattern extends NodeFilter {
23
24
25 /*** Matches any node */
26 short ANY_NODE = 0;
27
28 /*** Matches no nodes */
29 short NONE = 9999;
30
31 /*** Count of the number of node types */
32 short NUMBER_OF_TYPES = Node.UNKNOWN_NODE;
33
34 /***
35 * According to the <a href="http://www.w3.org/TR/xslt11/#conflict">spec
36 * </a> we should return 0.5 if we cannot determine the priority
37 */
38 double DEFAULT_PRIORITY = 0.5;
39
40 /***
41 * DOCUMENT ME!
42 *
43 * @param node
44 * DOCUMENT ME!
45 *
46 * @return true if the pattern matches the given DOM4J node.
47 */
48 boolean matches(Node node);
49
50 /***
51 * Returns the default resolution policy of the pattern according to the <a
52 * href="http://www.w3.org/TR/xslt11/#conflict"> XSLT conflict resolution
53 * spec </a>.
54 *
55 * @return DOCUMENT ME!
56 */
57 double getPriority();
58
59 /***
60 * If this pattern is a union pattern then this method should return an
61 * array of patterns which describe the union pattern, which should contain
62 * more than one pattern. Otherwise this method should return null.
63 *
64 * @return an array of the patterns which make up this union pattern or null
65 * if this pattern is not a union pattern
66 */
67 Pattern[] getUnionPatterns();
68
69 /***
70 * DOCUMENT ME!
71 *
72 * @return the type of node the pattern matches which by default should
73 * return ANY_NODE if it can match any kind of node.
74 */
75 short getMatchType();
76
77 /***
78 * For patterns which only match an ATTRIBUTE_NODE or an ELEMENT_NODE then
79 * this pattern may return the name of the element or attribute it matches.
80 * This allows a more efficient rule matching algorithm to be performed,
81 * rather than a brute force approach of evaluating every pattern for a
82 * given Node.
83 *
84 * @return the name of the element or attribute this pattern matches or null
85 * if this pattern matches any or more than one name.
86 */
87 String getMatchesNodeName();
88 }
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125