protected RdfReference(String reference){ if(reference == null){ throw new IllegalArgumentException("The parsed Reference MUST NOT be NULL!"); } else if(reference.isEmpty()){ throw new IllegalArgumentException("The parsed Reference MUST NOT be Empty!"); } else { this.uri = new IRI(reference); } } protected RdfReference(IRI uri){
Pos(String name, LexicalCategory category, LexicalCategory additional) { this.uri = new IRI(OLIA_NAMESPACE + (name == null ? name() : name)); categories = EnumSet.of(category); if (additional != null) { categories.add(additional); } parents = Collections.emptySet(); }
@Override public void removeAll(String field) { if(field == null){ throw new IllegalArgumentException("The parsed field MUST NOT be NULL"); } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } graphNode.deleteProperties(new IRI(field)); } @Override
private BlankNodeOrIRI getBlankNodeOrIRI(String s) { if (s.startsWith("_:")) { return getBlankNode(s); } else { return new IRI(s); } }
private BlankNodeOrIRI getNonLiteral(String s) { if (s.startsWith("_:")) { return getBNode(s); } else { return new IRI(s); } }
Tense(String name,Tense parent) { uri = new IRI(OLIA_NAMESPACE + (name == null ? name() : name)); this.parent = parent; } /**
private <R extends RDFTerm> R toSourceRDFTerm(final R targetRDFTerm) { if (targetRDFTerm instanceof IRI) { final IRI sourceIRI = (IRI) targetRDFTerm; if (sourceIRI.getUnicodeString().startsWith(targetPrefix)) { final String uriRest = sourceIRI.getUnicodeString() .substring(targetPrefixLength); return (R) new IRI(sourcePrefix+uriRest); } } return targetRDFTerm; }
@Override public com.hp.hpl.jena.graph.Graph getGraph(Node node) { final JenaGraph jenaGraph = new JenaGraph( tcManager.getGraph(new IRI(node.getURI()))); return jenaGraph; }
@Override public Iterator<Text> getText(String field) { if(field == null){ throw new IllegalArgumentException("The parsed field MUST NOT be NULL"); } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } return new AdaptingIterator<Literal, Text>( graphNode.getLiterals(new IRI(field)), new Literal2TextAdapter<Literal>(), Text.class); }
@Override public Iterator<Object> get(String field) { if(field == null){ throw new IllegalArgumentException("The parsed field MUST NOT be NULL"); } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } return new AdaptingIterator<RDFTerm, Object>(graphNode.getObjects(new IRI(field)), new Resource2ValueAdapter<RDFTerm>(),Object.class); }
@Override public Iterator<Text> getText(String field) { if(field == null){ throw new IllegalArgumentException("The parsed field MUST NOT be NULL"); } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } return new AdaptingIterator<Literal, Text>( graphNode.getLiterals(new IRI(field)), new Literal2TextAdapter<Literal>(), Text.class); }
@Override public Iterator<Text> get(String field, String...languages) { if(field == null){ throw new IllegalArgumentException("The parsed field MUST NOT be NULL"); } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } return new AdaptingIterator<Literal, Text>( graphNode.getLiterals(new IRI(field)), new Literal2TextAdapter<Literal>(languages), Text.class); }
OntologyToTcMapper() { if (store == null) throw new IllegalArgumentException("TcProvider cannot be null"); IRI graphId = new IRI(metaGraphId); try { graph = store.createGraph(graphId); } catch (EntityAlreadyExistsException e) { graph = store.getGraph(graphId); } }
@Override public boolean emailExists(String email) { Graph systemGraph = getSystemGraph(); Lock readLock = systemGraph.getLock().readLock(); readLock.lock(); try { return systemGraph.filter(null, FOAF.mbox, new IRI("mailto:" + email)).hasNext(); } finally { readLock.unlock(); } }
@Override public boolean containsGraph(Node node) { try { tcManager.getGraph(new IRI(node.getURI())); return true; } catch (NoSuchEntityException e) { return false; } }
public static Graph createOntology(String id, TcManager tcm) { IRI name = new IRI(id); Graph ont = tcm.createGraph(name); ont.add(new TripleImpl(name, RDF.type, OWL.Ontology)); return ont; }
@Test(expected=IllegalArgumentException.class) public void addPartWithoutPartContent() throws IOException{ ContentItem ci = createContentItem(contentSource); ci.addPart(new IRI("http://foo/"), null); } /**
@Test(expected=NoSuchPartException.class) public void removeNonExistentPartByUri() throws IOException { ContentItem ci = createContentItem(contentSource); ci.removePart(new IRI("urn:does.not.exist:and.can.not.be.removed")); } @Test(expected=NoSuchPartException.class)
private void triple(String s, String p, String o, String graph) { if (s == null || p == null || o == null) { // TODO: i don't know what to do here!!!! return; } final BlankNodeOrIRI subject = getNonLiteral(s); final IRI predicate = new IRI(p); final BlankNodeOrIRI object = getNonLiteral(o); mGraph.add(new TripleImpl(subject, predicate, object)); }
@Override public IRI createObject(Literal literal) { if (!literal.getDataType().equals(xsdAnyURI)) { throw new InvalidLiteralTypeException(IRI.class, literal.getDataType()); } return new IRI(literal.getLexicalForm()); } }