List of usage examples for org.apache.commons.rdf.api IRI getIRIString
String getIRIString();
From source file:edu.amherst.acdc.trellis.constraint.LdpConstraints.java
private static Predicate<Triple> subjectFilter(final IRI context) { return triple -> of(triple).map(Triple::getSubject).filter( iri -> !iri.equals(context) && !iri.ntriplesString().startsWith("<" + context.getIRIString() + "#")) .isPresent();//from w ww .j a v a 2 s .c o m }
From source file:example.UserGuideTest.java
@Test public void triple() throws Exception { BlankNodeOrIRI subject = factory.createBlankNode(); IRI predicate = factory.createIRI("http://example.com/says"); RDFTerm object = factory.createLiteral("Hello"); Triple triple = factory.createTriple(subject, predicate, object); BlankNodeOrIRI subj = triple.getSubject(); System.out.println(subj.ntriplesString()); IRI pred = triple.getPredicate(); System.out.println(pred.getIRIString()); RDFTerm obj = triple.getObject();//from www . ja v a2 s. c o m System.out.println(obj.ntriplesString()); if (subj instanceof IRI) { String s = ((IRI) subj).getIRIString(); System.out.println(s); } // .. if (obj instanceof Literal) { IRI type = ((Literal) obj).getDatatype(); System.out.println(type); } System.out.println(triple.equals(factory.createTriple(subj, pred, obj))); }
From source file:example.UserGuideTest.java
@Test public void ntriples() throws Exception { IRI iri = factory.createIRI("http://example.com/alice"); System.out.println(iri.getIRIString()); IRI iri2 = factory.createIRI("http://example.com/alice"); System.out.println(iri.equals(iri2)); IRI iri3 = factory.createIRI("http://example.com/alice/./"); System.out.println(iri.equals(iri3)); System.out.println(iri.equals("http://example.com/alice")); System.out.println(iri.equals(factory.createLiteral("http://example.com/alice"))); }
From source file:org.apache.jena.commonsrdf.impl.JCR_IRI.java
@Override public boolean equals(Object other) { if (other == this) return true; if (other == null) return false; if (!(other instanceof IRI)) return false; IRI iri = (IRI) other; return getIRIString().equals(iri.getIRIString()); }
From source file:org.apache.jena.commonsrdf.RDFTermFactoryJena.java
@Override public Literal createLiteral(String lexicalForm, IRI dataType) { return JCR_Factory.createLiteralDT(lexicalForm, dataType.getIRIString()); }
From source file:org.trellisldp.api.ResourceService.java
/** * Get the identifier for the structurally-logical container for the resource * @param identifier the identifier/*from w w w. j av a 2 s .com*/ * @return an identifier for the structurally-logical container * * Note: The returned identifier is not guaranteed to exist */ default Optional<IRI> getContainer(final IRI identifier) { final String id = identifier.getIRIString(); return of(id).map(x -> x.lastIndexOf('/')).filter(idx -> idx > 0).map(idx -> id.substring(0, idx)) .map(getInstance()::createIRI); }
From source file:org.trellisldp.api.TrellisUtils.java
/** * Get the structural-logical container for this resource. * * @param identifier the resource identifier * @return a container, if one exists. Only the root resource would return empty here. *///www. j a va2 s .co m public static Optional<IRI> getContainer(final IRI identifier) { final String path = identifier.getIRIString().substring(TRELLIS_DATA_PREFIX.length()); return Optional.of(path).filter(p -> !p.isEmpty()).map(x -> x.lastIndexOf('/')) .map(idx -> idx < 0 ? 0 : idx).map(idx -> TRELLIS_DATA_PREFIX + path.substring(0, idx)) .map(rdf::createIRI); }
From source file:org.trellisldp.file.FileUtils.java
/** * Get a directory for a given resource identifier. * @param baseDirectory the base directory * @param identifier a resource identifier * @return a directory/* w w w .j ava 2 s . co m*/ */ public static File getResourceDirectory(final File baseDirectory, final IRI identifier) { requireNonNull(baseDirectory, "The baseDirectory may not be null!"); requireNonNull(identifier, "The identifier may not be null!"); final String id = identifier.getIRIString(); final StringJoiner joiner = new StringJoiner(separator); final CRC32 hasher = new CRC32(); hasher.update(id.getBytes(UTF_8)); final String intermediate = Long.toHexString(hasher.getValue()); range(0, intermediate.length() / LENGTH).limit(MAX) .forEach(i -> joiner.add(intermediate.substring(i * LENGTH, (i + 1) * LENGTH))); joiner.add(md5Hex(id)); return new File(baseDirectory, joiner.toString()); }
From source file:org.trellisldp.http.AbstractLdpResourceTest.java
protected static Predicate<Link> hasLink(final IRI iri, final String rel) { return link -> rel.equals(link.getRel()) && iri.getIRIString().equals(link.getUri().toString()); }
From source file:org.trellisldp.http.HttpResolver.java
@Override public Boolean exists(final String partition, final IRI identifier) { requireNonNull(identifier, NON_NULL_IDENTIFIER); final Response res = httpClient.target(identifier.getIRIString()).request().head(); final Boolean status = res.getStatusInfo().getFamily().equals(SUCCESSFUL); LOGGER.info("HTTP HEAD request to {} returned status {}", identifier, res.getStatus()); res.close();//from ww w .ja v a 2s. c o m return status; }