1 61 62 package org.jaxen.function; 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 71 83 public class ContainsFunction implements Function 84 { 85 86 89 public ContainsFunction() {} 90 91 109 public Object call(Context context, 110 List args) throws FunctionCallException 111 { 112 if (args.size() == 2) 113 { 114 return evaluate(args.get(0), 115 args.get(1), 116 context.getNavigator() ); 117 } 118 119 throw new FunctionCallException("contains() requires two arguments."); 120 } 121 122 135 public static Boolean evaluate(Object strArg, 136 Object matchArg, 137 Navigator nav) 138 { 139 String str = StringFunction.evaluate( strArg, 140 nav ); 141 142 String match = StringFunction.evaluate( matchArg, 143 nav ); 144 145 return ( ( str.indexOf(match) >= 0) 146 ? Boolean.TRUE 147 : Boolean.FALSE 148 ); 149 } 150 } 151 | Popular Tags |