Search in sources :

Example 11 with AtomicValue

use of org.sirix.service.xml.xpath.AtomicValue in project sirix by sirixdb.

the class AbstractFunction method evaluate.

/**
 * {@inheritDoc}
 */
@Override
public void evaluate() throws SirixXPathException {
    // compute the function's result
    final byte[] value = computeResult();
    // create an atomic value, add it to the list and move the cursor to it.
    final int itemKey = getTrx().getItemList().addItem(new AtomicValue(value, mReturnType));
    mKey = itemKey;
}
Also used : AtomicValue(org.sirix.service.xml.xpath.AtomicValue)

Example 12 with AtomicValue

use of org.sirix.service.xml.xpath.AtomicValue in project sirix by sirixdb.

the class Function method fnnumber.

/**
 * Returns the value of the context item after atomization converted to an xs:double.
 *
 * @param rtx Read Transaction.
 * @return fnnumber boolean.
 */
public static boolean fnnumber(final XdmNodeReadTrx rtx) {
    // TODO: add error handling
    final AtomicValue item = new AtomicValue(rtx.getValue().getBytes(), rtx.keyForName("xs:double"));
    final int itemKey = rtx.getItemList().addItem(item);
    rtx.moveTo(itemKey);
    return true;
}
Also used : AtomicValue(org.sirix.service.xml.xpath.AtomicValue)

Example 13 with AtomicValue

use of org.sirix.service.xml.xpath.AtomicValue in project sirix by sirixdb.

the class Function method exactlyOne.

public static boolean exactlyOne(final XdmNodeReadTrx rtx, final AbstractAxis axis) throws SirixXPathException {
    if (axis.hasNext()) {
        if (axis.hasNext()) {
            throw EXPathError.FORG0005.getEncapsulatedException();
        } else {
            final int itemKey = rtx.getItemList().addItem(new AtomicValue(true));
            // only once
            rtx.moveTo(itemKey);
        }
    } else {
        throw EXPathError.FORG0005.getEncapsulatedException();
    }
    return true;
}
Also used : AtomicValue(org.sirix.service.xml.xpath.AtomicValue)

Example 14 with AtomicValue

use of org.sirix.service.xml.xpath.AtomicValue in project sirix by sirixdb.

the class Function method empty.

public static boolean empty(final XdmNodeReadTrx rtx, final AbstractAxis axis) {
    final boolean result = !axis.hasNext();
    final int itemKey = rtx.getItemList().addItem(new AtomicValue(result));
    rtx.moveTo(itemKey);
    return true;
}
Also used : AtomicValue(org.sirix.service.xml.xpath.AtomicValue)

Example 15 with AtomicValue

use of org.sirix.service.xml.xpath.AtomicValue in project sirix by sirixdb.

the class Function method exists.

public static boolean exists(final XdmNodeReadTrx rtx, final AbstractAxis axis) {
    final boolean result = axis.hasNext();
    final int itemKey = rtx.getItemList().addItem(new AtomicValue(result));
    rtx.moveTo(itemKey);
    return true;
}
Also used : AtomicValue(org.sirix.service.xml.xpath.AtomicValue)

Aggregations

AtomicValue (org.sirix.service.xml.xpath.AtomicValue)47 Test (org.junit.Test)12 AbstractAxis (org.sirix.service.xml.xpath.AbstractAxis)10 LiteralExpr (org.sirix.service.xml.xpath.expr.LiteralExpr)10 Type (org.sirix.service.xml.xpath.types.Type)7 XPathError (org.sirix.service.xml.xpath.XPathError)6 ErrorType (org.sirix.service.xml.xpath.XPathError.ErrorType)6 XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)4 Axis (org.sirix.api.Axis)3 SirixXPathException (org.sirix.exception.SirixXPathException)3 ArrayList (java.util.ArrayList)1 DescendantAxis (org.sirix.axis.DescendantAxis)1 SingleType (org.sirix.service.xml.xpath.SingleType)1