ref.takingMethod(new StringFunction() { public int func(String param) { // body } });
return stringValue(((Boolean) obj).booleanValue()); return stringValue(((Number) obj).doubleValue());
/** * Converts the given string value to upper case using an optional Locale * * @param strArg the value which gets converted to a String * @param locale the Locale to use for the conversion or null if * English should be used * @param nav the Navigator to use */ public static String evaluate(Object strArg, Locale locale, Navigator nav) { String str = StringFunction.evaluate( strArg, nav ); // it might be possible to use the xml:lang attribute to // pick a default locale if (locale == null) locale = Locale.ENGLISH; return str.toUpperCase(locale); } }
new StringFunction() );
/** * Converts the given string value to lower case using an optional Locale * * @param strArg the value which gets converted to a String * @param locale the Locale to use for the conversion or null * English should be used * @param nav the Navigator to use */ public static String evaluate(Object strArg, Locale locale, Navigator nav) { String str = StringFunction.evaluate( strArg, nav ); // it might be possible to use the xml:lang attribute to // pick a default locale if (locale == null) locale = Locale.ENGLISH; return str.toLowerCase(locale); } }
"string", new StringFunction());
/** * Returns true if the string-value of <code>strArg</code> * starts with the string-value of <code>matchArg</code>. * Otherwise it returns false. * * @param strArg the object whose string-value searched for the prefix * @param matchArg the object whose string-value becomes the prefix string to compare against * @param nav the navigator used to calculate the string-values of the arguments * * @return <code>Boolean.TRUE</code> if the string-value of <code>strArg</code> * starts with the string-value of <code>matchArg</code>; * otherwise <code>Boolean.FALSE</code> * */ public static Boolean evaluate(Object strArg, Object matchArg, Navigator nav) { String str = StringFunction.evaluate( strArg, nav ); String match = StringFunction.evaluate( matchArg, nav ); return ( str.startsWith(match) ? Boolean.TRUE : Boolean.FALSE ); }
"string", new StringFunction());
/** * <p>Returns true if the first string contains the second string; false otherwise. * If necessary one or both arguments are converted to a string as if by the XPath * <code>string()</code> function. * </p> * * @param strArg the containing string * @param matchArg the contained string * @param nav used to calculate the string-values of the first two arguments * * @return <code>Boolean.TRUE</code> if true if the first string contains * the second string; <code>Boolean.FALSE</code> otherwise. */ public static Boolean evaluate(Object strArg, Object matchArg, Navigator nav) { String str = StringFunction.evaluate( strArg, nav ); String match = StringFunction.evaluate( matchArg, nav ); return ( ( str.indexOf(match) >= 0) ? Boolean.TRUE : Boolean.FALSE ); } }
private static Boolean evaluate(List contextNodes, Object lang, Navigator nav) throws UnsupportedAxisException { return evaluate(contextNodes.get(0), StringFunction.evaluate(lang, nav), nav) ? Boolean.TRUE : Boolean.FALSE; }
/** * Converts each item in the list to a string and returns the * concatenation of these strings. * If necessary, each item is first converted to a <code>String</code> * as if by the XPath <code>string()</code> function. * * @param list the items to be concatenated * @param nav ignored * * @return the concatenation of the arguments */ public static String evaluate(List list, Navigator nav) { StringBuffer result = new StringBuffer(); Iterator argIter = list.iterator(); while ( argIter.hasNext() ) { result.append( StringFunction.evaluate( argIter.next(), nav ) ); } return result.toString(); } }
public Object call(Context context, List args) throws FunctionCallException { if (args.size() == 1) { Navigator nav = context.getNavigator(); String url = StringFunction.evaluate( args.get( 0 ), nav ); return evaluate( url, nav ); } throw new FunctionCallException( "document() requires one argument." ); }
Iterator iter = ((List)arg).iterator(); while (iter.hasNext()) { String id = StringFunction.evaluate(iter.next(), nav); nodes.addAll( evaluate( contextNodes, id, nav ) ); String ids = StringFunction.evaluate(arg, nav); StringTokenizer tok = new StringTokenizer(ids, " \t\n\r"); while (tok.hasMoreTokens()) {
String text = StringFunction.evaluate( value, navigator ); if (text != null && text.length() > 0)
/** * Returns the string-value of <code>args.get(0)</code> * or of the context node if <code>args</code> is empty. * * @param context the context at the point in the * expression where the function is called * @param args list with zero or one element * * @return a <code>String</code> * * @throws FunctionCallException if <code>args</code> has more than one item */ public Object call(Context context, List args) throws FunctionCallException { int size = args.size(); if ( size == 0 ) { return evaluate( context.getNodeSet(), context.getNavigator() ); } else if ( size == 1 ) { return evaluate( args.get(0), context.getNavigator() ); } throw new FunctionCallException( "string() takes at most argument." ); }
String str = StringFunction.evaluate( obj, nav );