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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe interface to resource factory objects. -
Method Summary
Modifier and TypeMethodDescriptionstatic LiteralcreateLangLiteral(String string, String lang) Answer a literal with language and the given content.static LiteralcreatePlainLiteral(String string) Answer a string (xsd:string) literal.static PropertycreateProperty(String uriref) Create a new property.static PropertycreateProperty(String namespace, String localName) Create a new property.static ResourceCreate a new anonymous resource.static ResourcecreateResource(String uriref) Create a new resource.static StatementcreateStatement(Resource subject, Property predicate, RDFNode object) Create a new statement.static StatementTermcreateStatementTerm(Statement statement) Create a new statement term.static LiteralcreateStringLiteral(String string) Answer a string (xsd:string) literal.static LiteralcreateTypedLiteral(Object value) Answer a typed literal.static LiteralcreateTypedLiteral(String string, RDFDatatype dType) Answer a typed literal.static ResourceFactory.InterfaceGet the current factory object.static ResourceFactory.InterfacesetInstance(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
-
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
-
createStatementTerm
Create a new statement term.Uses the current factory object to create a new statement.
- Parameters:
statement-- Returns:
- a new statement term for the statement
-