1 61 62 package org.jaxen.function.ext; 63 64 import java.util.List ; 65 import java.util.Locale ; 66 67 import org.jaxen.Context; 68 import org.jaxen.FunctionCallException; 69 import org.jaxen.Navigator; 70 import org.jaxen.function.StringFunction; 71 72 89 public class LowerFunction extends LocaleFunctionSupport 90 { 91 92 public Object call(Context context, 93 List args) throws FunctionCallException 94 { 95 Navigator navigator = context.getNavigator(); 96 int size = args.size(); 97 if (size > 0) 98 { 99 Object text = args.get(0); 100 Locale locale = null; 101 if (size > 1) 102 { 103 locale = getLocale( args.get(1), navigator ); 104 } 105 return evaluate( text, locale, navigator ); 106 } 107 throw new FunctionCallException( "lower-case() requires at least one argument." ); 108 } 109 110 118 public static String evaluate(Object strArg, 119 Locale locale, 120 Navigator nav) 121 { 122 123 String str = StringFunction.evaluate( strArg, 124 nav ); 125 if (locale == null) locale = Locale.ENGLISH; 128 return str.toLowerCase(locale); 129 130 } 131 } 132 | Popular Tags |