1 61 62 package org.jaxen.function.ext; 63 64 import java.util.List ; 65 66 import org.jaxen.Context; 67 import org.jaxen.Function; 68 import org.jaxen.FunctionCallException; 69 import org.jaxen.Navigator; 70 import org.jaxen.function.StringFunction; 71 72 77 public class EndsWithFunction implements Function 78 { 79 80 public Object call(Context context, 81 List args) throws FunctionCallException 82 { 83 if (args.size() == 2) 84 { 85 return evaluate( args.get(0), 86 args.get(1), 87 context.getNavigator() ); 88 } 89 90 throw new FunctionCallException( "ends-with() requires two arguments." ); 91 } 92 93 public static Boolean evaluate(Object strArg, 94 Object matchArg, 95 Navigator nav) 96 { 97 String str = StringFunction.evaluate( strArg, 98 nav ); 99 100 String match = StringFunction.evaluate( matchArg, 101 nav ); 102 103 return ( str.endsWith(match) 104 ? Boolean.TRUE 105 : Boolean.FALSE 106 ); 107 } 108 } 109 | Popular Tags |