/** @return true if the pattern matches the given node */ public boolean matches( Object node, Context context ) { return context.getNavigator().isText( node ); }
/** @return true if the pattern matches the given node */ public boolean matches( Object node, Context context ) { return nodeType == context.getNavigator().getNodeType( node ); }
/** @return true if the pattern matches the given node */ public boolean matches( Object node, Context context ) { short type = context.getNavigator().getNodeType( node ); return type == ELEMENT_NODE || type == TEXT_NODE || type == COMMENT_NODE || type == PROCESSING_INSTRUCTION_NODE; }
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." ); }
public Object evaluate(Context context) throws JaxenException { Number number = NumberFunction.evaluate( getExpr().evaluate( context ), context.getNavigator() ); return new Double( number.doubleValue() * -1 ); }
public Object evaluate( Context context ) throws JaxenException { Number lhsValue = NumberFunction.evaluate( getLHS().evaluate( context ), context.getNavigator() ); Number rhsValue = NumberFunction.evaluate( getRHS().evaluate( context ), context.getNavigator() ); double result = lhsValue.doubleValue() * rhsValue.doubleValue(); return new Double( result ); }
public Object evaluate( Context context ) throws JaxenException { Number lhsValue = NumberFunction.evaluate( getLHS().evaluate( context ), context.getNavigator() ); Number rhsValue = NumberFunction.evaluate( getRHS().evaluate( context ), context.getNavigator() ); double result = lhsValue.doubleValue() % rhsValue.doubleValue(); return new Double( result ); }
public Object evaluate(Context context) throws JaxenException { Number lhsValue = NumberFunction.evaluate( getLHS().evaluate( context ), context.getNavigator() ); Number rhsValue = NumberFunction.evaluate( getRHS().evaluate( context ), context.getNavigator() ); double result = lhsValue.doubleValue() + rhsValue.doubleValue(); return new Double( result ); }
/** 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."); }
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." ); }
public Object evaluate(Context context) throws JaxenException { Number lhsValue = NumberFunction.evaluate( getLHS().evaluate( context ), context.getNavigator() ); Number rhsValue = NumberFunction.evaluate( getRHS().evaluate( context ), context.getNavigator() ); double result = lhsValue.doubleValue() / rhsValue.doubleValue(); return new Double( result ); }
public Object evaluate(Context context) throws JaxenException { Number lhsValue = NumberFunction.evaluate( getLHS().evaluate( context ), context.getNavigator() ); Number rhsValue = NumberFunction.evaluate( getRHS().evaluate( context ), context.getNavigator() ); double result = lhsValue.doubleValue() - rhsValue.doubleValue(); return new Double( result ); }
public Object call(Context context, List args) throws FunctionCallException { Navigator navigator = context.getNavigator(); int size = args.size(); if (size > 0) { Object text = args.get(0); Locale locale = null; if (size > 1) { locale = getLocale( args.get(1), navigator ); } return evaluate( text, locale, navigator ); } throw new FunctionCallException( "lower-case() requires at least one argument." ); }
public Object call(Context context, List args) throws FunctionCallException { Navigator navigator = context.getNavigator(); int size = args.size(); if (size > 0) { Object text = args.get(0); Locale locale = null; if (size > 1) { locale = getLocale( args.get(1), navigator ); } return evaluate( text, locale, navigator ); } throw new FunctionCallException( "upper-case() requires at least one argument." ); }
/** * Concatenates the arguments and returns the resulting string. * Non-string items are first converted to strings as if by the * XPath <code>string()<code> function. * * @param context the context at the point in the * expression when the function is called * @param args the list of strings to be concatenated * * @return a <code>String</code> containing the concatenation of the items * of <code>args</code> * * @throws FunctionCallException if <code>args</code> has less than two items */ public Object call(Context context, List args) throws FunctionCallException { if ( args.size() >= 2 ) { return evaluate( args, context.getNavigator() ); } throw new FunctionCallException("concat() requires at least two arguments"); }
/** * Returns a list of the nodes with the specified IDs. * * @param context the context at the point in the * expression when the function is called * @param args a list with exactly one item which is either a string * a node-set * * @return a <code>List</code> containing the first node in document * with each of the specified IDs; or * an empty list if there are no such nodes * * @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( context.getNodeSet(), args.get(0), context.getNavigator() ); } throw new FunctionCallException( "id() requires one argument" ); }
/** Returns the URI of the current prefix or "" if no URI can be found */ protected String getURI(Object node, Context context) { String uri = context.getNavigator().translateNamespacePrefixToUri( prefix, node ); if ( uri == null ) { uri = context.getContextSupport().translateNamespacePrefixToUri( prefix ); } if ( uri == null ) { uri = ""; } return uri; } }
/** @return true if the pattern matches the given node */ public boolean matches( Object node, Context context ) { Navigator navigator = context.getNavigator(); String uri = getURI( node, context ); if ( nodeType == Pattern.ELEMENT_NODE ) { return navigator.isElement( node ) && uri.equals( navigator.getElementNamespaceUri( node ) ); } else if ( nodeType == Pattern.ATTRIBUTE_NODE ) { return navigator.isAttribute( node ) && uri.equals( navigator.getAttributeNamespaceUri( node ) ); } return false; }
public Object evaluate(Context context) throws JaxenException { Navigator nav = context.getNavigator(); Boolean lhsValue = BooleanFunction.evaluate( getLHS().evaluate( context ), nav ); if ( lhsValue.booleanValue() ) { return Boolean.TRUE; } // Short circuits are required in XPath. "The right operand is not // evaluated if the left operand evaluates to true." Boolean rhsValue = BooleanFunction.evaluate( getRHS().evaluate( context ), nav ); if ( rhsValue.booleanValue() ) { return Boolean.TRUE; } return Boolean.FALSE; }
public Object evaluate(Context context) throws JaxenException { Navigator nav = context.getNavigator(); Boolean lhsValue = BooleanFunction.evaluate( getLHS().evaluate( context ), nav ); if ( !lhsValue.booleanValue() ) { return Boolean.FALSE; } // Short circuits are required in XPath. "The right operand is not // evaluated if the left operand evaluates to false." Boolean rhsValue = BooleanFunction.evaluate( getRHS().evaluate( context ), nav ); if ( !rhsValue.booleanValue() ) { return Boolean.FALSE; } return Boolean.TRUE; }