Examples of StringValue


Examples of client.net.sf.saxon.ce.value.StringValue

    /**
    * Evaluate in a general context
    */

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

        byte fb = Normalizer.C;
        if (argument.length == 2) {
            String form = Whitespace.trim(argument[1].evaluateAsString(c));
            if (form.equalsIgnoreCase("NFC")) {
                fb = Normalizer.C;
            } else if (form.equalsIgnoreCase("NFD")) {
                fb = Normalizer.D;
            } else if (form.equalsIgnoreCase("NFKC")) {
                fb = Normalizer.KC;
            } else if (form.equalsIgnoreCase("NFKD")) {
                fb = Normalizer.KD;
            } else if (form.length() == 0) {
                return sv;
            } else {
                dynamicError("Normalization form " + form + " is not supported", "FOCH0003", c);
            }
        }

        // fast path for ASCII strings: normalization is a no-op
        boolean allASCII = true;
        CharSequence chars = sv.getStringValueCS();
        for (int i=chars.length()-1; i>=0; i--) {
            if (chars.charAt(i) > 127) {
                allASCII = false;
                break;
            }
        }
        if (allASCII) {
            return sv;
        }


        Normalizer norm = new Normalizer(fb, c.getConfiguration());
        CharSequence result = norm.normalize(sv.getStringValueCS());
        return StringValue.makeStringValue(result);
    }
View Full Code Here

Examples of client.net.sf.saxon.ce.value.StringValue

    * Evaluate the function
    */

    public Item evaluateItem(XPathContext context) throws XPathException {

        StringValue sv1 = (StringValue)argument[0].evaluateItem(context);
        if (sv1==null) {
            return StringValue.EMPTY_STRING;
        }

        StringValue sv2 = (StringValue)argument[1].evaluateItem(context);

        StringValue sv3 = (StringValue)argument[2].evaluateItem(context);

        int[] a1 = sv1.expand();
        int[] a2 = sv2.expand();
        int[] a3 = sv3.expand();

        int length1 = a1.length;
        int length2 = a2.length;
        FastStringBuffer sb = new FastStringBuffer(length1);
    inputLoop:
View Full Code Here

Examples of client.net.sf.saxon.ce.value.StringValue

     * @throws XPathException if a failure occurs evaluating the arguments
     */

    public Item evaluateItem(XPathContext context) throws XPathException {
        NodeInfo element = (NodeInfo)argument[1].evaluateItem(context);
        StringValue p = (StringValue)argument[0].evaluateItem(context);
        String prefix;
        if (p == null) {
            prefix = "";
        } else {
            prefix = p.getStringValue();
        }
        NamespaceResolver resolver = new InscopeNamespaceResolver(element);
        String uri = resolver.getURIForPrefix(prefix, true);
        if (uri == null) {
            return null;
View Full Code Here

Examples of client.net.sf.saxon.ce.value.StringValue

    public CharSequence evaluateAsString(XPathContext context) throws XPathException {
        Item o = evaluateItem(context);
//        if (o instanceof AtomicValue && !((AtomicValue)o).hasBuiltInType()) {
//            o = ((AtomicValue) o).getPrimitiveValue();
//        }
        StringValue value = (StringValue) o;  // the ClassCastException is deliberate
        if (value == null) return "";
        return value.getStringValue();
    }
View Full Code Here

Examples of client.net.sf.saxon.ce.value.StringValue

    @SuppressWarnings("rawtypes")
  public static SequenceIterator convertFromJavaScript(Object jsValue, Configuration config) {
        if (jsValue == null) {
            return EmptyIterator.getInstance();
        } else if (jsValue instanceof String) {
            return SingletonIterator.makeIterator(new StringValue((String)jsValue));
        } else if (jsValue instanceof Double) {
            return SingletonIterator.makeIterator(new DoubleValue((Double)jsValue));
        } else if (jsValue instanceof Boolean) {
            return SingletonIterator.makeIterator(BooleanValue.get((Boolean)jsValue));
        } else if (!(jsValue instanceof JavaScriptObject)) {
View Full Code Here

Examples of client.net.sf.saxon.ce.value.StringValue

        if (a == null) {
            return (b == null ? 0 : -1);
        } else if (b == null) {
            return +1;
        }
        StringValue as = (StringValue)a;
        StringValue bs = (StringValue)b;
        if (as.containsSurrogatePairs() || bs.containsSurrogatePairs()) {
            return collator.compareCS(as.getStringValueCS(), bs.getStringValueCS());
        } else {
            // optimize to use UTF-16 binary comparison
            return as.getStringValue().compareTo(bs.getStringValue());
        }
    }
View Full Code Here

Examples of client.net.sf.saxon.ce.value.StringValue

    * @return <0 if a<b, 0 if a=b, >0 if a>b
    * @throws ClassCastException if either value is not xs:string or a subtype
    */

    public boolean comparesEqual(AtomicValue a, AtomicValue b) {
        StringValue as = (StringValue)a;
        StringValue bs = (StringValue)b;
        return as.codepointEquals(bs);
    }
View Full Code Here

Examples of client.net.sf.saxon.ce.value.StringValue

    * function, and vice versa. There is no requirement that the
    * comparison keys should reflect the ordering of the underlying objects.
    */

    public ComparisonKey getComparisonKey(AtomicValue a) {
        StringValue as = (StringValue)a;
        return new ComparisonKey(StandardNames.XS_STRING, as.getStringValue());
    }
View Full Code Here

Examples of client.net.sf.saxon.ce.value.StringValue

    private StringValue toStringValue(AtomicValue a) {
        if (a instanceof StringValue) {
            return ((StringValue)a);
        } else {
            return new StringValue((a == null ? "" : a.getStringValue()));
        }
    }
View Full Code Here

Examples of client.net.sf.saxon.ce.value.StringValue

        // If either operand is a string, or if both are untyped atomic, convert
        // both operands to strings and compare them

        if (t0.equals(BuiltInAtomicType.STRING) || t1.equals(BuiltInAtomicType.STRING) ||
                (t0.equals(BuiltInAtomicType.UNTYPED_ATOMIC) && t1.equals(BuiltInAtomicType.UNTYPED_ATOMIC))) {
            StringValue s0 = (StringValue)a0.convert(BuiltInAtomicType.STRING, true).asAtomic();
            StringValue s1 = (StringValue)a1.convert(BuiltInAtomicType.STRING, true).asAtomic();
            return ValueComparison.compare(s0, operator, s1, comparer, false);
        }

        // If either operand is untyped atomic,
        // convert it to the type of the other operand, and compare
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.