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 UpperFunction extends LocaleFunctionSupport 90 { 91 public Object call(Context context, 92 List args) throws FunctionCallException 93 { 94 Navigator navigator = context.getNavigator(); 95 int size = args.size(); 96 if (size > 0) 97 { 98 Object text = args.get(0); 99 Locale locale = null; 100 if (size > 1) 101 { 102 locale = getLocale( args.get(1), navigator ); 103 } 104 return evaluate( text, locale, navigator ); 105 } 106 throw new FunctionCallException( "upper-case() requires at least one argument." ); 107 } 108 109 117 public static String evaluate(Object strArg, 118 Locale locale, 119 Navigator nav) 120 { 121 122 String str = StringFunction.evaluate( strArg, 123 nav ); 124 if (locale == null) locale = Locale.ENGLISH; 127 return str.toUpperCase(locale); 128 } 129 } 130 | Popular Tags |