Examples of RDFValue


Examples of net.fortytwo.ripple.model.RDFValue

        RDFImporter importer = new RDFImporter(mc);
        SesameInputAdapter.parse(is, importer, "", RDFFormat.TURTLE);
        mc.commit();
        is.close();

        RDFValue head;
        Collector<RippleList> created = new Collector<RippleList>();
        final Collector<RippleList> allowed = new Collector<RippleList>();

        Sink<RippleList> verifySink = new Sink<RippleList>() {
            public void put(final RippleList list) throws RippleException {
                boolean found = false;

                for (Iterator<RippleList> iter = allowed.iterator(); iter.hasNext(); ) {
                    if (0 == mc.getComparator().compare(iter.next(), list)) {
                        found = true;
                        break;
                    }
                }

                assertTrue(found);
            }
        };

        RippleValue l1 = mc.valueOf("1", XMLSchema.STRING);
        RippleValue l2 = mc.valueOf("2", XMLSchema.STRING);
        RippleValue l1a = mc.valueOf("1a", XMLSchema.STRING);
        RippleValue l1b = mc.valueOf("1b", XMLSchema.STRING);
        RippleValue l2a = mc.valueOf("2a", XMLSchema.STRING);
        RippleValue l2b = mc.valueOf("2b", XMLSchema.STRING);

        head = new RDFValue(createURI("urn:test.RippleListTest.FromRdfTest#simpleList", mc));
        created.clear();
        mc.toList(head, created);
        assertEquals(1, created.size());
        allowed.clear();
        allowed.put(mc.list().push(l2).push(l1));
        created.writeTo(verifySink);

        head = new RDFValue(createURI("urn:test.RippleListTest.FromRdfTest#firstBranchingList", mc));
        created.clear();
        mc.toList(head, created);
        assertEquals(2, created.size());
        allowed.clear();
        allowed.put(mc.list().push(l2).push(l1a));
        allowed.put(mc.list().push(l2).push(l1b));
        created.writeTo(verifySink);

        head = new RDFValue(createURI("urn:test.RippleListTest.FromRdfTest#restBranchingList", mc));
        created.clear();
        mc.toList(head, created);
        assertEquals(2, created.size());
        allowed.clear();
        allowed.put(mc.list().push(l2a).push(l1));
        allowed.put(mc.list().push(l2b).push(l1));
        created.writeTo(verifySink);

        head = new RDFValue(createURI("urn:test.RippleListTest.FromRdfTest#firstAndRestBranchingList", mc));
        created.clear();
        mc.toList(head, created);
        assertEquals(4, created.size());
        allowed.clear();
        allowed.put(mc.list().push(l2a).push(l1a));
View Full Code Here

Examples of net.fortytwo.ripple.model.RDFValue

        Operator.createOperator(arg, ops, mc);
        assertEquals(1, ops.size());
        assertTrue(ops.iterator().next().getMapping() instanceof ListDequotation);

        // rdf:nil --> ListDequotation
        arg = new RDFValue(RDF.NIL);
        ops.clear();
        Operator.createOperator(arg, ops, mc);
        assertEquals(1, ops.size());
        assertTrue(ops.iterator().next().getMapping() instanceof ListDequotation);

        // an rdf:List --> ListDequotation
        arg = new RDFValue(createURI("urn:test.CreateOperatorTest#simpleList", mc));
        ops.clear();
        Operator.createOperator(arg, ops, mc);
        assertEquals(1, ops.size());
        assertTrue(ops.iterator().next().getMapping() instanceof ListDequotation);

        // a branching rdf:List --> multiple ListDequotations
        arg = new RDFValue(createURI("urn:test.CreateOperatorTest#firstBranchingList", mc));
        ops.clear();
        Operator.createOperator(arg, ops, mc);
        assertEquals(2, ops.size());
        assertTrue(ops.iterator().next().getMapping() instanceof ListDequotation);

        // a PrimitiveStackRelation --> the same PrimitiveStackRelation
        arg = new Dup();
        ops.clear();
        Operator.createOperator(arg, ops, mc);
        assertEquals(1, ops.size());
        assertTrue(ops.iterator().next().getMapping() instanceof Dup);

        // an rdf:Property --> RdfPredicateRelation
        arg = new RDFValue(RDF.TYPE);
        ops.clear();
        Operator.createOperator(arg, ops, mc);
        assertEquals(1, ops.size());
        assertTrue(ops.iterator().next().getMapping() instanceof RDFPredicateMapping);

        // a non-property RdfValue which is not anything else --> RdfPredicateRelation
        arg = new RDFValue(RDF.BAG);
        ops.clear();
        Operator.createOperator(arg, ops, mc);
        assertEquals(1, ops.size());
        assertTrue(ops.iterator().next().getMapping() instanceof RDFPredicateMapping);
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.