Package net.fortytwo.ripple.model

Examples of net.fortytwo.ripple.model.RDFValue


            Sink<Statement> stSink = new Sink<Statement>() {
                public void put(final Statement st) throws RippleException {
                    Resource context = st.getContext();

                    RippleValue subj = mc.canonicalValue(new RDFValue(st.getSubject()));
                    RippleValue pred = mc.canonicalValue(new RDFValue(st.getPredicate()));
                    RippleValue ctx = (null == context) ? mc.list() : mc.canonicalValue(new RDFValue(context));

                    solutions.put(rest.push(subj).push(pred).push(obj).push(ctx));
                }
            };
View Full Code Here


                    subject = (Resource) valueFactory.nativize(subject);
                }
                RippleList stack = ((RippleSesameValue) subject).getStack();
                //System.out.println("\tstack = " + stack);
                if (null == stack) {
                    stack = modelConnection.list().push(modelConnection.canonicalValue(new RDFValue(subject)));

                    // Note: this may or may not be worth the extra CPU cycles.
                    ((RippleSesameValue) subject).setStack(stack);
                }

                stack = stack.push(modelConnection.canonicalValue(
                        new RDFValue(valueFactory.nativize(predicate)))).push(Operator.OP);
                //System.out.println("\t\tstack (new) = " + stack);

                CloseableIteration<RippleList, RippleException> solutions
                        = new LazyEvaluatingIterator(stack, modelConnection);
                /*
                Collector<StackContext, RippleException> solutions = new Collector<StackContext, RippleException>();
                evaluator.apply(new StackContext(stack, modelConnection), solutions);

                Collection<RippleList> stacks = new LinkedList<RippleList>();
                for (StackContext c : solutions) {
                    //System.out.println("\tsolution: " + c);
                    RippleList s = c.getStack();
                    if (!s.isNil()) {
                        stacks.add(s);
                    }
                }

                return new SolutionIteration(stacks.iterator(), false, subject, predicate, object, contexts);
                */

                return new SolutionIteration(solutions, false, subject, predicate, object, contexts);
            }

            // Backward traversal
            else if (null == subject) {
                if (!(object instanceof RippleSesameValue)) {
                    object = valueFactory.nativize(object);
                }
                RippleList stack = ((RippleSesameValue) object).getStack();
                if (null == stack) {
                    stack = modelConnection.list().push(modelConnection.canonicalValue(new RDFValue(object)));

                    // Note: this may or may not be worth the extra CPU cycles.
                    ((RippleSesameValue) object).setStack(stack);
                }

                stack = stack.push(modelConnection.canonicalValue(new RDFValue(predicate)))
                        .push(ControlLibrary.getInverseValue())
                        .push(Operator.OP)
                        .push(Operator.OP);
                //System.out.println("stack = " + stack);

View Full Code Here

                        s.setStack(stack);

                        nextStatement = valueFactory.createStatement((Resource) s, predicate, object);
                        //System.out.println("nextStatement(1): " + nextStatement);
                    } else {
                        RDFValue r = stack.getFirst().toRDF(modelConnection);
                        Value obj;
                        RippleSesameValue o;
                        if (null == r) {
                            //System.out.println("stack = " + stack);
                            //System.out.println("subject = " + subject);
                            //System.out.println("predicate = " + predicate);
                            //System.out.println("object = " + object);

                            o = new RippleBNode();
                            //continue;
                            o.setStack(stack);
                        } else {
                            obj = r.sesameValue();
                            o = (RippleSesameValue) valueFactory.nativize(obj);
                            o.setStack(stack);
                        }

                        nextStatement = valueFactory.createStatement(subject, predicate, (Value) o);
View Full Code Here

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

        RippleList stack = arg;

        RDFValue context = stack.getFirst().toRDF(mc);
        stack = stack.getRest();
        RDFValue pred = stack.getFirst().toRDF(mc);
        stack = stack.getRest();

        RDFPredicateMapping mapping = getMapping(pred, context);

        solutions.put(
View Full Code Here

    public RDFValue valueOf(final java.net.URI s) throws RippleException {
        try {
// return canonicalize(valueFactory.createURI(s));
            // Note: do NOT automatically canonicalize values.  Sometimes one needs the original URI (e.g. so as to
            // remove statements), and not the native object it maps to.
            return new RDFValue(valueFactory.createURI(s.toString()));
        } catch (Throwable t) {
            reset(true);
            throw new RippleException(t);
        }
    }
View Full Code Here

        }

        GregorianCalendar c = new GregorianCalendar();
        c.setTime(d);
        XMLGregorianCalendar xml = DATATYPE_FACTORY.newXMLGregorianCalendar(c);
        return new RDFValue(valueFactory.createLiteral(xml));
    }
View Full Code Here

        return model.specialValues.get(v);
    }

    public RDFValue valueOf(final String s) throws RippleException {
        try {
            return new RDFValue(
                    valueFactory.createLiteral(s));
//                    valueFactory.createLiteral( s, XMLSchema.STRING ) );
        } catch (Throwable t) {
            reset(true);
            throw new RippleException(t);
View Full Code Here

    }

    public RDFValue valueOf(final String s, final String language)
            throws RippleException {
        try {
            return new RDFValue(
                    valueFactory.createLiteral(s, language));
        } catch (Throwable t) {
            reset(true);
            throw new RippleException(t);
        }
View Full Code Here

    }

    public RDFValue valueOf(final String s, final URI dataType)
            throws RippleException {
        try {
            return new RDFValue(
                    valueFactory.createLiteral(s, dataType));
        } catch (Throwable t) {
            reset(true);
            throw new RippleException(t);
        }
View Full Code Here

    }

    public RDFValue valueOf(final boolean b)
            throws RippleException {
        try {
            return new RDFValue(
                    valueFactory.createLiteral("" + b, XMLSchema.BOOLEAN));
        } catch (Throwable t) {
            reset(true);
            throw new RippleException(t);
        }
View Full Code Here

TOP

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

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.