KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > pattern > AnyChildNodePattern


1 package com.icl.saxon.pattern;
2 import com.icl.saxon.Context;
3 import com.icl.saxon.om.*;
4 import com.icl.saxon.expr.XPathException;
5
6 /**
7 * An AnyChildNodePattern is the pattern node(), which matches any node except a root node,
8 * an attribute node, or a namespace node: in other words, any node that is the child of another
9 * node.
10 */

11
12 public final class AnyChildNodePattern extends NodeTest {
13
14     /**
15     * Determine whether the pattern matches a given node.
16     * @param node the node to be tested
17     * @return true if the pattern matches, else false
18     */

19
20     public boolean matches(NodeInfo node) {
21         short type = node.getNodeType();
22         return (type == NodeInfo.ELEMENT ||
23                 type == NodeInfo.TEXT ||
24                 type == NodeInfo.COMMENT ||
25                 type == NodeInfo.PI);
26     }
27
28     /**
29     * Test whether this node test is satisfied by a given node
30     * @param nodeType The type of node to be matched
31     * @param fingerprint identifies the expanded name of the node to be matched
32     */

33
34     public boolean matches(short nodeType, int fingerprint) {
35         return (nodeType == NodeInfo.ELEMENT ||
36                 nodeType == NodeInfo.TEXT ||
37                 nodeType == NodeInfo.COMMENT ||
38                 nodeType == NodeInfo.PI);
39     }
40     
41     /**
42     * Determine the type of nodes to which this pattern applies.
43     * @return the node type
44     */

45
46     public short getNodeType() {
47         return NodeInfo.NODE;
48     }
49
50     /**
51     * Determine the default priority to use if this pattern appears as a match pattern
52     * for a template with no explicit priority attribute.
53     */

54
55     public double getDefaultPriority() {
56         return -0.5;
57     }
58
59 }
60
61 //
62
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
63
// you may not use this file except in compliance with the License. You may obtain a copy of the
64
// License at http://www.mozilla.org/MPL/
65
//
66
// Software distributed under the License is distributed on an "AS IS" basis,
67
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
68
// See the License for the specific language governing rights and limitations under the License.
69
//
70
// The Original Code is: all this file.
71
//
72
// The Initial Developer of the Original Code is
73
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
74
//
75
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
76
//
77
// Contributor(s): none.
78
//
79
Popular Tags