1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Copyright 1999-2004 The Apache Software Foundation. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 /* 21 * $Id: Axis.java,v 1.2.4.1 2005/09/15 08:14:51 suresh_emailid Exp $ 22 */ 23 package com.sun.org.apache.xml.internal.dtm; 24 25 /** 26 * Specifies values related to XPath Axes. 27 * <p>The ancestor, descendant, following, preceding and self axes partition a 28 * document (ignoring attribute and namespace nodes): they do not overlap 29 * and together they contain all the nodes in the document.</p> 30 * 31 */ 32 public final class Axis 33 { 34 35 /** 36 * The ancestor axis contains the ancestors of the context node; 37 * the ancestors of the context node consist of the parent of context 38 * node and the parent's parent and so on; thus, the ancestor axis will 39 * always include the root node, unless the context node is the root node. 40 */ 41 public static final int ANCESTOR = 0; 42 43 /** 44 * the ancestor-or-self axis contains the context node and the ancestors of 45 * the context node; thus, the ancestor axis will always include the 46 * root node. 47 */ 48 public static final int ANCESTORORSELF = 1; 49 50 /** 51 * the attribute axis contains the attributes of the context node; the axis 52 * will be empty unless the context node is an element. 53 */ 54 public static final int ATTRIBUTE = 2; 55 56 /** The child axis contains the children of the context node. */ 57 public static final int CHILD = 3; 58 59 /** 60 * The descendant axis contains the descendants of the context node; 61 * a descendant is a child or a child of a child and so on; thus the 62 * descendant axis never contains attribute or namespace nodes. 63 */ 64 public static final int DESCENDANT = 4; 65 66 /** 67 * The descendant-or-self axis contains the context node and the 68 * descendants of the context node. 69 */ 70 public static final int DESCENDANTORSELF = 5; 71 72 /** 73 * the following axis contains all nodes in the same document as the 74 * context node that are after the context node in document order, excluding 75 * any descendants and excluding attribute nodes and namespace nodes. 76 */ 77 public static final int FOLLOWING = 6; 78 79 /** 80 * The following-sibling axis contains all the following siblings of the 81 * context node; if the context node is an attribute node or namespace node, 82 * the following-sibling axis is empty. 83 */ 84 public static final int FOLLOWINGSIBLING = 7; 85 86 /** 87 * The namespace axis contains the namespace nodes of the context node; the 88 * axis will be empty unless the context node is an element. 89 */ 90 public static final int NAMESPACEDECLS = 8; 91 92 /** 93 * The namespace axis contains the namespace nodes of the context node; the 94 * axis will be empty unless the context node is an element. 95 */ 96 public static final int NAMESPACE = 9; 97 98 /** 99 * The parent axis contains the parent of the context node, 100 * if there is one. 101 */ 102 public static final int PARENT = 10; 103 104 /** 105 * The preceding axis contains all nodes in the same document as the context 106 * node that are before the context node in document order, excluding any 107 * ancestors and excluding attribute nodes and namespace nodes 108 */ 109 public static final int PRECEDING = 11; 110 111 /** 112 * The preceding-sibling axis contains all the preceding siblings of the 113 * context node; if the context node is an attribute node or namespace node, 114 * the preceding-sibling axis is empty. 115 */ 116 public static final int PRECEDINGSIBLING = 12; 117 118 /** The self axis contains just the context node itself. */ 119 public static final int SELF = 13; 120 121 /** 122 * A non-xpath axis, traversing the subtree including the subtree 123 * root, descendants, attributes, and namespace node decls. 124 */ 125 public static final int ALLFROMNODE = 14; 126 127 /** 128 * A non-xpath axis, traversing the the preceding and the ancestor nodes, 129 * needed for inverseing select patterns to match patterns. 130 */ 131 public static final int PRECEDINGANDANCESTOR = 15; 132 133 // =========================================== 134 // All axis past this are absolute. 135 136 /** 137 * A non-xpath axis, returns all nodes in the tree from and including the 138 * root. 139 */ 140 public static final int ALL = 16; 141 142 /** 143 * A non-xpath axis, returns all nodes that aren't namespaces or attributes, 144 * from and including the root. 145 */ 146 public static final int DESCENDANTSFROMROOT = 17; 147 148 /** 149 * A non-xpath axis, returns all nodes that aren't namespaces or attributes, 150 * from and including the root. 151 */ 152 public static final int DESCENDANTSORSELFFROMROOT = 18; 153 154 /** 155 * A non-xpath axis, returns root only. 156 */ 157 public static final int ROOT = 19; 158 159 /** 160 * A non-xpath axis, for functions. 161 */ 162 public static final int FILTEREDLIST = 20; 163 164 /** 165 * A table to identify whether an axis is a reverse axis; 166 */ 167 private static final boolean[] isReverse = { 168 true, // ancestor 169 true, // ancestor-or-self 170 false, // attribute 171 false, // child 172 false, // descendant 173 false, // descendant-or-self 174 false, // following 175 false, // following-sibling 176 false, // namespace 177 false, // namespace-declarations 178 false, // parent (one node, has no order) 179 true, // preceding 180 true, // preceding-sibling 181 false // self (one node, has no order) 182 }; 183 184 /** The names of the axes for diagnostic purposes. */ 185 private static final String[] names = 186 { 187 "ancestor", // 0 188 "ancestor-or-self", // 1 189 "attribute", // 2 190 "child", // 3 191 "descendant", // 4 192 "descendant-or-self", // 5 193 "following", // 6 194 "following-sibling", // 7 195 "namespace-decls", // 8 196 "namespace", // 9 197 "parent", // 10 198 "preceding", // 11 199 "preceding-sibling", // 12 200 "self", // 13 201 "all-from-node", // 14 202 "preceding-and-ancestor", // 15 203 "all", // 16 204 "descendants-from-root", // 17 205 "descendants-or-self-from-root", // 18 206 "root", // 19 207 "filtered-list" // 20 208 }; 209 210 public static boolean isReverse(int axis){ 211 return isReverse[axis]; 212 } 213 214 public static String getNames(int index){ 215 return names[index]; 216 } 217 218 public static int getNamesLength(){ 219 return names.length; 220 } 221 222 }