|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Pattern.java | - | - | - | - |
|
1 | /* | |
2 | * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. | |
3 | * | |
4 | * This software is open source. | |
5 | * See the bottom of this file for the licence. | |
6 | * | |
7 | * $Id: Pattern.java,v 1.4 2004/06/25 08:03:39 maartenc Exp $ | |
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 | // These node numbers are compatable with DOM4J's Node types | |
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 | * Redistribution and use of this software and associated documentation | |
91 | * ("Software"), with or without modification, are permitted provided | |
92 | * that the following conditions are met: | |
93 | * | |
94 | * 1. Redistributions of source code must retain copyright | |
95 | * statements and notices. Redistributions must also contain a | |
96 | * copy of this document. | |
97 | * | |
98 | * 2. Redistributions in binary form must reproduce the | |
99 | * above copyright notice, this list of conditions and the | |
100 | * following disclaimer in the documentation and/or other | |
101 | * materials provided with the distribution. | |
102 | * | |
103 | * 3. The name "DOM4J" must not be used to endorse or promote | |
104 | * products derived from this Software without prior written | |
105 | * permission of MetaStuff, Ltd. For written permission, | |
106 | * please contact dom4j-info@metastuff.com. | |
107 | * | |
108 | * 4. Products derived from this Software may not be called "DOM4J" | |
109 | * nor may "DOM4J" appear in their names without prior written | |
110 | * permission of MetaStuff, Ltd. DOM4J is a registered | |
111 | * trademark of MetaStuff, Ltd. | |
112 | * | |
113 | * 5. Due credit should be given to the DOM4J Project - | |
114 | * http://www.dom4j.org | |
115 | * | |
116 | * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS | |
117 | * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT | |
118 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
119 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
120 | * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
121 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
122 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
123 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
124 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
125 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
126 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
127 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
128 | * | |
129 | * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. | |
130 | * | |
131 | * $Id: Pattern.java,v 1.4 2004/06/25 08:03:39 maartenc Exp $ | |
132 | */ |
|