Package net.sf.saxon.value

Examples of net.sf.saxon.value.AtomicValue


     * @return the result as a BooleanValue, or null to indicate the empty sequence
     * @throws XPathException on an error
     */

    public Item evaluateItem(XPathContext c) throws XPathException {
        AtomicValue sv0 = (AtomicValue)argument[0].evaluateItem(c);
        if (sv0==null) return null;

        Pattern re = regexp;
        if (re == null) {

            AtomicValue pat = (AtomicValue)argument[1].evaluateItem(c);
            if (pat==null) return null;

            String flags;
            if (argument.length==2) {
                flags = "";
            } else {
                AtomicValue sv2 = (AtomicValue)argument[2].evaluateItem(c);
                if (sv2==null) return null;
                flags = sv2.getStringValue();
            }

            try {
                String javaRegex = RegexTranslator.translate(
                        pat.getStringValue(), true);
View Full Code Here


                // Add the actual column values to be inserted

                int i = 1;
                for (int c=FIRST_COLUMN; c<arguments.length; c++) {
                    AtomicValue v = (AtomicValue)((SQLColumn.ColumnInstruction)arguments[c]).getSelectValue(context);

               // TODO: the values are all strings. There is no way of adding to a numeric column
                   String val = v.getStringValue();

                   // another hack: setString() doesn't seem to like single-character string values
                   if (val.length()==1) val += " ";
                   //System.err.println("Set statement parameter " + i + " to " + val);
                 ps.setObject(i++, val);
View Full Code Here

    public Iterator iterateSubExpressions() {
        return new MonoIterator(input);
    }

    public Item evaluateItem(XPathContext context) throws XPathException {
        AtomicValue av = (AtomicValue)input.evaluateItem(context);
        if (av==null) return null;
        StringValue sv = (StringValue)av.getPrimitiveValue();

        try {
            String parts[] = Name.getQNameParts(sv.getStringValue());
            String uri = nsContext.getURIForPrefix(parts[0], true);
            if (uri==null) {
View Full Code Here

    /**
    * Evaluate in a general context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        AtomicValue sv = (AtomicValue)argument[0].evaluateItem(c);
        if (sv==null) return StringValue.EMPTY_STRING;
        return new StringValue(normalize(sv.getStringValue()));
    }
View Full Code Here

    /**
    * Evaluate the expression
    */

    public Item evaluateItem(XPathContext context) throws XPathException {
        AtomicValue arg = (AtomicValue)argument[0].evaluateItem(context);

        if (arg == null) {
            return null;
        }

        return arg.getComponent(component);

    }
View Full Code Here

    /**
    * Evaluate in a general context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        AtomicValue sv = (AtomicValue)argument[0].evaluateItem(c);
        if (sv==null) return null;

        switch(operation) {
            case UPPERCASE:
                return new StringValue(sv.getStringValue().toUpperCase());
            case LOWERCASE:
                return new StringValue(sv.getStringValue().toLowerCase());
            default:
                throw new UnsupportedOperationException("Unknown function");
        }
    }
View Full Code Here

    * Evaluate the function to return an iteration of selected nodes.
    */

    public SequenceIterator iterate(XPathContext context) throws XPathException {
        SequenceIterator seq = argument[0].iterate(context);
        AtomicValue n0 = (AtomicValue)argument[1].evaluateItem(context);
        NumericValue n = (NumericValue)n0.getPrimitiveValue();
        int pos = (int)n.longValue();
        if (pos < 1) {
            return seq;
        }
        return new RemoveIterator(seq, pos);
View Full Code Here

     * @return true if the item is an instance of this type; false otherwise
    */

    public boolean matchesItem(Item item) {
        if (item instanceof AtomicValue) {
            AtomicValue value = (AtomicValue)item;
            AtomicType type = (AtomicType)value.getItemType();
            if (type.getFingerprint()==this.getFingerprint()) {
                // note, with compiled stylesheets one can have two objects representing
                // the same type, so comparing identity is not safe
                return true;
            }
View Full Code Here

    * @param context the given context for evaluation
    * @return a boolean representing the result of the numeric comparison of the two operands
    */

    public boolean effectiveBooleanValue(XPathContext context) throws XPathException {
        AtomicValue v1 = (AtomicValue)operand0.evaluateItem(context);
        if (v1==null) return false;
        AtomicValue v2 = (AtomicValue)operand1.evaluateItem(context);
        if (v2==null) return false;

        try {
            return GeneralComparison.compare(v1, operator, v2, comparer, backwardsCompatible, context);
        } catch (DynamicError e) {
View Full Code Here

    /**
    * Evaluate the expression
    */

    public Item evaluateItem(XPathContext context) throws XPathException {
        AtomicValue value = (AtomicValue)operand.evaluateItem(context);
        if (value==null) {
            if (allowEmpty) {
                return null;
            } else {
                DynamicError e = new DynamicError("Cast does not allow an empty sequence");
                e.setXPathContext(context);
                throw e;
            }
        }
        try {
            return value.convert(targetType, context);
        } catch (XPathException err) {
            // add location information
            dynamicError(err.getMessage(), context);
            return null;
        }
View Full Code Here

TOP

Related Classes of net.sf.saxon.value.AtomicValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.