/** * Cast result object to a boolean, but allow side effects, such as the * incrementing of an iterator. * * @return True if there is a next node in the nodeset */ public boolean boolWithSideEffects() throws javax.xml.transform.TransformerException { return bool(); }
/** * Cast result object to a boolean, but allow side effects, such as the * incrementing of an iterator. * * @return True if there is a next node in the nodeset */ public boolean boolWithSideEffects() throws javax.xml.transform.TransformerException { return bool(); }
/** * Execute the function. The function must return * a valid object. * @param xctxt The current execution context. * @return A valid XObject. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { return m_arg0.execute(xctxt).bool() ? XBoolean.S_TRUE : XBoolean.S_FALSE; }
/** * Execute the function. The function must return * a valid object. * @param xctxt The current execution context. * @return A valid XObject. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { return m_arg0.execute(xctxt).bool() ? XBoolean.S_FALSE : XBoolean.S_TRUE; } }
/** * Execute the function. The function must return * a valid object. * @param xctxt The current execution context. * @return A valid XObject. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { return m_arg0.execute(xctxt).bool() ? XBoolean.S_TRUE : XBoolean.S_FALSE; }
/** * Evaluate expression to a boolean. * * * @param xctxt The XPath runtime context. * @return false * * @throws javax.xml.transform.TransformerException */ public boolean bool(XPathContext xctxt) throws javax.xml.transform.TransformerException { return execute(xctxt).bool(); }
/** * Execute the function. The function must return * a valid object. * @param xctxt The current execution context. * @return A valid XObject. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { return m_arg0.execute(xctxt).bool() ? XBoolean.S_FALSE : XBoolean.S_TRUE; } }
/** * Evaluate expression to a boolean. * * * @param xctxt The XPath runtime context. * @return false * * @throws javax.xml.transform.TransformerException */ public boolean bool(XPathContext xctxt) throws javax.xml.transform.TransformerException { return execute(xctxt).bool(); }
/** * Apply the operation to two operands, and return the result. * * * @param right non-null reference to the evaluated right operand. * * @return non-null reference to the XObject that represents the result of the operation. * * @throws javax.xml.transform.TransformerException */ public XObject operate(XObject right) throws javax.xml.transform.TransformerException { if (XObject.CLASS_BOOLEAN == right.getType()) return right; else return right.bool() ? XBoolean.S_TRUE : XBoolean.S_FALSE; }
/** * Tell if two objects are functionally equal. * * @param obj2 Object to compare to this * * @return True if the two objects are equal * * @throws javax.xml.transform.TransformerException */ public boolean equals(XObject obj2) { try { return m_val == obj2.bool(); } catch(javax.xml.transform.TransformerException te) { throw new org.apache.xml.utils.WrappedRuntimeException(te); } } }
/** * Apply the operation to two operands, and return the result. * * * @param right non-null reference to the evaluated right operand. * * @return non-null reference to the XObject that represents the result of the operation. * * @throws javax.xml.transform.TransformerException */ public XObject operate(XObject right) throws javax.xml.transform.TransformerException { if (XObject.CLASS_BOOLEAN == right.getType()) return right; else return right.bool() ? XBoolean.S_TRUE : XBoolean.S_FALSE; }
/** * OR two expressions and return the boolean result. Override * superclass method for optimization purposes. * * @param xctxt The runtime execution context. * * @return {@link org.apache.xpath.objects.XBoolean#S_TRUE} or * {@link org.apache.xpath.objects.XBoolean#S_FALSE}. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { XObject expr1 = m_left.execute(xctxt); if (!expr1.bool()) { XObject expr2 = m_right.execute(xctxt); return expr2.bool() ? XBoolean.S_TRUE : XBoolean.S_FALSE; } else return XBoolean.S_TRUE; }
/** * AND two expressions and return the boolean result. Override * superclass method for optimization purposes. * * @param xctxt The runtime execution context. * * @return {@link org.apache.xpath.objects.XBoolean#S_TRUE} or * {@link org.apache.xpath.objects.XBoolean#S_FALSE}. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { XObject expr1 = m_left.execute(xctxt); if (expr1.bool()) { XObject expr2 = m_right.execute(xctxt); return expr2.bool() ? XBoolean.S_TRUE : XBoolean.S_FALSE; } else return XBoolean.S_FALSE; }
/** * Tell if two objects are functionally equal. * * @param obj2 Object to compare to this * * @return True if the two objects are equal * * @throws javax.xml.transform.TransformerException */ public boolean equals(XObject obj2) { try { return m_val == obj2.bool(); } catch(javax.xml.transform.TransformerException te) { throw new org.apache.xml.utils.WrappedRuntimeException(te); } } }
/** * AND two expressions and return the boolean result. Override * superclass method for optimization purposes. * * @param xctxt The runtime execution context. * * @return {@link org.apache.xpath.objects.XBoolean#S_TRUE} or * {@link org.apache.xpath.objects.XBoolean#S_FALSE}. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { XObject expr1 = m_left.execute(xctxt); if (expr1.bool()) { XObject expr2 = m_right.execute(xctxt); return expr2.bool() ? XBoolean.S_TRUE : XBoolean.S_FALSE; } else return XBoolean.S_FALSE; }
/** * OR two expressions and return the boolean result. Override * superclass method for optimization purposes. * * @param xctxt The runtime execution context. * * @return {@link org.apache.xpath.objects.XBoolean#S_TRUE} or * {@link org.apache.xpath.objects.XBoolean#S_FALSE}. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { XObject expr1 = m_left.execute(xctxt); if (!expr1.bool()) { XObject expr2 = m_right.execute(xctxt); return expr2.bool() ? XBoolean.S_TRUE : XBoolean.S_FALSE; } else return XBoolean.S_TRUE; }
return new Boolean( resultObject.bool());
/** * Tell if two objects are functionally equal. * * @param obj2 Object to compare to this * * @return True if the two objects are equal * * @throws javax.xml.transform.TransformerException */ public boolean equals(XObject obj2) { // In order to handle the 'all' semantics of // nodeset comparisons, we always call the // nodeset function. if (obj2.getType() == XObject.CLASS_NODESET) return obj2.equals(this); try { return m_val == obj2.bool(); } catch(javax.xml.transform.TransformerException te) { throw new org.apache.xml.utils.WrappedRuntimeException(te); } }
protected boolean evaluate(InputSource inputSource) { try { DocumentBuilder dbuilder = createDocumentBuilder(); Document doc = dbuilder.parse(inputSource); //An XPath expression could return a true or false value instead of a node. //eval() is a better way to determine the boolean value of the exp. //For compliance with legacy behavior where selecting an empty node returns true, //selectNodeIterator is attempted in case of a failure. CachedXPathAPI cachedXPathAPI = new CachedXPathAPI(); XObject result = cachedXPathAPI.eval(doc, xpath); if (result.bool()) return true; else { NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath); return (iterator.nextNode() != null); } } catch (Throwable e) { return false; } }
/** * @see org.w3c.dom.xpath.XPathResult#getBooleanValue() */ public boolean getBooleanValue() throws XPathException { if (getResultType() != BOOLEAN_TYPE) { String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_BOOLEAN, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)}); throw new XPathException(XPathException.TYPE_ERR,fmsg); // "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a boolean." } else { try { return m_resultObj.bool(); } catch (TransformerException e) { // Type check above should prevent this exception from occurring. throw new XPathException(XPathException.TYPE_ERR,e.getMessage()); } } }