1 61 62 63 package org.jaxen.function; 64 65 import java.util.List ; 66 67 import org.jaxen.Context; 68 import org.jaxen.Function; 69 import org.jaxen.FunctionCallException; 70 import org.jaxen.Navigator; 71 72 84 public class StartsWithFunction implements Function 85 { 86 87 90 public StartsWithFunction() {} 91 92 107 public Object call(Context context, 108 List args) throws FunctionCallException 109 { 110 if (args.size() == 2) 111 { 112 return evaluate( args.get(0), 113 args.get(1), 114 context.getNavigator() ); 115 } 116 117 throw new FunctionCallException( "starts-with() requires two arguments." ); 118 } 119 120 134 public static Boolean evaluate(Object strArg, 135 Object matchArg, 136 Navigator nav) 137 { 138 String str = StringFunction.evaluate( strArg, 139 nav ); 140 141 String match = StringFunction.evaluate( matchArg, 142 nav ); 143 144 return ( str.startsWith(match) 145 ? Boolean.TRUE 146 : Boolean.FALSE 147 ); 148 } 149 150 } 151 | Popular Tags |