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