org.openrdf.sail.memory.model
Class MemValueFactory

java.lang.Object
  extended by org.openrdf.model.impl.ValueFactoryBase
      extended by org.openrdf.sail.memory.model.MemValueFactory
All Implemented Interfaces:
ValueFactory

public class MemValueFactory
extends ValueFactoryBase

A factory for MemValue objects that keeps track of created objects to prevent the creation of duplicate objects, minimizing memory usage as a result.

Author:
Arjohn Kampman, David Huynh

Constructor Summary
MemValueFactory()
           
 
Method Summary
 void clear()
           
 BNode createBNode(String nodeID)
          Creates a new blank node with the given node identifier.
protected  Literal createFPLiteral(Number n, URI datatype)
          Calls ValueFactoryBase.createNumericLiteral(Number, URI) with the supplied value and datatype as parameters.
protected  Literal createIntegerLiteral(Number n, URI datatype)
          Calls ValueFactoryBase.createNumericLiteral(Number, URI) with the supplied value and datatype as parameters.
 Literal createLiteral(boolean value)
          Calls ValueFactory.createLiteral(String, URI) with the String-value of the supplied value and XMLSchema.BOOLEAN as parameters.
 Literal createLiteral(String value)
          Creates a new literal with the supplied label.
 Literal createLiteral(String value, String language)
          Creates a new literal with the supplied label and language attribute.
 Literal createLiteral(String value, URI datatype)
          Creates a new literal with the supplied label and datatype.
 Literal createLiteral(XMLGregorianCalendar calendar)
          Calls ValueFactory.createLiteral(String, URI) with the String-value of the supplied calendar and the appropriate datatype as parameters.
 MemBNode createMemBNode(BNode bnode)
          See createMemValue() for description.
 MemLiteral createMemLiteral(Literal literal)
          See createMemValue() for description.
 MemResource createMemResource(Resource resource)
          See createMemValue() for description.
 MemURI createMemURI(URI uri)
          See createMemValue() for description.
 MemValue createMemValue(Value value)
          Creates a MemValue for the supplied Value.
 Statement createStatement(Resource subject, URI predicate, Value object)
          Creates a new statement with the supplied subject, predicate and object.
 Statement createStatement(Resource subject, URI predicate, Value object, Resource context)
          Creates a new statement with the supplied subject, predicate and object and associated context.
 URI createURI(String uri)
          Creates a new URI from the supplied string-representation.
 URI createURI(String namespace, String localName)
          Creates a new URI from the supplied namespace and local name.
 MemBNode getMemBNode(BNode bnode)
          See getMemValue() for description.
 Set<MemBNode> getMemBNodes()
          Gets all bnodes that are managed by this value factory.
 MemLiteral getMemLiteral(Literal literal)
          See getMemValue() for description.
 Set<MemLiteral> getMemLiterals()
          Gets all literals that are managed by this value factory.
 MemResource getMemResource(Resource resource)
          See getMemValue() for description.
 MemURI getMemURI(URI uri)
          See getMemValue() for description.
 Set<MemURI> getMemURIs()
          Gets all URIs that are managed by this value factory.
 MemValue getMemValue(Value value)
          Returns a previously created MemValue that is equal to the supplied value, or null if the supplied value is a new value or is equal to null.
 
Methods inherited from class org.openrdf.model.impl.ValueFactoryBase
createBNode, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createNumericLiteral, initBNodeParams
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemValueFactory

public MemValueFactory()
Method Detail

clear

public void clear()

getMemValue

public MemValue getMemValue(Value value)
Returns a previously created MemValue that is equal to the supplied value, or null if the supplied value is a new value or is equal to null.

Parameters:
value - The MemValue equivalent of the supplied value, or null.
Returns:
A previously created MemValue that is equal to value, or null if no such value exists or if value is equal to null.

getMemResource

public MemResource getMemResource(Resource resource)
See getMemValue() for description.


getMemURI

public MemURI getMemURI(URI uri)
See getMemValue() for description.


getMemBNode

public MemBNode getMemBNode(BNode bnode)
See getMemValue() for description.


getMemLiteral

public MemLiteral getMemLiteral(Literal literal)
See getMemValue() for description.


getMemURIs

public Set<MemURI> getMemURIs()
Gets all URIs that are managed by this value factory.

Warning: This method is not synchronized. To iterate over the returned set in a thread-safe way, this method should only be called while synchronizing on this object.

Returns:
An unmodifiable Set of MemURI objects.

getMemBNodes

public Set<MemBNode> getMemBNodes()
Gets all bnodes that are managed by this value factory.

Warning: This method is not synchronized. To iterate over the returned set in a thread-safe way, this method should only be called while synchronizing on this object.

Returns:
An unmodifiable Set of MemBNode objects.

getMemLiterals

public Set<MemLiteral> getMemLiterals()
Gets all literals that are managed by this value factory.

Warning: This method is not synchronized. To iterate over the returned set in a thread-safe way, this method should only be called while synchronizing on this object.

Returns:
An unmodifiable Set of MemURI objects.

createMemValue

public MemValue createMemValue(Value value)
Creates a MemValue for the supplied Value. The supplied value should not already have an associated MemValue. The created MemValue is returned.

Parameters:
value - A Resource or Literal.
Returns:
The created MemValue.

createMemResource

public MemResource createMemResource(Resource resource)
See createMemValue() for description.


createMemURI

public MemURI createMemURI(URI uri)
See createMemValue() for description.


createMemBNode

public MemBNode createMemBNode(BNode bnode)
See createMemValue() for description.


createMemLiteral

public MemLiteral createMemLiteral(Literal literal)
See createMemValue() for description.


createURI

public URI createURI(String uri)
Description copied from interface: ValueFactory
Creates a new URI from the supplied string-representation.

Parameters:
uri - A string-representation of a URI.
Returns:
An object representing the URI.

createURI

public URI createURI(String namespace,
                     String localName)
Description copied from interface: ValueFactory
Creates a new URI from the supplied namespace and local name. Calling this method is funtionally equivalent to calling createURI(namespace+localName), but allows the ValueFactory to reuse supplied namespace and local name strings whenever possible. Note that the values returned by URI.getNamespace() and URI.getLocalName() are not necessarily the same as the values that are supplied to this method.

Parameters:
namespace - The URI's namespace.
localName - The URI's local name.

createBNode

public BNode createBNode(String nodeID)
Description copied from interface: ValueFactory
Creates a new blank node with the given node identifier.

Parameters:
nodeID - The blank node identifier.
Returns:
An object representing the blank node.

createLiteral

public Literal createLiteral(String value)
Description copied from interface: ValueFactory
Creates a new literal with the supplied label.

Parameters:
value - The literal's label.

createLiteral

public Literal createLiteral(String value,
                             String language)
Description copied from interface: ValueFactory
Creates a new literal with the supplied label and language attribute.

Parameters:
value - The literal's label.
language - The literal's language attribute, or null if the literal doesn't have a language.

createLiteral

public Literal createLiteral(String value,
                             URI datatype)
Description copied from interface: ValueFactory
Creates a new literal with the supplied label and datatype.

Parameters:
value - The literal's label.
datatype - The literal's datatype, or null if the literal doesn't have a datatype.

createLiteral

public Literal createLiteral(boolean value)
Description copied from class: ValueFactoryBase
Calls ValueFactory.createLiteral(String, URI) with the String-value of the supplied value and XMLSchema.BOOLEAN as parameters.

Specified by:
createLiteral in interface ValueFactory
Overrides:
createLiteral in class ValueFactoryBase
Parameters:
value - The value for the literal.
Returns:
An xsd:boolean-typed literal for the specified value.

createIntegerLiteral

protected Literal createIntegerLiteral(Number n,
                                       URI datatype)
Description copied from class: ValueFactoryBase
Calls ValueFactoryBase.createNumericLiteral(Number, URI) with the supplied value and datatype as parameters.

Overrides:
createIntegerLiteral in class ValueFactoryBase

createFPLiteral

protected Literal createFPLiteral(Number n,
                                  URI datatype)
Description copied from class: ValueFactoryBase
Calls ValueFactoryBase.createNumericLiteral(Number, URI) with the supplied value and datatype as parameters.

Overrides:
createFPLiteral in class ValueFactoryBase

createLiteral

public Literal createLiteral(XMLGregorianCalendar calendar)
Description copied from class: ValueFactoryBase
Calls ValueFactory.createLiteral(String, URI) with the String-value of the supplied calendar and the appropriate datatype as parameters.

Specified by:
createLiteral in interface ValueFactory
Overrides:
createLiteral in class ValueFactoryBase
Parameters:
calendar - The value for the literal.
Returns:
An typed literal for the specified calendar.
See Also:
XMLGregorianCalendar.toXMLFormat(), XMLGregorianCalendar.getXMLSchemaType(), XMLDatatypeUtil.qnameToURI(javax.xml.namespace.QName)

createStatement

public Statement createStatement(Resource subject,
                                 URI predicate,
                                 Value object)
Description copied from interface: ValueFactory
Creates a new statement with the supplied subject, predicate and object.

Parameters:
subject - The statement's subject.
predicate - The statement's predicate.
object - The statement's object.
Returns:
The created statement.

createStatement

public Statement createStatement(Resource subject,
                                 URI predicate,
                                 Value object,
                                 Resource context)
Description copied from interface: ValueFactory
Creates a new statement with the supplied subject, predicate and object and associated context.

Parameters:
subject - The statement's subject.
predicate - The statement's predicate.
object - The statement's object.
context - The statement's context.
Returns:
The created statement.


Copyright © 2001-2009 Aduna. All Rights Reserved.