org.eclipse.rdf4j.sail.memory.model

## Class MemValueFactory

- java.lang.Object
- - org.eclipse.rdf4j.model.base.AbstractValueFactory
  - - org.eclipse.rdf4j.model.impl.AbstractValueFactory
    - - org.eclipse.rdf4j.sail.memory.model.MemValueFactory

- All Implemented Interfaces:
    ValueFactory

      public class MemValueFactory
      extends AbstractValueFactory

  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

    Constructors
    Constructor and Description
    `MemValueFactory()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()`
    `BNode` | `createBNode(String nodeID)` Creates a new blank node with the given node identifier.
    `protected Literal` | `createFPLiteral(Number n, IRI datatype)` Calls `AbstractValueFactory.createNumericLiteral(Number, IRI)` with the supplied value and datatype as parameters.
    `protected Literal` | `createIntegerLiteral(Number n, IRI datatype)` Calls `AbstractValueFactory.createNumericLiteral(Number, IRI)` with the supplied value and datatype as parameters.
    `IRI` | `createIRI(String uri)` Creates a new IRI from the supplied string-representation.
    `IRI` | `createIRI(String namespace, String localName)` Creates a new IRI from the supplied namespace and local name.
    `Literal` | `createLiteral(boolean value)` Creates a new `xsd:boolean`-typed literal representing the specified value.
    `Literal` | `createLiteral(String value)` Creates a new literal with the supplied label.
    `Literal` | `createLiteral(String value, IRI datatype)` Creates a new literal with the supplied label and datatype.
    `Literal` | `createLiteral(String value, String language)` Creates a new literal with the supplied label and language attribute.
    `Literal` | `createLiteral(XMLGregorianCalendar calendar)` Calls `ValueFactory.createLiteral(String, IRI)` with the String-value of the supplied calendar and the appropriate datatype as parameters.
    `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.
    `MemIRI` | `getMemURI(IRI uri)` See getMemValue() for description.
    `Set<MemIRI>` | `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`.
    `MemBNode` | `getOrCreateMemBNode(BNode bnode)` See `getOrCreateMemValue(Value)` for description.
    `MemLiteral` | `getOrCreateMemLiteral(Literal literal)` See `getOrCreateMemValue(Value)` for description.
    `MemResource` | `getOrCreateMemResource(Resource resource)` See `getOrCreateMemValue(Value)` for description.
    `MemIRI` | `getOrCreateMemURI(IRI uri)` See `getOrCreateMemValue(Value)` for description.
    `MemValue` | `getOrCreateMemValue(Value value)` Gets or creates a MemValue for the supplied Value.

    - ### Methods inherited from class org.eclipse.rdf4j.model.impl.AbstractValueFactory

      `createBNode, createFPLiteral, createIntegerLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createNumericLiteral, createNumericLiteral, createStatement, createStatement, createTriple, initBNodeParams`

    - ### Methods inherited from class org.eclipse.rdf4j.model.base.AbstractValueFactory

      `createLiteral, createLiteral`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.rdf4j.model.ValueFactory

      `createLiteral, createStatement, createStatement, createURI, createURI`

- - ### 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 MemIRI getMemURI(IRI 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<MemIRI> 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.

    - #### getOrCreateMemValue

          public MemValue getOrCreateMemValue(Value value)

      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

          public MemResource getOrCreateMemResource(Resource resource)

      See `getOrCreateMemValue(Value)` for description.

    - #### getOrCreateMemURI

          public MemIRI getOrCreateMemURI(IRI uri)

      See `getOrCreateMemValue(Value)` for description.

    - #### getOrCreateMemBNode

          public MemBNode getOrCreateMemBNode(BNode bnode)

      See `getOrCreateMemValue(Value)` for description.

    - #### getOrCreateMemLiteral

          public MemLiteral getOrCreateMemLiteral(Literal literal)

      See `getOrCreateMemValue(Value)` for description.

    - #### createIRI

          public IRI createIRI(String uri)

      Description copied from interface: `ValueFactory`
      Creates a new IRI from the supplied string-representation.
      Specified by:
        `createIRI` in interface `ValueFactory`
      Overrides:
        `createIRI` in class `AbstractValueFactory`
      Parameters:
        `uri` - A string-representation of a IRI.
      Returns:
        An object representing the IRI.

    - #### createIRI

          public IRI createIRI(String namespace,
                               String localName)

      Description copied from interface: `ValueFactory`
      Creates a new IRI from the supplied namespace and local name. Calling this method is funtionally equivalent to calling `createIRI(namespace+localName)`, but allows the ValueFactory to reuse supplied namespace and local name strings whenever possible. Note that the values returned by `IRI.getNamespace()` and `IRI.getLocalName()` are not necessarily the same as the values that are supplied to this method.
      Specified by:
        `createIRI` in interface `ValueFactory`
      Overrides:
        `createIRI` in class `AbstractValueFactory`
      Parameters:
        `namespace` - The IRI's namespace.
        `localName` - The IRI's local name.

    - #### createBNode

          public BNode createBNode(String nodeID)

      Description copied from interface: `ValueFactory`
      Creates a new blank node with the given node identifier.
      Specified by:
        `createBNode` in interface `ValueFactory`
      Overrides:
        `createBNode` in class `AbstractValueFactory`
      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. The return value of `Literal.getDatatype()` for the returned object must be `xsd:string`.
      Specified by:
        `createLiteral` in interface `ValueFactory`
      Overrides:
        `createLiteral` in class `AbstractValueFactory`
      Parameters:
        `value` - The literal's label, must not be `null`.

    - #### createLiteral

          public Literal createLiteral(String value,
                                       String language)

      Description copied from interface: `ValueFactory`
      Creates a new literal with the supplied label and language attribute. The return value of `Literal.getDatatype()` for the returned object must be `rdf:langString`.
      Specified by:
        `createLiteral` in interface `ValueFactory`
      Overrides:
        `createLiteral` in class `AbstractValueFactory`
      Parameters:
        `value` - The literal's label, must not be `null`.
        `language` - The literal's language attribute, must not be `null`.

    - #### createLiteral

          public Literal createLiteral(String value,
                                       IRI datatype)

      Description copied from interface: `ValueFactory`
      Creates a new literal with the supplied label and datatype.
      Specified by:
        `createLiteral` in interface `ValueFactory`
      Overrides:
        `createLiteral` in class `AbstractValueFactory`
      Parameters:
        `value` - The literal's label, must not be `null`.
        `datatype` - The literal's datatype. If it is null, the datatype `xsd:string` will be assigned to this literal.

    - #### createLiteral

          public Literal createLiteral(boolean value)

      Description copied from interface: `ValueFactory`
      Creates a new `xsd:boolean`-typed literal representing the specified value.
      Specified by:
        `createLiteral` in interface `ValueFactory`
      Overrides:
        `createLiteral` in class `AbstractValueFactory`
      Parameters:
        `value` - The value for the literal.
      Returns:
        An `xsd:boolean`-typed literal for the specified value.

    - #### createIntegerLiteral

          protected Literal createIntegerLiteral(Number n,
                                                 IRI datatype)

      Description copied from class: `AbstractValueFactory`
      Calls `AbstractValueFactory.createNumericLiteral(Number, IRI)` with the supplied value and datatype as parameters.
      Overrides:
        `createIntegerLiteral` in class `AbstractValueFactory`

    - #### createFPLiteral

          protected Literal createFPLiteral(Number n,
                                            IRI datatype)

      Description copied from class: `AbstractValueFactory`
      Calls `AbstractValueFactory.createNumericLiteral(Number, IRI)` with the supplied value and datatype as parameters.
      Overrides:
        `createFPLiteral` in class `AbstractValueFactory`

    - #### createLiteral

          public Literal createLiteral(XMLGregorianCalendar calendar)

      Description copied from class: `AbstractValueFactory`
      Calls `ValueFactory.createLiteral(String, IRI)` with the String-value of the supplied calendar and the appropriate datatype as parameters.
      Specified by:
        `createLiteral` in interface `ValueFactory`
      Overrides:
        `createLiteral` in class `AbstractValueFactory`
      Parameters:
        `calendar` - The value for the literal.
      Returns:
        A typed literal for the specified calendar.
      See Also:
        `XMLGregorianCalendar.toXMLFormat()`, `XMLGregorianCalendar.getXMLSchemaType()`, `XMLDatatypeUtil.qnameToURI(javax.xml.namespace.QName)`

Copyright © 2015-2021 Eclipse Foundation. All Rights Reserved.