1 61 62 63 package org.jaxen.function; 64 65 import java.util.Iterator ; 66 import java.util.List ; 67 68 import org.jaxen.Context; 69 import org.jaxen.Function; 70 import org.jaxen.FunctionCallException; 71 import org.jaxen.Navigator; 72 73 83 public class ConcatFunction implements Function 84 { 85 86 89 public ConcatFunction() {} 90 91 105 public Object call(Context context, 106 List args) throws FunctionCallException 107 { 108 if ( args.size() >= 2 ) 109 { 110 return evaluate( args, 111 context.getNavigator() ); 112 } 113 114 throw new FunctionCallException("concat() requires at least two arguments"); 115 } 116 117 128 public static String evaluate(List list, 129 Navigator nav) 130 { 131 StringBuffer result = new StringBuffer (); 132 Iterator argIter = list.iterator(); 133 while ( argIter.hasNext() ) 134 { 135 result.append( StringFunction.evaluate( argIter.next(), 136 nav ) ); 137 } 138 139 return result.toString(); 140 } 141 } 142 | Popular Tags |