public Object getDocument(String url) throws FunctionCallException { try { SAXBuilder builder = new SAXBuilder(); return builder.build( url ); } catch (Exception e) { throw new FunctionCallException( e.getMessage() ); } } }
/** * <p> * Returns the exception that caused this function call to fail. * Use <code>getCause</code> instead. * </p> * * @return the exception that caused this function call to fail * * @deprecated replaced by {@link #getCause()} */ public Throwable getNestedException() { return getCause(); }
/** * <p> * Returns the number of nodes in the specified node-set. * </p> * * @param obj a <code>List</code> of nodes * @return the integral number of items in the list * @throws FunctionCallException if obj is not a <code>List</code> */ public static Double evaluate(Object obj) throws FunctionCallException { if (obj instanceof List) { return new Double( ((List) obj).size() ); } throw new FunctionCallException("count() function can only be used for node-sets"); }
public Object getDocument(String uri) throws FunctionCallException { try { return getSAXReader().read( uri ); } catch (DocumentException e) { throw new FunctionCallException("Failed to parse document for URI: " + uri, e); } }
public Object call( Context context, List args ) throws FunctionCallException { if ( args.size() == 1 ) { return evaluate( context, args.get(0)); } throw new FunctionCallException( "evaluate() requires one argument" ); }
throw new FunctionCallException("JAXP setup error in document() function: " + e.getMessage(), e); throw new FunctionCallException("XML error in document() function: " + e.getMessage(), e); throw new FunctionCallException("I/O error in document() function: " + e.getMessage(), e);
public Object call(Context context, List args) throws FunctionCallException { if (args.size() == 2) { return evaluate( args.get(0), args.get(1), context.getNavigator() ); } throw new FunctionCallException( "ends-with() requires two arguments." ); }
/** 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." ); }
char low = data[i+1]; if (low < 0xDC00 || low > 0xDFFF) { throw new FunctionCallException("Bad surrogate pair in string " + str); throw new FunctionCallException("Bad surrogate pair in string " + str);
/** * Returns the number of nodes 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 size * * @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( "last() requires no arguments." ); }
throw new FunctionCallException("Mismatched surrogate pair in translate function"); throw new FunctionCallException("High surrogate without low surrogate at end of string passed to translate function");
throw new FunctionCallException("The argument to the sum function must be a node-set");
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." ); }
/** Returns the smallest integer greater than or equal to a number. * * @param context the context at the point in the * expression when the function is called * @param args a list with exactly one item which will be converted to a * <code>Double</code> as if by the XPath <code>number()</code> function * * @return a <code>Double</code> containing the smallest integer greater than or equal * <code>args.get(0)</code> * * @throws FunctionCallException if <code>args</code> has more or less than one item */ public Object call(Context context, List args) throws FunctionCallException { if (args.size() == 1) { return evaluate( args.get(0), context.getNavigator() ); } throw new FunctionCallException("ceiling() requires one argument."); }
/** Returns a copy of the first argument in which * characters found in the second argument are replaced by * corresponding characters from the third argument. * * @param context the context at the point in the * expression when the function is called * @param args a list that contains exactly three items * * @return a <code>String</code> built from <code>args.get(0)</code> * in which occurrences of characters in <code>args.get(1)</code> * are replaced by the corresponding characters in <code>args.get(2)</code> * * @throws FunctionCallException if <code>args</code> does not have exactly three items */ public Object call(Context context, List args) throws FunctionCallException { if (args.size() == 3) { return evaluate( args.get(0), args.get(1), args.get(2), context.getNavigator() ); } throw new FunctionCallException( "translate() requires three arguments." ); }
/** Convert the argument to a <code>Boolean</code> * * @param context the context at the point in the * expression when the function is called * @param args a list with exactly one item which will be converted to a * <code>Boolean</code> * * @return the result of evaluating the function; * <code>Boolean.TRUE</code> or <code>Boolean.FALSE</code> * * @throws FunctionCallException if <code>args</code> has more or less than one item */ public Object call(Context context, List args) throws FunctionCallException { if ( args.size() == 1 ) { return evaluate( args.get(0), context.getNavigator() ); } throw new FunctionCallException("boolean() requires one argument"); }
/** Returns the sum of its arguments. * * @param context the context at the point in the * expression when the function is called * @param args a list that contains exactly one item, also a <code>List</code> * * @return a <code>Double</code> containing the sum of the items in <code>args.get(0)</code> * * @throws FunctionCallException if <code>args</code> has more or less than one item; * or if the first argument is not a <code>List</code> */ public Object call(Context context, List args) throws FunctionCallException { if (args.size() == 1) { return evaluate( args.get(0), context.getNavigator() ); } throw new FunctionCallException( "sum() requires one argument." ); }