KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > xpath > Axis


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  * Copyright (C) 2003 XQuark Group.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
19  * You can also get it at http://www.gnu.org/licenses/lgpl.html
20  *
21  * For more information on this software, see http://www.xquark.org.
22  */

23
24 package org.xquark.xpath;
25
26
27
28 public final class Axis
29 {
30     
31     /**
32      * The <code>NO</code> axis contains no axis.
33      */

34     public static final byte NONE = 0x00;
35
36     /**
37      * The <code>SELF</code> axis just contains the context node itself.
38      */

39     public static final byte SELF = 0x01;
40     
41     /**
42      * The <code>CHILD</code> axis contains the children of the context node.
43      */

44     public static final byte CHILD = 0x02;
45     
46     /**
47      * The <code>PARENT</code> axis contains the parent node of the context node.
48      * The <code>PARENT</code> axis implies that the target node type being
49      * Type.ELEMENT.
50      */

51     public static final byte PARENT = 0x03;
52     
53     /**
54      * The <code>ANCESTOR</code> axis contains the ancestors of the context node.
55      * The <code>ANCESTOR</code> axis implies that the target node type being
56      * Type.ELEMENT.
57      */

58     public static final byte ANCESTOR = 0x04;
59     
60     /**
61      * The <code>ANCESTOR_OR_SELF</code> axis contains the context node and
62      * the ancestors of the context node; thus, the ancestor axis will always
63      * include the root node.
64      */

65     public static final byte ANCESTOR_OR_SELF = 0x05;
66     
67     /**
68      * The <code>DESCENDANT</code> axis contains the descendants of the
69      * context node; a descendant is a child or a child of a child and so on;
70      * thus the descendant axis never contains attribute or namespace nodes.
71      */

72     public static final byte DESCENDANT = 0x06;
73     
74     /**
75      * The <code>descendant-or-self</code> axis contains the context node
76      * and the descendants of the context node.
77      */

78     public static final byte DESCENDANT_OR_SELF = 0x07;
79     
80     /**
81      * The <code>PRECEDING</code> axis contains all nodes in the same document
82      * as the context node that are before the context node in document order,
83      * excluding any ancestors and excluding attribute nodes and namespace nodes.
84      */

85     public static final byte PRECEDING = 0x08;
86     
87     /**
88      * The <code>PRECEDING_SIBLING</code> axis contains all the preceding
89      * siblings of the context node; if the context node is an attribute node
90      * or namespace node, the <code>PRECEDING_SIBLING</code> axis is empty.
91      */

92     public static final byte PRECEDING_SIBLING = 0x09;
93     
94     /**
95      * The <code>FOLLOWING</code> axis contains all nodes in the same document
96      * as the context node that are after the context node in document order,
97      * excluding any descendants and excluding attribute nodes and namespace
98      * nodes
99      */

100     public static final byte FOLLOWING = 0x0a;
101     
102     /**
103      * The <code>FOLLOWING_SIBLING</code> axis contains all the following
104      * siblings of the context node; if the context node is an attribute node
105      * or namespace node, the <code>FOLLOWING_SIBLING</code> axis is empty.
106      */

107     public static final byte FOLLOWING_SIBLING = 0x0b;
108     
109     /**
110      * The <code>ATTRIBUTE</code> axis contains the attributes of the context
111      * node; the axis will be empty unless the context node is an element.
112      */

113     public static final byte ATTRIBUTE = 0x0c;
114     
115     /**
116      * The <code>namespace</code> axis contains the namespace nodes of the
117      * context node; the axis will be empty unless the context node is an element.
118      */

119     public static final byte NAMESPACE = 0x0d;
120
121     /**
122      * The string values of the different axis
123      */

124     static public final String JavaDoc[] AXISSTRINGS = {
125         "",
126         "self::",
127         "child::",
128         "parent::",
129         "ancestor::",
130         "ancestor-or-self::",
131         "descendant::",
132         "descendant-or-self::",
133         "preceding::",
134         "preceding-sibling::",
135         "following::",
136         "following-sibling::",
137         "attribute::",
138         "namespace::"
139     };
140     
141     public static String JavaDoc stringValue(byte axis)
142     {
143         switch(axis)
144         {
145             case SELF:
146                 return "self::";
147             case CHILD:
148                 return "child::";
149             case PARENT:
150                 return "parent::";
151             case ANCESTOR:
152                 return "ancestor::";
153             case ANCESTOR_OR_SELF:
154                 return "ancestor-or-self::";
155             case DESCENDANT:
156                 return "descendant::";
157             case DESCENDANT_OR_SELF:
158                 return "descendant-or-self::";
159             case PRECEDING:
160                 return "preceding::";
161             case PRECEDING_SIBLING:
162                 return "preceding-sibling::";
163             case FOLLOWING:
164                 return "following::";
165             case FOLLOWING_SIBLING:
166                 return "following-sibling::";
167             case ATTRIBUTE:
168                 return "attribute::";
169             case NAMESPACE:
170                 return "namespace::";
171             default:
172                 return "unknown-axis::";
173         }
174     }
175
176 }
177
Popular Tags