com.hp.hpl.jena.rdf.model
Class ResourceFactory

java.lang.Object
  extended by com.hp.hpl.jena.rdf.model.ResourceFactory

public class ResourceFactory
extends 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 the setInstance method.


Nested Class Summary
static interface ResourceFactory.Interface
          the interface to resource factory objects.
 
Method Summary
static Literal createPlainLiteral(String string)
           
static Property createProperty(String uriref)
          create a new property.
static Property createProperty(String namespace, String localName)
          create a new property.
static Resource createResource()
          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 Literal createTypedLiteral(Object value)
          Answer a typed literal.
static Literal createTypedLiteral(String string, RDFDatatype dType)
           
static ResourceFactory.Interface getInstance()
          get the current factory object.
static ResourceFactory.Interface setInstance(ResourceFactory.Interface newInstance)
          set the current factory object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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(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

createPlainLiteral

public static Literal createPlainLiteral(String string)

createTypedLiteral

public static Literal createTypedLiteral(String string,
                                         RDFDatatype dType)

createTypedLiteral

public static Literal createTypedLiteral(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(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(String namespace,
                                      String localName)
create a new property.

Uses the current factory object to create a new property.

Parameters:
namespace - URIREF of the namespace of the property
localName - 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 statement
predicate - the predicate of the new statement
object - the objectof the new statement
Returns:
a new resource


Licenced under the Apache License, Version 2.0