@Override public SecuredRDFList cons(final RDFNode value) throws UpdateDeniedException, AddDeniedException, AuthenticationRequiredException { checkUpdate(); checkCreateNewList(value, holder.getBaseItem()); return SecuredRDFListImpl.getInstance(getModel(), holder.getBaseItem() .cons(value)); }
list = list.cons( ontology.createResource().addProperty(ontology.createProperty(XSD.getURI() + "maxInclusive"), facets.maxInclusive, XSDUtil.getXSDDatatype(name)) ); list = list.cons( ontology.createResource().addProperty(ontology.createProperty(XSD.getURI() + "minInclusive"), facets.minInclusive, XSDUtil.getXSDDatatype(name)) ); list = list.cons( ontology.createResource().addProperty(ontology.createProperty(XSD.getURI() + "maxExclusive"), facets.maxExclusive, XSDUtil.getXSDDatatype(name)) ); list = list.cons( ontology.createResource().addProperty(ontology.createProperty(XSD.getURI() + "minExclusive"), facets.minExclusive, XSDUtil.getXSDDatatype(name)) ); list = list.cons( ontology.createResource().addProperty(ontology.createProperty(XSD.getURI() + "length"), facets.length, XSDUtil.getXSDDatatype(name)) ); list = list.cons( ontology.createResource().addProperty(ontology.createProperty(XSD.getURI() + "maxLength"), facets.maxLength, XSDUtil.getXSDDatatype(name)) ); list = list.cons( ontology.createResource().addProperty(ontology.createProperty(XSD.getURI() + "minLength"), facets.minLength, XSDUtil.getXSDDatatype(name)) ); list = list.cons(
public void testIndex2() { final Resource nil = model.getResource(RDF.nil.getURI()); RDFList list = nil.as(RDFList.class); final Resource r = model.createResource(TestList.NS + "a"); // cons each a's onto the front of the list for (int i = 0; i < 10; i++) { list = list.cons(r); } // now index them back again for (int j = 0; j < 10; j++) { Assert.assertEquals("index of j'th item should be j", j, list.indexOf(r, j)); } }
public void testIndex2() { final Resource nil = model.getResource(RDF.nil.getURI()); RDFList list = nil.as(RDFList.class); final Resource r = model.createResource(TestList.NS + "a"); // cons each a's onto the front of the list for (int i = 0; i < 10; i++) { list = list.cons(r); } // now index them back again for (int j = 0; j < 10; j++) { Assert.assertEquals("index of j'th item should be j", j, list.indexOf(r, j)); } }
public void testConcatenate2() { model.read(getFileName("ontology/list5.rdf")); final Resource a = model.createResource(TestList.NS + "a"); // create a list of foos final Resource[] rs = new Resource[] { model.createResource(TestList.NS + "b"), model.createResource(TestList.NS + "c"), model.createResource(TestList.NS + "d"), model.createResource(TestList.NS + "e") }; final RDFList aList = model.createList().cons(a); final RDFList rsList = model.createList(rs); // concatenate the above resources onto the empty list aList.concatenate(rsList); checkValid("concatTest3", aList, true); final RDFList root = getListRoot(model); Assert.assertTrue("Constructed and loaded lists should be the same", aList.sameListAs(root)); }
public void testConcatenate2() { model.read(getFileName("ontology/list5.rdf")); final Resource a = model.createResource(TestList.NS + "a"); // create a list of foos final Resource[] rs = new Resource[] { model.createResource(TestList.NS + "b"), model.createResource(TestList.NS + "c"), model.createResource(TestList.NS + "d"), model.createResource(TestList.NS + "e") }; final RDFList aList = model.createList().cons(a); final RDFList rsList = model.createList(rs); // concatenate the above resources onto the empty list aList.concatenate(rsList); checkValid("concatTest3", aList, true); final RDFList root = getListRoot(model); Assert.assertTrue("Constructed and loaded lists should be the same", aList.sameListAs(root)); }
public void testCons() { final Resource root = model.createResource(TestList.NS + "root"); final Property p = model.createProperty(TestList.NS, "p"); final Resource nil = model.getResource(RDF.nil.getURI()); RDFList list = nil.as(RDFList.class); final Resource[] toAdd = new Resource[] { model.createResource(TestList.NS + "e"), model.createResource(TestList.NS + "d"), model.createResource(TestList.NS + "c"), model.createResource(TestList.NS + "b"), model.createResource(TestList.NS + "a"), }; // cons each of these resources onto the front of the list for (final Resource element : toAdd) { final RDFList list0 = list.cons(element); checkValid("constest1", list0, true); Assert.assertTrue("cons'ed lists should not be equal", !list0.equals(list)); list = list0; } // relate the root to the list model.add(root, p, list); // should be isomorphic with list 5 final Model m0 = ModelFactory.createDefaultModel(); m0.read(getFileName("ontology/list5.rdf")); Assert.assertTrue("Cons'ed and read models should be the same", m0.isIsomorphicWith(model)); }
public void testCons() { final Resource root = model.createResource(TestList.NS + "root"); final Property p = model.createProperty(TestList.NS, "p"); final Resource nil = model.getResource(RDF.nil.getURI()); RDFList list = nil.as(RDFList.class); final Resource[] toAdd = new Resource[] { model.createResource(TestList.NS + "e"), model.createResource(TestList.NS + "d"), model.createResource(TestList.NS + "c"), model.createResource(TestList.NS + "b"), model.createResource(TestList.NS + "a"), }; // cons each of these resources onto the front of the list for (final Resource element : toAdd) { final RDFList list0 = list.cons(element); checkValid("constest1", list0, true); Assert.assertTrue("cons'ed lists should not be equal", !list0.equals(list)); list = list0; } // relate the root to the list model.add(root, p, list); // should be isomorphic with list 5 final Model m0 = ModelFactory.createDefaultModel(); m0.read(getFileName("ontology/list5.rdf")); Assert.assertTrue("Cons'ed and read models should be the same", m0.isIsomorphicWith(model)); }
public void testConcatenate() { model.read(getFileName("ontology/list5.rdf")); final Resource nil = model.getResource(RDF.nil.getURI()); RDFList list = nil.as(RDFList.class); final Resource r = model.createResource(TestList.NS + "foo"); // create a list of foos for (int i = 0; i < 5; i++) { list = list.cons(r); } final int listLen = list.size(); // now append foos to the root list final RDFList root = getListRoot(model); final int rootLen = root.size(); root.concatenate(list); // original list should be unchanged checkValid("concatTest0", list, true); Assert.assertEquals("Original list should be unchanged", listLen, list.size()); // but lhs list has changed checkValid("concatTest1", root, true); Assert.assertEquals("Root list should be new length", rootLen + listLen, root.size()); }
public void testConcatenate() { model.read(getFileName("ontology/list5.rdf")); final Resource nil = model.getResource(RDF.nil.getURI()); RDFList list = nil.as(RDFList.class); final Resource r = model.createResource(TestList.NS + "foo"); // create a list of foos for (int i = 0; i < 5; i++) { list = list.cons(r); } final int listLen = list.size(); // now append foos to the root list final RDFList root = getListRoot(model); final int rootLen = root.size(); root.concatenate(list); // original list should be unchanged checkValid("concatTest0", list, true); Assert.assertEquals("Original list should be unchanged", listLen, list.size()); // but lhs list has changed checkValid("concatTest1", root, true); Assert.assertEquals("Root list should be new length", rootLen + listLen, root.size()); }
public void testAppend() { model.read(getFileName("ontology/list5.rdf")); final Resource nil = model.getResource(RDF.nil.getURI()); RDFList list = nil.as(RDFList.class); final Resource r = model.createResource(TestList.NS + "foo"); // create a list of foos for (int i = 0; i < 5; i++) { list = list.cons(r); } final int listLen = list.size(); // now append foos to the root list final RDFList root = getListRoot(model); final int rootLen = root.size(); final RDFList appended = root.append(list); // original list should be unchanged checkValid("appendTest0", root, true); Assert.assertEquals("Original list should be unchanged", rootLen, root.size()); checkValid("appendTest1", list, true); Assert.assertEquals("Original list should be unchanged", listLen, list.size()); // new list should be length of combined checkValid("appendTest2", appended, true); Assert.assertEquals("Appended list not correct length", rootLen + listLen, appended.size()); }
public void testAppend() { model.read(getFileName("ontology/list5.rdf")); final Resource nil = model.getResource(RDF.nil.getURI()); RDFList list = nil.as(RDFList.class); final Resource r = model.createResource(TestList.NS + "foo"); // create a list of foos for (int i = 0; i < 5; i++) { list = list.cons(r); } final int listLen = list.size(); // now append foos to the root list final RDFList root = getListRoot(model); final int rootLen = root.size(); final RDFList appended = root.append(list); // original list should be unchanged checkValid("appendTest0", root, true); Assert.assertEquals("Original list should be unchanged", rootLen, root.size()); checkValid("appendTest1", list, true); Assert.assertEquals("Original list should be unchanged", listLen, list.size()); // new list should be length of combined checkValid("appendTest2", appended, true); Assert.assertEquals("Appended list not correct length", rootLen + listLen, appended.size()); }