Class MemValueFactory
java.lang.Object
org.eclipse.rdf4j.model.base.AbstractValueFactory
org.eclipse.rdf4j.sail.memory.model.MemValueFactory
- All Implemented Interfaces:
ValueFactory
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
ConstructorDescriptionA cache of the most common IRIs to improve lookup performance when users use our vocabularies (eg. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
createBNode
(String nodeID) Creates a new blank node with the given node identifier.Creates a new IRI from the supplied string-representation.Creates a new IRI from the supplied namespace and local name.createLiteral
(boolean value) Creates a new xsd:boolean-typed literal representing the specified value.createLiteral
(String value) Creates a new literal with the supplied label.createLiteral
(String value, String language) Creates a new literal with the supplied label and language attribute.createLiteral
(String value, CoreDatatype datatype) Creates a new literal with the supplied label and datatype.createLiteral
(String value, IRI datatype) Creates a new literal with the supplied label and datatype.createLiteral
(XMLGregorianCalendar calendar) Creates a new literal representing the specified calendar that is typed using the appropriate XML Schema date/time datatype.getMemBNode
(BNode bnode) See getMemValue() for description.Deprecated, for removal: This API element is subject to removal in a future version.Use getMemBNodesIterator() instead.Gets all bnodes that are managed by this value factory.Gets all URIs that are managed by this value factory.getMemLiteral
(Literal literal) See getMemValue() for description.Deprecated, for removal: This API element is subject to removal in a future version.Use getMemLiteralsIterator() instead.Gets all literals that are managed by this value factory.getMemResource
(Resource resource) See getMemValue() for description.See getMemValue() for description.Deprecated, for removal: This API element is subject to removal in a future version.Use getMemIRIsIterator() instead.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.getOrCreateMemBNode
(BNode bnode) SeegetOrCreateMemValue(Value)
for description.getOrCreateMemLiteral
(Literal literal) SeegetOrCreateMemValue(Value)
for description.getOrCreateMemResource
(Resource resource) SeegetOrCreateMemValue(Value)
for description.getOrCreateMemURI
(IRI uri) SeegetOrCreateMemValue(Value)
for description.getOrCreateMemValue
(Value value) Gets or creates a MemValue for the supplied Value.Methods inherited from class org.eclipse.rdf4j.model.base.AbstractValueFactory
createBNode, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createStatement, createStatement, createTriple
-
Constructor Details
-
MemValueFactory
public MemValueFactory()A cache of the most common IRIs to improve lookup performance when users use our vocabularies (eg.RDF.TYPE
).
-
-
Method Details
-
clear
public void clear() -
getMemValue
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
See getMemValue() for description. -
getMemURI
See getMemValue() for description. -
getMemBNode
See getMemValue() for description. -
getMemLiteral
See getMemValue() for description. -
getMemURIs
Deprecated, for removal: This API element is subject to removal in a future version.Use getMemIRIsIterator() instead.Gets all URIs that are managed by this value factory.Warning: This method is not synchronized.
- Returns:
- An unmodifiable Set of MemURI objects.
-
getMemBNodes
Deprecated, for removal: This API element is subject to removal in a future version.Use getMemBNodesIterator() instead.Gets all bnodes that are managed by this value factory.Warning: This method is not synchronized.
- Returns:
- An unmodifiable Set of MemBNode objects.
-
getMemLiterals
Deprecated, for removal: This API element is subject to removal in a future version.Use getMemLiteralsIterator() instead.Gets all literals that are managed by this value factory.Warning: This method is not synchronized.
- Returns:
- An unmodifiable Set of MemURI objects.
-
getMemIRIsIterator
Gets all URIs that are managed by this value factory.- Returns:
- An autocloseable iterator.
-
getMemBNodesIterator
Gets all bnodes that are managed by this value factory.- Returns:
- An autocloseable iterator.
-
getMemLiteralsIterator
Gets all literals that are managed by this value factory.- Returns:
- An autocloseable iterator.
-
getOrCreateMemValue
Gets or creates a MemValue for the supplied Value. If the factory already contains a MemValue object that is equivalent to the supplied value then this equivalent value will be returned. Otherwise a new MemValue will be created, stored for future calls and then returned.- Parameters:
value
- A Resource or Literal.- Returns:
- The existing or created MemValue.
-
getOrCreateMemResource
SeegetOrCreateMemValue(Value)
for description. -
getOrCreateMemURI
SeegetOrCreateMemValue(Value)
for description. -
getOrCreateMemBNode
SeegetOrCreateMemValue(Value)
for description. -
getOrCreateMemLiteral
SeegetOrCreateMemValue(Value)
for description. -
createIRI
Description copied from interface:ValueFactory
Creates a new IRI from the supplied string-representation.- Specified by:
createIRI
in interfaceValueFactory
- Overrides:
createIRI
in classAbstractValueFactory
- Parameters:
uri
- A string-representation of a IRI.- Returns:
- An object representing the IRI.
-
createIRI
Description copied from interface:ValueFactory
Creates a new IRI from the supplied namespace and local name. Calling this method is funtionally equivalent to callingcreateIRI(namespace+localName)
, but allows the ValueFactory to reuse supplied namespace and local name strings whenever possible. Note that the values returned byIRI.getNamespace()
andIRI.getLocalName()
are not necessarily the same as the values that are supplied to this method.- Specified by:
createIRI
in interfaceValueFactory
- Overrides:
createIRI
in classAbstractValueFactory
- Parameters:
namespace
- The IRI's namespace.localName
- The IRI's local name.
-
createBNode
Description copied from interface:ValueFactory
Creates a new blank node with the given node identifier.- Specified by:
createBNode
in interfaceValueFactory
- Overrides:
createBNode
in classAbstractValueFactory
- Parameters:
nodeID
- The blank node identifier.- Returns:
- An object representing the blank node.
-
createLiteral
Description copied from interface:ValueFactory
Creates a new literal with the supplied label. The return value ofLiteral.getDatatype()
for the returned object must bexsd:string
.- Specified by:
createLiteral
in interfaceValueFactory
- Overrides:
createLiteral
in classAbstractValueFactory
- Parameters:
value
- The literal's label, must not be null.- Returns:
- A literal for the specified value.
-
createLiteral
Description copied from interface:ValueFactory
Creates a new literal with the supplied label and language attribute. The return value ofLiteral.getDatatype()
for the returned object must berdf:langString
.- Specified by:
createLiteral
in interfaceValueFactory
- Overrides:
createLiteral
in classAbstractValueFactory
- Parameters:
value
- The literal's label, must not be null.language
- The literal's language attribute, must not be null.- Returns:
- A literal for the specified value and language attribute.
-
createLiteral
Description copied from interface:ValueFactory
Creates a new literal with the supplied label and datatype.- Specified by:
createLiteral
in interfaceValueFactory
- Overrides:
createLiteral
in classAbstractValueFactory
- Parameters:
value
- The literal's label, must not be null.datatype
- The literal's datatype. If it is null, the datatypexsd:string
will be assigned to this literal.- Returns:
- A literal for the specified value and type.
-
createLiteral
Description copied from interface:ValueFactory
Creates a new literal with the supplied label and datatype.- Specified by:
createLiteral
in interfaceValueFactory
- Overrides:
createLiteral
in classAbstractValueFactory
- Parameters:
value
- The literal's label, must not be null.datatype
- The literal's datatype. It may not be null.
-
createLiteral
Description copied from interface:ValueFactory
Creates a new xsd:boolean-typed literal representing the specified value.- Specified by:
createLiteral
in interfaceValueFactory
- Overrides:
createLiteral
in classAbstractValueFactory
- Parameters:
value
- The value for the literal.- Returns:
- An xsd:boolean-typed literal for the specified value.
-
createLiteral
Description copied from interface:ValueFactory
Creates a new literal representing the specified calendar that is typed using the appropriate XML Schema date/time datatype.- Specified by:
createLiteral
in interfaceValueFactory
- Overrides:
createLiteral
in classAbstractValueFactory
- Parameters:
calendar
- The value for the literal.- Returns:
- A typed literal for the specified calendar.
-