This class creates resources and properties and things of that ilk. These resources are not associated with a user-modifiable model: doing getModel() on them will return null.
It is designed as a singleton. There are static convenience methods on this class itself, so the easy way to create resource is for example to do something like:
Resource r = ResourceFactory.createResource();
If a factory object is needed, then this can be obtained using
the getInstance
method on the class. The factory
object used may be changed using the setInstance
method.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
The interface to resource factory objects. -
Method Summary
Modifier and TypeMethodDescriptionstatic Literal
createLangLiteral
(String string, String lang) Answer a literal with language and the given content.static Literal
createPlainLiteral
(String string) Answer a string (xsd:string) literal.static Property
createProperty
(String uriref) Create a new property.static Property
createProperty
(String namespace, String localName) Create a new property.static Resource
Create a new anonymous resource.static Resource
createResource
(String uriref) Create a new resource.static Statement
createStatement
(Resource subject, Property predicate, RDFNode object) Create a new statement.static Resource
createStmtResource
(Statement statement) Create a new resource representing an RDF-star triple term.static Literal
createStringLiteral
(String string) Answer a string (xsd:string) literal.static Literal
createTypedLiteral
(Object value) Answer a typed literal.static Literal
createTypedLiteral
(String string, RDFDatatype dType) Answer a typed literal.static ResourceFactory.Interface
Get the current factory object.static ResourceFactory.Interface
setInstance
(ResourceFactory.Interface newInstance) Set the current factory object.
-
Method Details
-
getInstance
Get the current factory object.- Returns:
- the current factory object
-
setInstance
Set the current factory object.- Parameters:
newInstance
- the new factory object- Returns:
- the previous factory object
-
createResource
Create a new anonymous resource.Uses the current factory object to create a new anonymous resource.
- Returns:
- a new anonymous resource
-
createResource
Create a new resource.Uses the current factory object to create a new resource.
- Parameters:
uriref
- URIREF of the resource- Returns:
- a new resource
-
createStmtResource
Create a new resource representing an RDF-star triple term.- Parameters:
statement
-- Returns:
- a new resource
-
createPlainLiteral
Answer a string (xsd:string) literal. This is the equivalent of a plain literal with no language from RDF 1.0 (also called a simple literal in SPARQL) UsingcreateStringLiteral(java.lang.String)
is preferred; "plain literal" is RDF 1.0 terminology.- Parameters:
string
- the string which forms the value of the literal- Returns:
- a Literal node with that string as value
-
createStringLiteral
Answer a string (xsd:string) literal. This is the equivalent of a plain literal with no language from RDF 1.0 (also called a simple literal in SPARQL)- Parameters:
string
- the string which forms the value of the literal- Returns:
- a Literal node with that string as value
-
createLangLiteral
Answer a literal with language and the given content. The literal will have datatype rdf:langString.- Parameters:
string
- the string which forms the value of the literallang
- The language tag to be used- Returns:
- a Literal node with that string as value
-
createTypedLiteral
Answer a typed literal.- Parameters:
string
- the string which forms the value of the literaldType
- RDFDatatype of the type literal- Returns:
- a Literal node with that string as value
-
createTypedLiteral
Answer a typed literal.- Parameters:
value
- a java Object, the default RDFDatatype for that object will be used- Returns:
- a Literal node with that value
-
createProperty
Create a new property.Uses the current factory object to create a new resource.
- Parameters:
uriref
- URIREF of the property- Returns:
- a new property
-
createProperty
Create a new property.Uses the current factory object to create a new property.
- Parameters:
namespace
- URIREF of the namespace of the propertylocalName
- localname of the property- Returns:
- a new property
-
createStatement
Create a new statement.Uses the current factory object to create a new statement.
- Parameters:
subject
- the subject of the new statementpredicate
- the predicate of the new statementobject
- the object of the new statement- Returns:
- a new resource
-