org.modeshape.jcr.value.binary

## Class BinaryStoreValueFactory

- java.lang.Object
- - org.modeshape.jcr.value.basic.AbstractValueFactory<BinaryValue>
  - - org.modeshape.jcr.value.binary.BinaryStoreValueFactory

- All Implemented Interfaces:
    BinaryFactory, ValueFactory<BinaryValue>

      @Immutable
      public class BinaryStoreValueFactory
      extends AbstractValueFactory<BinaryValue>
      implements BinaryFactory

  An abstract `BinaryFactory` implementation that contains many general methods that are likely to be appropriate for many concrete implementations.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.modeshape.jcr.value.basic.AbstractValueFactory

      `AbstractValueFactory.ConvertingIterator<ValueType>`

  - ### Field Summary

    - ### Fields inherited from class org.modeshape.jcr.value.basic.AbstractValueFactory

      `decoder, propertyType, valueFactories`

    - ### Fields inherited from interface org.modeshape.jcr.value.ValueFactory

      `DEFAULT_DECODER, DEFAULT_ENCODER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BinaryStoreValueFactory(BinaryStore store, TextDecoder decoder, ValueFactories factories, ValueFactory<String> stringFactory)` Create a factory instance that finds persisted binary values in the supplied store, and that uses the supplied decoder and string value factory to convert string values into binary values.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `BinaryValue` | `create(BigDecimal value)` Create a value from a decimal.
    `BinaryValue` | `create(BinaryValue value)` Create a value from the binary content given by the supplied stream.
    `BinaryValue` | `create(boolean value)` Create a boolean from a string.
    `BinaryValue` | `create(byte[] value)` Create a value from the binary content given by the supplied array.
    `BinaryValue` | `create(Calendar value)` Create a value from a Calendar instance.
    `BinaryValue` | `create(Date value)` Create a value from a date.
    `BinaryValue` | `create(DateTime value)` Create a value from a date-time instant.
    `BinaryValue` | `create(double value)` Create a value from a double.
    `BinaryValue` | `create(float value)` Create a value from a float.
    `BinaryValue` | `create(InputStream stream)` Create a value from the binary content given by the supplied stream.
    `BinaryValue` | `create(InputStream stream, String hint)` Create a value from the binary content given by the supplied stream with a hint to the BinaryStore for how to store it
    `BinaryValue` | `create(int value)` Create a value from an integer.
    `BinaryValue` | `create(long value)` Create a long from a string.
    `BinaryValue` | `create(Name value)` Create a value from a name.
    `BinaryValue` | `create(NodeKey value)` Create a value from a `NodeKey`.
    `BinaryValue` | `create(Path.Segment value)` Create a value from a path segment.
    `BinaryValue` | `create(Path value)` Create a value from a path.
    `BinaryValue` | `create(Reference value)` Create a value from a reference.
    `BinaryValue` | `create(String value)` Create a value from a string, using no decoding.
    `BinaryValue` | `create(String value, TextDecoder decoder)` Create a value from a string, using the supplied decoder.
    `BinaryValue` | `create(URI value)` Create a value from a URI.
    `BinaryValue` | `create(UUID value)` Create a value from a UUID.
    `BinaryValue[]` | `createEmptyArray(int length)` Creates an empty array of the given type.
    `BinaryValue` | `find(BinaryKey secureHash, long size)` Find an existing binary value given the supplied binary key.
    `protected ValueFactory<String>` | `getStringValueFactory()`
    `BinaryStoreValueFactory` | `with(BinaryStore store)` Return a potentially new copy of this factory that uses the supplied `BinaryStore` object.
    `BinaryFactory` | `with(ValueFactories valueFactories)` Return a potentially new copy of this factory that uses the supplied ValueFactories object.

    - ### Methods inherited from class org.modeshape.jcr.value.basic.AbstractValueFactory

      `create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, getDecoder, getDecoder, getPropertyType`

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

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

    - ### Methods inherited from interface org.modeshape.jcr.value.ValueFactory

      `create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, getPropertyType`

- - ### Constructor Detail

    - #### BinaryStoreValueFactory

          public BinaryStoreValueFactory(BinaryStore store,
                                 TextDecoder decoder,
                                 ValueFactories factories,
                                 ValueFactory<String> stringFactory)

      Create a factory instance that finds persisted binary values in the supplied store, and that uses the supplied decoder and string value factory to convert string values into binary values.
      Parameters:
        `store` - the binary store; may not be null
        `decoder` - the text decoder; may be null if the default decoder should be used
        `factories` - the set of value factories, used to obtain the `string value factory`; may not be null
        `stringFactory` - the optional string factory that should be used in place of the one in the supplied ValueFactories parameter; may be null

  - ### Method Detail

    - #### with

          public BinaryFactory with(ValueFactories valueFactories)

      Description copied from interface: `ValueFactory`
      Return a potentially new copy of this factory that uses the supplied ValueFactories object.
      Specified by:
        `with` in interface `BinaryFactory`
      Specified by:
        `with` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `valueFactories` - the value factories object; may not be null
      Returns:
        the factory, which may be a new instance or may be this object if the supplied value factories is the same as used by this factory; never null

    - #### with

          public BinaryStoreValueFactory with(BinaryStore store)

      Description copied from interface: `BinaryFactory`
      Return a potentially new copy of this factory that uses the supplied `BinaryStore` object.
      Specified by:
        `with` in interface `BinaryFactory`
      Parameters:
        `store` - the binary store; may not be null
      Returns:
        the factory, which may be a new instance or may be this object if the supplied value binary store is the same as used by this factory; never null

    - #### getStringValueFactory

          protected ValueFactory<String> getStringValueFactory()

      Overrides:
        `getStringValueFactory` in class `AbstractValueFactory<BinaryValue>`
      Returns:
        stringValueFactory

    - #### createEmptyArray

          public BinaryValue[] createEmptyArray(int length)

      Description copied from interface: `ValueFactory`
      Creates an empty array of the given type.
      Specified by:
        `createEmptyArray` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `length` - the length of the array; must be a positive value
      Returns:
        an empty array of the given length.

    - #### create

          public BinaryValue create(String value)

      Description copied from interface: `ValueFactory`
      Create a value from a string, using no decoding.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the string from which the value is to be created
      Returns:
        the value, or null if the supplied string is null
      See Also:
        `ValueFactory.create(String, TextDecoder)`

    - #### create

          public BinaryValue create(String value,
                           TextDecoder decoder)

      Description copied from interface: `ValueFactory`
      Create a value from a string, using the supplied decoder.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the string from which the value is to be created
        `decoder` - the decoder that should be used; if null, the `default decoder` is used
      Returns:
        the value, or null if the supplied string is null
      See Also:
        `ValueFactory.create(String)`

    - #### create

          public BinaryValue create(int value)

      Description copied from interface: `ValueFactory`
      Create a value from an integer.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the integer from which the value is to be created
      Returns:
        the value; never null

    - #### create

          public BinaryValue create(long value)

      Description copied from interface: `ValueFactory`
      Create a long from a string.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the string from which the long is to be created
      Returns:
        the value; never null

    - #### create

          public BinaryValue create(boolean value)

      Description copied from interface: `ValueFactory`
      Create a boolean from a string.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the boolean from which the value is to be created
      Returns:
        the value; never null

    - #### create

          public BinaryValue create(float value)

      Description copied from interface: `ValueFactory`
      Create a value from a float.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the float from which the value is to be created
      Returns:
        the value; never null

    - #### create

          public BinaryValue create(double value)

      Description copied from interface: `ValueFactory`
      Create a value from a double.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the double from which the value is to be created
      Returns:
        the value; never null

    - #### create

          public BinaryValue create(BigDecimal value)

      Description copied from interface: `ValueFactory`
      Create a value from a decimal.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the decimal from which the value is to be created
      Returns:
        the value, or null if the supplied decimal is null

    - #### create

          public BinaryValue create(Calendar value)

      Description copied from interface: `ValueFactory`
      Create a value from a Calendar instance.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the Calendar instance from which the value is to be created
      Returns:
        the value, or null if the supplied Calendar is null

    - #### create

          public BinaryValue create(Date value)

      Description copied from interface: `ValueFactory`
      Create a value from a date.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the date from which the value is to be created
      Returns:
        the value, or null if the supplied date is null

    - #### create

          public BinaryValue create(DateTime value)
                             throws ValueFormatException

      Description copied from interface: `ValueFactory`
      Create a value from a date-time instant.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the date-time instant from which the value is to be created
      Returns:
        the value, or null if the supplied date is null
      Throws:
        `ValueFormatException` - if the conversion from a Date could not be performed

    - #### create

          public BinaryValue create(Name value)

      Description copied from interface: `ValueFactory`
      Create a value from a name.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the name from which the value is to be created
      Returns:
        the value, or null if the supplied name is null

    - #### create

          public BinaryValue create(Path value)

      Description copied from interface: `ValueFactory`
      Create a value from a path.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the path from which the value is to be created
      Returns:
        the value, or null if the supplied path is null

    - #### create

          public BinaryValue create(Path.Segment value)

      Description copied from interface: `ValueFactory`
      Create a value from a path segment.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the path segment from which the value is to be created
      Returns:
        the value, or null if the supplied path segment is null

    - #### create

          public BinaryValue create(Reference value)

      Description copied from interface: `ValueFactory`
      Create a value from a reference.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the reference from which the value is to be created
      Returns:
        the value, or null if the supplied reference is null

    - #### create

          public BinaryValue create(URI value)

      Description copied from interface: `ValueFactory`
      Create a value from a URI.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the URI from which the value is to be created
      Returns:
        the value, or null if the supplied URI is null

    - #### create

          public BinaryValue create(UUID value)

      Description copied from interface: `ValueFactory`
      Create a value from a UUID.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the UUID from which the value is to be created
      Returns:
        the value, or null if the supplied URI is null

    - #### create

          public BinaryValue create(NodeKey value)
                             throws ValueFormatException

      Description copied from interface: `ValueFactory`
      Create a value from a `NodeKey`.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the node key from which the value is to be created
      Returns:
        the value, or null if the supplied URI is null
      Throws:
        `ValueFormatException` - if the conversion from a NodeKey could not be performed

    - #### create

          public BinaryValue create(BinaryValue value)
                             throws ValueFormatException,
                                    IoException

      Description copied from interface: `ValueFactory`
      Create a value from the binary content given by the supplied stream.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the binary object to be used to create the value
      Returns:
        the value, or null if the supplied stream is null
      Throws:
        `ValueFormatException` - if the conversion from the binary object could not be performed
        `IoException` - If an unexpected problem occurs while accessing the supplied binary value (such as an `IOException`).

    - #### create

          public BinaryValue create(byte[] value)
                             throws ValueFormatException

      Description copied from interface: `ValueFactory`
      Create a value from the binary content given by the supplied array.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `value` - the content to be used to create the value
      Returns:
        the value, or null if the supplied stream is null
      Throws:
        `ValueFormatException` - if the conversion from a byte array could not be performed

    - #### create

          public BinaryValue create(InputStream stream)
                             throws IoException

      Description copied from interface: `ValueFactory`
      Create a value from the binary content given by the supplied stream.
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Parameters:
        `stream` - the stream containing the content to be used to create the value
      Returns:
        the value, or null if the supplied stream is null
      Throws:
        `IoException` - If an unexpected problem occurs while accessing the supplied stream (such as an `IOException`).

    - #### create

          public BinaryValue create(InputStream stream,
                           String hint)
                             throws IoException

      Description copied from interface: `ValueFactory`
      Create a value from the binary content given by the supplied stream with a hint to the BinaryStore for how to store it
      Specified by:
        `create` in interface `ValueFactory<BinaryValue>`
      Overrides:
        `create` in class `AbstractValueFactory<BinaryValue>`
      Parameters:
        `stream` - the stream containing the content to be used to create the value
        `hint` - a hint that the BinaryStore may use to make storage decisions about this input stream
      Returns:
        the value, or null if the supplied stream is null
      Throws:
        `IoException` - If an unexpected problem occurs while accessing the supplied stream (such as an `IOException`).

    - #### find

          public BinaryValue find(BinaryKey secureHash,
                         long size)
                           throws BinaryStoreException

      Description copied from interface: `BinaryFactory`
      Find an existing binary value given the supplied binary key. If no such binary value exists, null is returned. This method can be used when the caller knows the secure hash (e.g., from a previously-held Binary object), and would like to reuse an existing binary value (if possible).
      Specified by:
        `find` in interface `BinaryFactory`
      Parameters:
        `secureHash` - the secure hash of the binary content, which was probably `obtained` from a previously-held `BinaryValue` object; a null or empty value is allowed, but will always result in returning null
        `size` - the size of the binary content
      Returns:
        the existing Binary value that has the same secure hash; never null
      Throws:
        `BinaryStoreException` - if there is a problem accessing the binary store

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.