ref.takingMethod(new StringFunction() { public int func(String param) { // body } });
new BooleanFunction() ); new CeilingFunction() ); new ConcatFunction() ); new ContainsFunction() ); new CountFunction() ); new FalseFunction() ); new FloorFunction() ); new IdFunction() ); new LangFunction() ); new LastFunction() ); new LocalNameFunction() ); new NameFunction() ); new NamespaceUriFunction() ); new NormalizeSpaceFunction() ); new NotFunction() );
private boolean evaluateObjectObject( Object lhs, Object rhs, Navigator nav ) { if( eitherIsBoolean( lhs, rhs ) ) { return evaluateObjectObject( BooleanFunction.evaluate( lhs, nav ), BooleanFunction.evaluate( rhs, nav ) ); } else if( eitherIsNumber( lhs, rhs ) ) { return evaluateObjectObject( NumberFunction.evaluate( lhs, nav ), NumberFunction.evaluate( rhs, nav ) ); } else { return evaluateObjectObject( StringFunction.evaluate( lhs, nav ), StringFunction.evaluate( rhs, nav ) ); } }
Navigator nav) String str = StringFunction.evaluate( strArg, nav ); while (read < buffer.length) if (isXMLSpace(buffer[read])) while(read < buffer.length && isXMLSpace(buffer[read]));
private boolean evaluateObjectObject( Object lhs, Object rhs, Navigator nav ) { if( lhs == null || rhs == null ) { return false; } Double lhsNum = NumberFunction.evaluate( lhs, nav ); Double rhsNum = NumberFunction.evaluate( rhs, nav ); if( NumberFunction.isNaN( lhsNum ) || NumberFunction.isNaN( rhsNum ) ) { return false; } return evaluateDoubleDouble( lhsNum, rhsNum ); }
/** * Returns <code>Boolean.TRUE</code> if the boolean value of * <code>obj</code> is false, and <code>Boolean.FALSE</code> otherwise. * The boolean value is calculated as if by the XPath <code>boolean</code> * function. * * @param obj the object whose boolean value is inverted * @param nav the <code>Navigator</code> used to calculate the boolean value of <code>obj</code> * * @return <code>Boolean.TRUE</code> if the boolean value of * <code>obj</code> is false, and <code>Boolean.FALSE</code> otherwise */ public static Boolean evaluate(Object obj, Navigator nav) { return ( ( BooleanFunction.evaluate( obj, nav ).booleanValue() ) ? Boolean.FALSE : Boolean.TRUE ); }
/** Returns the smallest integer greater than or equal to the argument. * If necessary, the argument is first converted to a <code>Double</code> * as if by the XPath <code>number()</code> function. * * @param obj the object whose ceiling is returned * @param nav ignored * * @return a <code>Double</code> containing the smallest integer * greater than or equal to <code>obj</code> */ public static Double evaluate(Object obj, Navigator nav) { Double value = NumberFunction.evaluate( obj, nav ); return new Double( Math.ceil( value.doubleValue() ) ); } }
/** Returns <code>Boolean.TRUE</code> * * @param context ignored * @param args an empty list * * @return <code>Boolean.TRUE</code> * * @throws FunctionCallException if <code>args</code> is not empty */ public Object call(Context context, List args) throws FunctionCallException { if (args.size() == 0) { return evaluate(); } throw new FunctionCallException( "true() requires no arguments." ); }
/** Returns <code>Boolean.FALSE</code> * * @param context the context at the point in the * expression when the function is called * @param args an empty list * * @return <code>Boolean.FALSE</code> * * @throws FunctionCallException if <code>args</code> is not empty */ public Object call(Context context, List args) throws FunctionCallException { if (args.size() == 0) { return evaluate(); } throw new FunctionCallException( "false() requires no arguments." ); }
/** * <p> * Returns the number of nodes in the specified node-set. * </p> * @param context ignored * @param args the function arguments * * @return a <code>Double</code> giving the integral number of items in the first argument * * @throws FunctionCallException if args does not have exactly one * item; or that item is not a <code>List</code> */ public Object call(Context context, List args) throws FunctionCallException { if (args.size() == 1) { return evaluate( args.get(0) ); } throw new FunctionCallException( "count() requires one argument." ); }
/** * Returns the position of the context node in the context node-set. * * @param context the context at the point in the * expression where the function is called * @param args an empty list * * @return a <code>Double</code> containing the context position * * @throws FunctionCallException if <code>args</code> is not empty * * @see Context#getSize() */ public Object call(Context context, List args) throws FunctionCallException { if ( args.size() == 0 ) { return evaluate( context ); } throw new FunctionCallException( "position() does not take any arguments." ); }
/** * 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); } }
/** Returns the largest integer less than or equal to the argument. * If necessary, the argument is first converted to a <code>Double</code> * as if by the XPath <code>number()</code> function. * * @param obj the object whose floor is returned * @param nav ignored * * @return a <code>Double</code> containing the largest integer less * than or equal to <code>obj</code> */ public static Double evaluate(Object obj, Navigator nav) { Double value = NumberFunction.evaluate( obj, nav ); return new Double( Math.floor( value.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); } }
/** * 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 ); }
/** * <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 ); } }