Package xbird.xquery.dm.value

Examples of xbird.xquery.dm.value.Sequence


            menu.add(new AbstractAction("Eval Expression (pull)") {
                public void actionPerformed(ActionEvent e) {
                    String selected = (String) cell.getUserObject();
                    XQExpression expr = sourceExprMap.get(selected);
                    DynamicContext dynEnv = new DynamicContext(statEnv);
                    final Sequence result;
                    try {
                        result = expr.eval(ValueSequence.EMPTY_SEQUENCE, dynEnv);
                    } catch (Exception ex) {
                        JOptionPane.showMessageDialog(frame, "eval failed!: " + ex.getMessage());
                        ex.printStackTrace();
                        return;
                    }
                    JOptionPane.showMessageDialog(frame, result.toString());
                }
            });
            menu.add(new AbstractAction("Print Tree") {
                public void actionPerformed(ActionEvent e) {
                    String selected = (String) cell.getUserObject();
View Full Code Here


        public Item next() {
            Entry<GroupKeys, GroupEntry> entry = _itor.next();
            entry.getKey().assignGroupingKeys();
            GroupEntry value = entry.getValue();
            value.assignNonGroupingVariables();
            Sequence postGroupingSeq = value.getValue();
            return SingleCollection.wrap(postGroupingSeq, _dynEnv);
        }
View Full Code Here

            // #2 distributed-compile
            body = distributedCompile(body, rm);
        }
        // #3 evaluation
        StaticContext statEnv = parser.getStaticContext();
        final Sequence result;
        try {
            result = body.eval(null, new DynamicContext(statEnv));
        } catch (XQueryException e) {
            throw new RemoteException("Evaluation failed.", e);
        }
View Full Code Here

        StopWatch sw = new StopWatch("[Xbird] " + queryFile);
        XQueryProcessor processor = new XQueryProcessor();
        XQueryModule mod = processor.parse(new FileInputStream(queryFile), new File(DOC_BASE).toURI());
        processor.compile(mod);
        System.err.println(mod.getExpression().toString());
        Sequence result = processor.execute(mod);
        StringWriter res_sw = new StringWriter();
        Serializer ser = new SAXSerializer(new SAXWriter(res_sw), res_sw);
        ser.emit(result);
        String swresult = sw.toString();
        long used = SystemUtils.getHeapUsedMemory();
View Full Code Here

                final int len = specs.length;
                final Item[] groupKeys = new Item[len];
                final Sequence[] rawKeys = new Sequence[len];
                for(int i = 0; i < len; i++) {
                    GroupingSpec spec = specs[i];
                    Sequence result = spec.getKeyExpr().eval(contextSeq, dynEnv);
                    Sequence atomized = result.atomize(dynEnv);
                    IFocus atomizedItor = atomized.iterator();

                    final Item groupKey;
                    if(atomizedItor.hasNext()) {
                        AtomicValue atom = (AtomicValue) atomizedItor.next();
                        if(atomizedItor.hasNext()) {
                            atomizedItor.closeQuietly();
                            throw new DynamicError("err:XQDY0095", "Illegal resulting value for a grouping variable: "
                                    + atomized);
                        }
                        groupKey = atom.asGroupingValue();
                    } else {
                        groupKey = ValueSequence.EMPTY_SEQUENCE;
                    }
                    atomizedItor.closeQuietly();

                    groupKeys[i] = groupKey;
                    rawKeys[i] = result;
                }

                final GroupKeys k = new GroupKeys(specs, groupKeys, rawKeys, dynEnv);
                final GroupEntry v = new GroupEntry(it, dynEnv);

                final GroupEntry prevEntry = map.put(k, v);
                if(prevEntry != null) {
                    v.setNonGroupingVaribales(prevEntry.getNonGroupingVaribales());

                    final Sequence prevValue = prevEntry.getValue();
                    if(prevValue instanceof ValueSequence) {
                        ((ValueSequence) prevValue).addItem(it);
                        v.setValue(prevValue);
                    } else {
                        final List<Item> list = new ArrayList<Item>(4);
View Full Code Here

        public void setNonGroupingVaribales(Map<BindingVariable, Sequence> nonGroupingVaribales) {
            this.nonGroupingVaribales = nonGroupingVaribales;
        }

        public void putNonGroupingVariable(BindingVariable var) throws DynamicError {
            final Sequence result = var.getResult();
            if(result == null) {
                throw new DynamicError("Result is not bounded for " + var);
            }
            if(nonGroupingVaribales == null) {
                this.nonGroupingVaribales = new IdentityHashMap<BindingVariable, Sequence>(4);
                nonGroupingVaribales.put(var, result);
            } else {
                final Sequence prevValue = nonGroupingVaribales.get(var);
                if(prevValue == null) {
                    nonGroupingVaribales.put(var, result);
                } else {
                    if(prevValue instanceof ValueSequence) {
                        Item resultItem = SingleCollection.wrap(result, dynEnv);
View Full Code Here

        public void assignNonGroupingVariables() {
            if(nonGroupingVaribales != null && !nonGroupingVaribales.isEmpty()) {
                for(Entry<BindingVariable, Sequence> entry : nonGroupingVaribales.entrySet()) {
                    BindingVariable var = entry.getKey();
                    Sequence value = entry.getValue();
                    var.allocateResult(value, dynEnv);
                }
            }
        }
View Full Code Here

    public static void main(String[] args) throws MalformedURLException, RemoteException,
            NotBoundException {
        final XQEngine serv = (XQEngine) Naming.lookup(_localRegistryUrl);
        QueryRequest request = new QueryRequest("1 + 2");
        Sequence result = (Sequence) serv.execute(request);
        System.out.println(result.toString());
    }
View Full Code Here

*/
public class PredefinedFunctionsTest extends TestCase {

    public void testLookupString() throws XQueryException {
        BuiltInFunction func = PredefinedFunctions.lookup("ext:example-func");
        Sequence seq = func.eval(null, null, DynamicContext.DUMMY);
        String actual = seq.toString();
        assertEquals(ExampleFunction.expected, actual);
    }
View Full Code Here

        stdbuf.append(" - free(init): " + StringUtils.displayBytesSize(free));
        final StopWatch sw = new StopWatch("[Xbird] " + queryFile);
        queryFile = XMARK_HOME + '/' + queryFile;
        final XQueryProcessor processor = new XQueryProcessor();
        XQueryModule mod = processor.parse(new FileInputStream(queryFile), new File(queryFile).toURI());
        Sequence result = processor.execute(mod);
        StringWriter res_sw = new StringWriter();
        final Serializer ser = new SAXSerializer(new SAXWriter(res_sw), res_sw);
        ser.emit(result);
        String swresult = sw.toString();
        long used = SystemUtils.getHeapUsedMemory();
View Full Code Here

TOP

Related Classes of xbird.xquery.dm.value.Sequence

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.