Skip to content

Commit

Permalink
Merge pull request #82 from Fedict/issues/#1292-validation-factory
Browse files Browse the repository at this point in the history
Issues/#1292 validation factory
  • Loading branch information
barthanssens authored Feb 13, 2019
2 parents 9771ec8 + c8849fd commit 5c79b7d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/programming/02-model-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The core of the RDF4J framework is the RDF Model API (see the link:/javadoc/late
RDF statements are represented by the {javadoc}model/Statement.html[Statement] interface. Each `Statement` has a subject, predicate, object and (optionally) a context (more about contexts below, in the section about the Repository API). Each of these 4 items is a {javadoc}model/Value.html[Value]. The `Value` interface is further specialized into {javadoc}model/Resource.html[Resource], and {javadoc}model/Literal.html.html[Literal]. `Resource` represents any RDF value that is either a blank node or a IRI (in fact, it specializes further into {javadoc}model/IRI.html[IRI] and {javadoc}model/BNode.html[BNode]). `Literal`
represents RDF literal values (strings, dates, integer numbers, and so on).

To create new values and statements, we can use a {javadoc}model/ValueFactory.html[ValueFactory]. You can use a default ValueFactory implementation called {javadoc}model/impl/SimpleValueFactory[SimpleValueFactory]:
To create new values and statements, you can use a {javadoc}model/ValueFactory.html[ValueFactory]. You can use a default ValueFactory implementation called {javadoc}model/impl/SimpleValueFactory[SimpleValueFactory]:

[source,java,linenum]
----
Expand All @@ -19,6 +19,8 @@ import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
ValueFactory factory = SimpleValueFactory.getInstance();
----

For performance reasons, the `SimpleValueFactory` provides only basic input validation. The {javadoc}model/impl/ValidatingValueFactory[ValidatingValueFactory] is stricter, albeit somewhat slower.

You can also obtain a `ValueFactory` from the {javadoc}repository/Repository.html[Repository] you are working with, and in fact, this is the recommend approach. More about that in the next section.

Regardless of how you obtain your `ValueFactory`, once you have it, you can use it to create new URIs, Literals, and Statements:
Expand Down

0 comments on commit 5c79b7d

Please sign in to comment.