1 61 62 63 64 package org.jaxen; 65 66 import java.util.Iterator ; 67 68 import org.jaxen.pattern.Pattern; 69 import org.jaxen.util.AncestorAxisIterator; 70 import org.jaxen.util.AncestorOrSelfAxisIterator; 71 import org.jaxen.util.DescendantAxisIterator; 72 import org.jaxen.util.DescendantOrSelfAxisIterator; 73 import org.jaxen.util.FollowingAxisIterator; 74 import org.jaxen.util.FollowingSiblingAxisIterator; 75 import org.jaxen.util.PrecedingAxisIterator; 76 import org.jaxen.util.PrecedingSiblingAxisIterator; 77 import org.jaxen.util.SelfAxisIterator; 78 79 98 public abstract class DefaultNavigator implements Navigator 99 { 100 101 107 public Iterator getChildAxisIterator(Object contextNode) throws UnsupportedAxisException 108 { 109 throw new UnsupportedAxisException("child"); 110 } 111 112 115 public Iterator getDescendantAxisIterator(Object contextNode) throws UnsupportedAxisException 116 { 117 return new DescendantAxisIterator( contextNode, 118 this ); 119 } 120 121 127 public Iterator getParentAxisIterator(Object contextNode) throws UnsupportedAxisException 128 { 129 throw new UnsupportedAxisException("parent"); 130 } 131 132 public Iterator getAncestorAxisIterator(Object contextNode) throws UnsupportedAxisException 133 { 134 return new AncestorAxisIterator( contextNode, 135 this ); 136 } 137 138 139 public Iterator getFollowingSiblingAxisIterator(Object contextNode) throws UnsupportedAxisException 140 { 141 return new FollowingSiblingAxisIterator( contextNode, 142 this ); 143 } 144 145 146 public Iterator getPrecedingSiblingAxisIterator(Object contextNode) throws UnsupportedAxisException 147 { 148 return new PrecedingSiblingAxisIterator( contextNode, 149 this ); 150 } 151 152 public Iterator getFollowingAxisIterator(Object contextNode) throws UnsupportedAxisException 153 { 154 return new FollowingAxisIterator( contextNode, 155 this ); 156 157 } 159 160 161 public Iterator getPrecedingAxisIterator(Object contextNode) throws UnsupportedAxisException 162 { 163 return new PrecedingAxisIterator( contextNode, 164 this ); 165 166 } 168 169 176 public Iterator getAttributeAxisIterator(Object contextNode) throws UnsupportedAxisException 177 { 178 throw new UnsupportedAxisException("attribute"); 179 } 180 181 188 public Iterator getNamespaceAxisIterator(Object contextNode) throws UnsupportedAxisException 189 { 190 throw new UnsupportedAxisException("namespace"); 191 } 192 193 public Iterator getSelfAxisIterator(Object contextNode) throws UnsupportedAxisException 194 { 195 return new SelfAxisIterator( contextNode ); 196 } 197 198 public Iterator getDescendantOrSelfAxisIterator(Object contextNode) throws UnsupportedAxisException 199 { 200 return new DescendantOrSelfAxisIterator( contextNode, 201 this ); 202 } 203 204 public Iterator getAncestorOrSelfAxisIterator(Object contextNode) throws UnsupportedAxisException 205 { 206 return new AncestorOrSelfAxisIterator( contextNode, 207 this ); 208 } 209 210 public Object getDocumentNode(Object contextNode) 211 { 212 return null; 213 } 214 215 public String translateNamespacePrefixToUri(String prefix, Object element) 216 { 217 return null; 218 } 219 220 public String getProcessingInstructionTarget(Object obj) 221 { 222 return null; 223 } 224 225 public String getProcessingInstructionData(Object obj) 226 { 227 return null; 228 } 229 230 public short getNodeType(Object node) 231 { 232 if ( isElement(node) ) 233 { 234 return Pattern.ELEMENT_NODE; 235 } 236 else if ( isAttribute(node) ) 237 { 238 return Pattern.ATTRIBUTE_NODE; 239 } 240 else if ( isText(node) ) 241 { 242 return Pattern.TEXT_NODE; 243 } 244 else if ( isComment(node) ) 245 { 246 return Pattern.COMMENT_NODE; 247 } 248 else if ( isDocument(node) ) 249 { 250 return Pattern.DOCUMENT_NODE; 251 } 252 else if ( isProcessingInstruction(node) ) 253 { 254 return Pattern.PROCESSING_INSTRUCTION_NODE; 255 } 256 else if ( isNamespace(node) ) 257 { 258 return Pattern.NAMESPACE_NODE; 259 } 260 else { 261 return Pattern.UNKNOWN_NODE; 262 } 263 } 264 265 273 public Object getParentNode(Object contextNode) throws UnsupportedAxisException 274 { 275 Iterator iter = getParentAxisIterator( contextNode ); 276 if ( iter != null && iter.hasNext() ) 277 { 278 return iter.next(); 279 } 280 return null; 281 } 282 283 293 public Object getDocument(String url) throws FunctionCallException 294 { 295 return null; 296 } 297 298 308 public Object getElementById(Object contextNode, String elementId) 309 { 310 return null; 311 } 312 313 } 314 | Popular Tags |