RDF graphs consist of statements, each of which is represented by an RDF triple. Triples are represented in Tupelo 2 with the Triple class, which extends the more generic Tuple utility.
Each term in a Triple is a Resource.
Constructing Triples
To construct a URI reference, use Resource.uriRef:
Resource subject = Resource.uriRef("http://myuri.org/people/joe"); Resource predicate = Resource.uriRef("http://myuri.org/predicates/hasNickname");
To construct a literal, use Resource.literal:
Resource object = Resource.literal("Mr. RDF");
If you want a typed literal, use the two-argument form:
import org.tupeloproject.rdf.terms.Xsd; ... Resource object = Resource.literal("34",Xsd.POSITIVE_INTEGER);
A Triple can be constructed from Resources:
import org.tupeloproject.rdf.terms.Dc; ... Triple triple = new Triple (Resource.uriRef("http://tupeloproject.org"), Dc.DESCRIPTION, Resource.literal("Tupelo project website");
The Triple class provides a convenience method that attempts to convert Java types to the relevant kinds of Resources:
import org.tupeloproject.rdf.terms.Dc; ... URI website = URI.create("http://tupeloproject.org"); Triple triple1 = Triple.create(website,Dc.DESCRIPTION,"Tupelo project website"); Triple triple2 = Triple.create(website,Dc.DATE,new Date());