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