Class ResourceFactory
- java.lang.Object
-
- org.apache.jena.rdf.model.ResourceFactory
-
public class ResourceFactory extends java.lang.Object
A Factory class for creating resources.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 thesetInstance
method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ResourceFactory.Interface
The interface to resource factory objects.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Literal
createLangLiteral(java.lang.String string, java.lang.String lang)
Answer a literal with language and the given content.static Literal
createPlainLiteral(java.lang.String string)
Answer a string (xsd:string) literal.static Property
createProperty(java.lang.String uriref)
Create a new property.static Property
createProperty(java.lang.String namespace, java.lang.String localName)
Create a new property.static Resource
createResource()
Create a new anonymous resource.static Resource
createResource(java.lang.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(java.lang.String string)
Answer a string (xsd:string) literal.static Literal
createTypedLiteral(java.lang.Object value)
Answer a typed literal.static Literal
createTypedLiteral(java.lang.String string, RDFDatatype dType)
Answer a typed literal.static ResourceFactory.Interface
getInstance()
Get the current factory object.static ResourceFactory.Interface
setInstance(ResourceFactory.Interface newInstance)
Set the current factory object.
-
-
-
Method Detail
-
getInstance
public static ResourceFactory.Interface getInstance()
Get the current factory object.- Returns:
- the current factory object
-
setInstance
public static ResourceFactory.Interface setInstance(ResourceFactory.Interface newInstance)
Set the current factory object.- Parameters:
newInstance
- the new factory object- Returns:
- the previous factory object
-
createResource
public static Resource createResource()
Create a new anonymous resource.Uses the current factory object to create a new anonymous resource.
- Returns:
- a new anonymous resource
-
createResource
public static Resource createResource(java.lang.String uriref)
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
public static Resource createStmtResource(Statement statement)
Create a new resource representing an RDF-star triple term.- Parameters:
statement
-- Returns:
- a new resource
-
createPlainLiteral
public static Literal createPlainLiteral(java.lang.String string)
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
public static Literal createStringLiteral(java.lang.String string)
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
public static Literal createLangLiteral(java.lang.String string, java.lang.String lang)
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
public static Literal createTypedLiteral(java.lang.String string, RDFDatatype dType)
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
public static Literal createTypedLiteral(java.lang.Object value)
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
public static Property createProperty(java.lang.String uriref)
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
public static Property createProperty(java.lang.String namespace, java.lang.String localName)
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
public static Statement createStatement(Resource subject, Property predicate, RDFNode object)
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
-
-