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 87 public class SubstringAfterFunction implements Function 88 { 89 90 93 public SubstringAfterFunction() {} 94 95 96 111 public Object call(Context context, 112 List args) throws FunctionCallException 113 { 114 if (args.size() == 2) 115 { 116 return evaluate( args.get(0), 117 args.get(1), 118 context.getNavigator() ); 119 } 120 121 throw new FunctionCallException( "substring-after() requires two arguments." ); 122 } 123 124 125 140 public static String evaluate(Object strArg, 141 Object matchArg, 142 Navigator nav) 143 { 144 String str = StringFunction.evaluate( strArg, 145 nav ); 146 147 String match = StringFunction.evaluate( matchArg, 148 nav ); 149 150 int loc = str.indexOf(match); 151 152 if ( loc < 0 ) 153 { 154 return ""; 155 } 156 157 return str.substring(loc+match.length()); 158 } 159 } 160 | Popular Tags |