Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph.property.basic
Class AbstractBinaryValueFactory

    java.lang.Object
      org.modeshape.graph.property.basic.AbstractValueFactory<Binary>
          org.modeshape.graph.property.basic.AbstractBinaryValueFactory

All Implemented Interfaces:
  BinaryFactory, ValueFactory<Binary>

Direct Known Subclasses:
  InMemoryBinaryValueFactory

    @Immutable
    public abstract class AbstractBinaryValueFactory

extends AbstractValueFactory<Binary>
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.graph.property.basic.AbstractValueFactory
`AbstractValueFactory.ConvertingIterator<ValueType>`

Field Summary

Fields inherited from interface org.modeshape.graph.property.ValueFactory
`DEFAULT_DECODER, DEFAULT_ENCODER`

Constructor Summary
`protected` | `AbstractBinaryValueFactory(TextDecoder decoder, ValueFactory<String> stringValueFactory)`

Method Summary
`Binary` | `create(BigDecimal value)` Create a value from a decimal.
`Binary` | `create(Binary value)` Create a value from the binary content given by the supplied stream.
`Binary` | `create(boolean value)` Create a boolean from a string.
`Binary` | `create(Calendar value)` Create a value from a Calendar instance.
`Binary` | `create(Date value)` Create a value from a date.
`Binary` | `create(DateTime value)` Create a value from a date-time instant.
`Binary` | `create(double value)` Create a value from a double.
`Binary` | `create(File file)` Create a binary value from the given file.
`Binary` | `create(float value)` Create a value from a float.
`Binary` | `create(InputStream stream, long approximateLength)` Create a value from the binary content given by the supplied stream.
`Binary` | `create(InputStream stream, long approximateLength, byte[] secureHash)` Create a value from the binary content given by the supplied stream, the approximate length, and the SHA-1 secure hash of the content.
`Binary` | `create(int value)` Create a value from an integer.
`Binary` | `create(long value)` Create a long from a string.
`Binary` | `create(Name value)` Create a value from a name.
`Binary` | `create(Path.Segment value)` Create a value from a path segment.
`Binary` | `create(Path value)` Create a value from a path.
`Binary` | `create(Reader reader, long approximateLength)` Create a value from a the binary content given by the supplied reader.
`Binary` | `create(Reader reader, long approximateLength, byte[] secureHash)` Create a value from the binary content given by the supplied reader, the approximate length, and the SHA-1 secure hash of the content.
`Binary` | `create(Reference value)` Create a value from a reference.
`Binary` | `create(String value)` Create a value from a string, using no decoding.
`Binary` | `create(String value, TextDecoder decoder)` Create a value from a string, using the supplied decoder.
`Binary` | `create(URI value)` Create a value from a URI.
`Binary` | `create(UUID value)` Create a value from a UUID.
`protected Binary[]` | `createEmptyArray(int length)`
`Binary` | `find(byte[] secureHash)` Find an existing binary value given the supplied secure hash.

Methods inherited from class org.modeshape.graph.property.basic.AbstractValueFactory
`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, getStringValueFactory`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.modeshape.graph.property.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

### AbstractBinaryValueFactory

    protected AbstractBinaryValueFactory(TextDecoder decoder,
                                         ValueFactory<String> stringValueFactory)

Method Detail

### create

    public Binary create(String value)

  Create a value from a string, using no decoding.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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 Binary create(String value,
                         TextDecoder decoder)

  Create a value from a string, using the supplied decoder.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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 Binary create(int value)

  Create a value from an integer.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  Parameters:
    `value` - the integer from which the value is to be created
  Returns:
    the value; never null

### create

    public Binary create(long value)

  Create a long from a string.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  Parameters:
    `value` - the string from which the long is to be created
  Returns:
    the value; never null

### create

    public Binary create(boolean value)

  Create a boolean from a string.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  Parameters:
    `value` - the boolean from which the value is to be created
  Returns:
    the value; never null

### create

    public Binary create(float value)

  Create a value from a float.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  Parameters:
    `value` - the float from which the value is to be created
  Returns:
    the value; never null

### create

    public Binary create(double value)

  Create a value from a double.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  Parameters:
    `value` - the double from which the value is to be created
  Returns:
    the value; never null

### create

    public Binary create(BigDecimal value)

  Create a value from a decimal.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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 Binary create(Calendar value)

  Create a value from a Calendar instance.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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 Binary create(Date value)

  Create a value from a date.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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 Binary create(DateTime value)
                  throws ValueFormatException

  Create a value from a date-time instant.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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
  See Also:
    `ValueFactory.create(org.modeshape.graph.property.DateTime)`

### create

    public Binary create(Name value)

  Create a value from a name.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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 Binary create(Path value)

  Create a value from a path.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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 Binary create(Path.Segment value)

  Create a value from a path segment.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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 Binary create(Reference value)

  Create a value from a reference.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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 Binary create(URI value)

  Create a value from a URI.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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 Binary create(UUID value)

  Create a value from a UUID.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  Parameters:
    `value` - the UUID from which the value is to be created
  Returns:
    the value, or null if the supplied URI is null
  See Also:
    `ValueFactory.create(java.util.UUID)`

### create

    public Binary create(Binary value)
                  throws ValueFormatException,
                         IoException

  Create a value from the binary content given by the supplied stream.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  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`).
  See Also:
    `ValueFactory.create(org.modeshape.graph.property.Binary)`

### create

    public Binary create(InputStream stream,
                         long approximateLength)
                  throws IoException

  Create a value from the binary content given by the supplied stream.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  Parameters:
    `stream` - the stream containing the content to be used to create the value
    `approximateLength` - the approximate length of the content (in bytes)
  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 Binary create(Reader reader,
                         long approximateLength)
                  throws IoException

  Create a value from a the binary content given by the supplied reader.

  Specified by:
    `create` in interface `ValueFactory<Binary>`
  Parameters:
    `reader` - the reader containing the content to be used to create the value
    `approximateLength` - the approximate length of the content (in bytes)
  Returns:
    the value, or null if the supplied string is null
  Throws:
    `IoException` - If an unexpected problem occurs while accessing the supplied reader (such as an `IOException`).

### create

    public Binary create(File file)
                  throws ValueFormatException,
                         IoException

  Create a binary value from the given file.

  Specified by:
    `create` in interface `BinaryFactory`
  Parameters:
    `file` - the file containing the content to be used
  Returns:
    the binary value, or null if the file parameter was null
  Throws:
    `ValueFormatException` - if the conversion from the file could not be performed
    `IoException` - If an unexpected problem occurs while accessing the supplied file (such as an `IOException`).
  See Also:
    `BinaryFactory.create(java.io.File)`

### create

    public Binary create(Reader reader,
                         long approximateLength,
                         byte[] secureHash)
                  throws ValueFormatException,
                         IoException

  Create a value from the binary content given by the supplied reader, the approximate length, and the SHA-1 secure hash of the content. If the secure hash is null, then a secure hash is computed from the content. If the secure hash is not null, it is assumed to be the hash for the content and may not be checked.

  This implementation does not manage or share the in-memory binary values, so this implementation is identical to calling `create(Reader, long)`.

  Specified by:
    `create` in interface `BinaryFactory`
  Parameters:
    `reader` - the reader containing the content to be used to create the value
    `approximateLength` - the approximate length of the content (in bytes)
    `secureHash` - the secure hash of the content in the `stream`; if null, the secure hash is computed from the content, and if not null it is assumed to be the correct secure hash (and is not checked)
  Returns:
    the value, or null if the supplied string is null
  Throws:
    `ValueFormatException` - if the conversion from a reader could not be performed
    `IoException` - If an unexpected problem occurs while accessing the supplied reader (such as an `IOException`).
  See Also:
    `BinaryFactory.create(java.io.Reader, long, byte[])`

### create

    public Binary create(InputStream stream,
                         long approximateLength,
                         byte[] secureHash)
                  throws ValueFormatException,
                         IoException

  Create a value from the binary content given by the supplied stream, the approximate length, and the SHA-1 secure hash of the content. If the secure hash is null, then a secure hash is computed from the content. If the secure hash is not null, it is assumed to be the hash for the content and may not be checked.

  This implementation does not manage or share the in-memory binary values, so this implementation is identical to calling `create(InputStream, long)`.

  Specified by:
    `create` in interface `BinaryFactory`
  Parameters:
    `stream` - the stream containing the content to be used to create the value
    `approximateLength` - the approximate length of the content (in bytes)
    `secureHash` - the secure hash of the content in the `stream`; if null, the secure hash is computed from the content, and if not null it is assumed to be the correct secure hash (and is not checked)
  Returns:
    the value, or null if the supplied stream is null
  Throws:
    `ValueFormatException` - if the conversion from an input stream could not be performed
    `IoException` - If an unexpected problem occurs while accessing the supplied stream (such as an `IOException`).
  See Also:
    `BinaryFactory.create(java.io.InputStream, long, byte[])`

### find

    public Binary find(byte[] secureHash)

  Find an existing binary value given the supplied secure hash. 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) rather than recreate the binary value by processing the stream contents. This is especially true when the size of the binary is quite large.

  This method always returns null, since the in-memory binary values are not managed or shared.

  Specified by:
    `find` in interface `BinaryFactory`
  Parameters:
    `secureHash` - the secure hash of the binary content, which was probably `obtained` from a previously-held `Binary` object; a null or empty value is allowed, but will always result in returning null
  Returns:
    the existing Binary value that has the same secure hash, or null if there is no such value available at this time
  See Also:
    `BinaryFactory.find(byte[])`

### createEmptyArray

    protected Binary[] createEmptyArray(int length)

  Specified by:
    `createEmptyArray` in class `AbstractValueFactory<Binary>`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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