001/* 002 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 003 * 004 * This software is open source. 005 * See the bottom of this file for the licence. 006 * 007 * $Id: Pattern.java,v 1.1 2001/02/07 14:51:18 jstrachan Exp $ 008 */ 009 010package org.dom4j.rule; 011 012import org.dom4j.Node; 013import org.dom4j.NodeFilter; 014 015 016/** <p><code>Pattern</code> defines the behaviour for pattern in 017 * the XSLT processing model.</p> 018 * 019 * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a> 020 * @version $Revision: 1.1 $ 021 */ 022public interface Pattern extends NodeFilter { 023 024 // These node numbers are compatable with DOM4J's Node types 025 026 /** Matches any node */ 027 public static final short ANY_NODE = 0; 028 029 /** Matches no nodes */ 030 public static final short NONE = 9999; 031 032 /** Count of the number of node types */ 033 public static final short NUMBER_OF_TYPES = Node.UNKNOWN_NODE; 034 035 /** According to the 036 * <a href="http://www.w3.org/TR/xslt11/#conflict">spec</a> 037 * we should return 0.5 if we cannot determine the priority 038 */ 039 public static final double DEFAULT_PRIORITY = 0.5; 040 041 042 /** @return true if the pattern matches the given 043 * DOM4J node. 044 */ 045 public boolean matches( Node node ); 046 047 /** Returns the default resolution policy of the pattern according to the 048 * <a href="http://www.w3.org/TR/xslt11/#conflict"> 049 * XSLT conflict resolution spec</a>. 050 * 051 */ 052 public double getPriority(); 053 054 /** If this pattern is a union pattern then this 055 * method should return an array of patterns which 056 * describe the union pattern, which should contain more than one pattern. 057 * Otherwise this method should return null. 058 * 059 * @return an array of the patterns which make up this union pattern 060 * or null if this pattern is not a union pattern 061 */ 062 public Pattern[] getUnionPatterns(); 063 064 065 /** @return the type of node the pattern matches 066 * which by default should return ANY_NODE if it can 067 * match any kind of node. 068 */ 069 public short getMatchType(); 070 071 072 /** For patterns which only match an ATTRIBUTE_NODE or an 073 * ELEMENT_NODE then this pattern may return the name of the 074 * element or attribute it matches. This allows a more efficient 075 * rule matching algorithm to be performed, rather than a brute 076 * force approach of evaluating every pattern for a given Node. 077 * 078 * @return the name of the element or attribute this pattern matches 079 * or null if this pattern matches any or more than one name. 080 */ 081 public String getMatchesNodeName(); 082 083 084} 085 086 087 088 089/* 090 * Redistribution and use of this software and associated documentation 091 * ("Software"), with or without modification, are permitted provided 092 * that the following conditions are met: 093 * 094 * 1. Redistributions of source code must retain copyright 095 * statements and notices. Redistributions must also contain a 096 * copy of this document. 097 * 098 * 2. Redistributions in binary form must reproduce the 099 * 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://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 (C) MetaStuff, Ltd. All Rights Reserved. 130 * 131 * $Id: Pattern.java,v 1.1 2001/02/07 14:51:18 jstrachan Exp $ 132 */