Package client.net.sf.saxon.ce.functions

Source Code of client.net.sf.saxon.ce.functions.StringToCodepoints

package client.net.sf.saxon.ce.functions;

import client.net.sf.saxon.ce.expr.XPathContext;
import client.net.sf.saxon.ce.om.Item;
import client.net.sf.saxon.ce.om.SequenceIterator;
import client.net.sf.saxon.ce.trans.XPathException;
import client.net.sf.saxon.ce.tree.iter.ArrayIterator;
import client.net.sf.saxon.ce.tree.iter.EmptyIterator;
import client.net.sf.saxon.ce.value.IntegerValue;
import client.net.sf.saxon.ce.value.StringValue;

/**
* This class supports the function string-to-codepoints()
*/

public class StringToCodepoints extends SystemFunction {

    public StringToCodepoints newInstance() {
        return new StringToCodepoints();
    }

    public SequenceIterator iterate(XPathContext c) throws XPathException {
        Item item = argument[0].evaluateItem(c);
        if (item==null) {
            return EmptyIterator.getInstance();
        }
        int[] chars = ((StringValue)item).expand();
        IntegerValue[] codes = new IntegerValue[chars.length];
        for (int i=0; i<chars.length; i++) {
            codes[i] = new IntegerValue(chars[i]);
        }
        return new ArrayIterator(codes);
    }

}



// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
TOP

Related Classes of client.net.sf.saxon.ce.functions.StringToCodepoints

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.