Package net.fortytwo.ripple.model

Examples of net.fortytwo.ripple.model.RippleList


    }

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {
        RippleList stack = arg;

        RippleValue a = stack.getFirst();
        stack = stack.getRest();

        String result = StringUtils.percentDecode(mc.toString(a));
        solutions.put(
                stack.push(StringLibrary.value(result, mc, a)));
    }
View Full Code Here


    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {

        RippleList stack = arg;
        boolean x, y;

        x = mc.toBoolean(stack.getFirst());
        stack = stack.getRest();
        y = mc.toBoolean(stack.getFirst());
        stack = stack.getRest();

        RippleValue result = mc.valueOf((x && !y) || (!x && y));

        solutions.put(
                stack.push(result));
    }
View Full Code Here

        } else if (expressions.size() > 1) {
            qe.getErrorPrintStream().println(
                    "Warning: the given expression resolved to multiple values.");
        } else {
            // Note: the first element of the list will also be a list
            RippleList expr = (RippleList) expressions.iterator().next().getFirst();
//System.out.println( "exprList = " + exprList );

            RDFValue id = mc.valueOf(java.net.URI.create(qe.getLexicon().getDefaultNamespace() + name));
            expr.setRDF(id);
            mc.internalize(expr);
            mc.commit();

            qe.getLexicon().addURI((URI) id.sesameValue());
            mc.getModel().getSpecialValues().put(id.sesameValue(), expr);
View Full Code Here

            public void apply(final RippleList arg,
                              final Sink<RippleList> solutions,
                              final ModelConnection mc) throws RippleException {

                RippleList stack = arg;

                boolean x;

                x = mc.toBoolean(stack.getFirst());
                stack = stack.getRest();

                if (x) {
                    RippleValue t = mc.valueOf(true);
                    RippleValue f = mc.valueOf(false);
                    solutions.put(stack.push(t).push(f));
                    solutions.put(stack.push(f).push(t));
                } else {
                    RippleValue f = mc.valueOf(false);
                    solutions.put(stack.push(f).push(f));
                }
            }
        };
    }
View Full Code Here

    }

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {
        RippleList stack = arg;

        RippleValue s, regex;

        regex = stack.getFirst();
        stack = stack.getRest();
        s = stack.getFirst();
        stack = stack.getRest();

        try {
            String[] array = mc.toString(s).split(mc.toString(regex));
            RippleList result = mc.list();
            for (int i = array.length - 1; i >= 0; i--) {
                result = result.push(StringLibrary.value(array[i], mc, s, regex));
            }

            try {
                solutions.put(
                        stack.push(result));
View Full Code Here

    }

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {
        RippleList stack = arg;

        NumericValue a, result;

        a = mc.toNumericValue(stack.getFirst());
        stack = stack.getRest();

        result = mc.valueOf(a.sign());

        solutions.put(
                stack.push(result));
    }
View Full Code Here

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {

        RippleList stack = arg;

        RippleValue subj, pred, obj, ctx;

        ctx = stack.getFirst();
        stack = stack.getRest();
        obj = stack.getFirst();
        stack = stack.getRest();
        pred = stack.getFirst();
        stack = stack.getRest();
        subj = stack.getFirst();
        stack = stack.getRest();

        mc.add(subj, pred, obj, ctx);

        // TODO: store added and removed statements in a buffer until the
        // ModelConnection commits.  You may not simply wait to commit,
        // as writing and then reading without first committing may result
        // in a deadlock.  The LinkedDataSail already does this sort of
        // buffering, which is why it does not deadlock w.r.t. its base
        // Sail.
        mc.commit();

        solutions.put(stack.push(subj));
    }
View Full Code Here

                      final ModelConnection mc) throws RippleException {

        RippleValue l;

        l = arg.getFirst();
        final RippleList rest = arg.getRest();

        Sink<RippleList> listSink = new Sink<RippleList>() {
            public void put(RippleList list) throws RippleException {
                RippleValue result = null;
                while (!list.isNil()) {
                    RippleValue v = list.getFirst();

                    if (null == result || mc.getComparator().compare(v, result) > 0) {
                        result = v;
                    }

                    list = list.getRest();
                }

                if (null != result) {
                    solutions.put(
                            rest.push(result));
                }
            }
        };

        mc.toList(l, listSink);
View Full Code Here

    }

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {
        RippleList stack = arg;
        double a;
        NumericValue result;

        a = mc.toNumericValue(stack.getFirst()).doubleValue();
        stack = stack.getRest();

// TODO: check for undefined values
        double d = Math.tan(a);
        result = mc.valueOf(d);

        solutions.put(
                stack.push(result));
    }
View Full Code Here

                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {

        Model model = mc.getModel();
        if (model instanceof SesameModel) {
            RippleList stack = arg;

            RippleValue head = stack.getFirst();
            final RippleList rest = stack.getRest();

            final Sink<RippleValue> pushSink = new Sink<RippleValue>() {
                public void put(final RippleValue v) throws RippleException {
                    solutions.put(rest.push(v));
                }
            };

            Sink<Statement> stSink = new Sink<Statement>() {
                public void put(final Statement st) throws RippleException {
View Full Code Here

TOP

Related Classes of net.fortytwo.ripple.model.RippleList

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.