1 61 package org.jaxen.expr; 62 63 import java.util.Collections ; 64 import java.util.List ; 65 66 import org.jaxen.Context; 67 import org.jaxen.ContextSupport; 68 import org.jaxen.JaxenException; 69 import org.jaxen.Navigator; 70 import org.jaxen.util.SingletonList; 71 72 public class DefaultAbsoluteLocationPath extends DefaultLocationPath 73 { 74 public DefaultAbsoluteLocationPath() 75 { 76 } 77 78 public String toString() 79 { 80 return "[(DefaultAbsoluteLocationPath): " + super.toString() + "]"; 81 } 82 83 public boolean isAbsolute() 84 { 85 return true; 86 } 87 88 public String getText() 89 { 90 return "/" + super.getText(); 91 } 92 93 public Object evaluate(Context context) throws JaxenException 94 { 95 ContextSupport support = context.getContextSupport(); 96 Navigator nav = support.getNavigator(); 97 Context absContext = new Context( support ); 98 List contextNodes = context.getNodeSet(); 99 100 if ( contextNodes.isEmpty() ) 101 { 102 return Collections.EMPTY_LIST; 103 } 104 105 Object firstNode = contextNodes.get( 0 ); 106 Object docNode = nav.getDocumentNode( firstNode ); 107 108 if ( docNode == null ) 109 { 110 return Collections.EMPTY_LIST; 111 } 112 113 List list = new SingletonList(docNode); 114 115 absContext.setNodeSet( list ); 116 117 return super.evaluate( absContext ); 118 } 119 120 public void accept(Visitor visitor) 121 { 122 visitor.visit(this); 123 } 124 } 125 126 | Popular Tags |