Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.content
Class BinaryValue

    java.lang.Object
      com.bea.content.BinaryValue

All Implemented Interfaces
  Serializable, Cloneable

    public class BinaryValue

extends Object
implements Serializable, Cloneable

This class represents binary content. It contains the binary data along with binary metadata.

A BinaryValue must always contain the contentType, name and size.

A size of -1 means that that the size was not available when this object was constructed. Once the value has been persisted, the size will be available.

The stream representing the binary content may not be present depending on the underlying repository and SPI implementation. If the stream is not present, they can be retrieved via `INodeManager.getStream(ContentContext, ID, String)` for Property values and `ITypeManager.getStream(ContentContext, ID, ID)` for PropertyChoice values.

A BinaryValue's name should be a single filename element and therefore should not include path separator characters (either / or \.) These characters have specific meaning to filesystems and may cause trouble should this binary be persisted to the filesystem by its name.

For SPI implementors: After using a BinaryValue, it is necessary to close the value InputStream.

See Also
  Serialized Form

Constructor Summary
`BinaryValue()` Constructs an empty BinaryValue.
`BinaryValue(String contentType, String name, InputStream value)` Constructs a full BinaryValue.
`BinaryValue(String contentType, String name, int size)` Constructs a BinaryValue without the stream.
`BinaryValue(String contentType, String name, int size, InputStream value)` Constructs a full BinaryValue.
`BinaryValue(String contentType, String name, int size, InputStream value, String checksum)` Construct a BinaryValue object with a checksum.

Method Summary
`Object` | `clone()` Clones a BinaryValue.
`boolean` | `equals(Object obj)` Indicates whether some other BinaryValue is "equal to" this one.
`String` | `getChecksum()` Get the checksum for this value.
`String` | `getContentType()` Gets the content type for the binary data.
`String` | `getName()` Gets the filename for the binary data, including the file extension.
`int` | `getSize()` Returns the size in bytes, or -1 if the size is not available.
`InputStream` | `getValue()` Gets the binary data.
`int` | `hashCode()` Returns a hash code value for this binary value.
`boolean` | `isChecksumManuallySet()` If the `setChecksum(String)` method is called this will return true.
`void` | `setChecksum(String checksum)` This will set the checksum for this binary data.
`void` | `setContentType(String contentType)` Sets the content type for the binary data.
`void` | `setName(String name)` Sets the filename for the binary data, including the file extension.
`void` | `setSize(int size)` Sets the size in bytes, specify -1 if unknown.
`void` | `setValue(InputStream value)` Sets the binary data.
`String` | `toString()` Returns the BinaryValue's name as a String.

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### BinaryValue

    public BinaryValue(String contentType,
                       String name,
                       int size,
                       InputStream value,
                       String checksum)

  Construct a BinaryValue object with a checksum.

  Parameters
    `contentType` - - must have the mimeType and optionally the charset in format "mimetypevalue;charset=charsetvalue". For example, "text/html;charset=iso-8859-1"
    `name` - - the filename including the extension. For example, foo.html
    `size` - - the size in bytes of the binary data. Specify -1 if unknown. The size is calculated at create and update time when using the WLP Repository. A value given to this constructor will be ignored by the WLP Repository. Other SPI implementations may chose to populate or ignore this field.
    `value` - - the the binary data as a an InputStream.
    `checksum` - - the checksum of the binary data. The checksum is calculated at create and update time when using the WLP Repository. A value given to this constructor will be ignored by the WLP Repository. Other SPI implementations may chose to populate or ignore this field.

### BinaryValue

    public BinaryValue()

  Constructs an empty BinaryValue.

### BinaryValue

    public BinaryValue(String contentType,
                       String name,
                       int size)

  Constructs a BinaryValue without the stream.

  Parameters
    `contentType` - - must have the mimeType and optionally the charset in format "mimetypevalue;charset=charsetvalue". For example, "text/html;charset=iso-8859-1"
    `name` - - the filename including the extension. For example, foo.html
    `size` - - the size in bytes of the binary data. Specify -1 if unknown. The size is calculated at create and update time when using the WLP Repository. A value given to this constructor will be ignored by the WLP Repository. Other SPI implementations may chose to populate or ignore this field.

### BinaryValue

    public BinaryValue(String contentType,
                       String name,
                       int size,
                       InputStream value)

  Constructs a full BinaryValue.

  Parameters
    `contentType` - - must have the mimeType and optionally the charset in format "mimetypevalue;charset=charsetvalue". For example, "text/html;charset=iso-8859-1"
    `name` - - the filename including the extension. For example, foo.html
    `size` - - the size in bytes of the binary data. Specify -1 if unknown. The size is calculated at create and update time when using the WLP Repository. A value given to this constructor will be ignored by the WLP Repository. Other SPI implementations may chose to populate or ignore this field.
    `value` - - the the binary data as a an InputStream.

### BinaryValue

    public BinaryValue(String contentType,
                       String name,
                       InputStream value)

  Constructs a full BinaryValue.

  Parameters
    `contentType` - - must have the mimeType and optionally the charset in format "mimetypevalue;charset=charsetvalue". For example, "text/html;charset=iso-8859-1"
    `name` - - the filename including the extension. For example, foo.html
    `value` - - the the binary data as a an InputStream.

Method Detail

### getContentType

    public String getContentType()

  Gets the content type for the binary data. For example, "mimetypevalue;charset=charsetvalue"

  Returns
    The content type of the binary data.

### setContentType

    public void setContentType(String contentType)

  Sets the content type for the binary data. For example, "mimetypevalue;charset=charsetvalue".

  Parameters
    `contentType` - the content type of the binary data.

### getName

    public String getName()

  Gets the filename for the binary data, including the file extension. For example, foo.html

  Returns
    The name of the binary data.

### setName

    public void setName(String name)

  Sets the filename for the binary data, including the file extension. For example, foo.html

  Parameters
    `name` - The name of the binary data.

### getValue

    public InputStream getValue()

  Gets the binary data.

  WARNING: If using this interface to retrieve binary content from a WLP Repository, please read the javadoc for `RepositoryConfig`. BinaryValue objects returned from the WLP Repository will not include the value. The value can be retrieved using `INodeManager.getStream(ContentContext, ID, String)` for Property values on published nodes, `IVersionManager.getStream(ContentContext, ID, ID)` for Property values on versions and `ITypeManager.getStream(ContentContext, ID, ID)` for PropertyChoice values.

  Note: After using the value, it is necessary to close the InputStream.

  Returns
    The InputStream representing the binary data (if set.)

### setValue

    public void setValue(InputStream value)

  Sets the binary data.

  Parameters
    `value` - The value to set.

### getSize

    public int getSize()

  Returns the size in bytes, or -1 if the size is not available. After the value has been persisted, the size should be available.

  Returns
    The size.

### setSize

    public void setSize(int size)

  Sets the size in bytes, specify -1 if unknown. This size may not be persisted by repositories; the exact behavior is repository-dependent.

  Parameters
    `size` - The size in bytes of the binary data.

### toString

    public String toString()

  Returns the BinaryValue's name as a String.

  Overrides:
    `toString` in class `Object`

### clone

    public Object clone()
                 throws CloneNotSupportedException

  Clones a BinaryValue. Note that binary data stream values are not cloned, but merely copied.

  Overrides:
    `clone` in class `Object`
  Returns
    A clone of the value.
  Throws
    `CloneNotSupportedException` - If the clone fails.

### getChecksum

    public String getChecksum()

  Get the checksum for this value. When using the WLP Repository the checksum is generated at create or update time as an MD5 Hex representation. Other SPI implementations may chose to expose a checksum, but are not required to.

  Returns
    the checksum

### setChecksum

    public void setChecksum(String checksum)

  This will set the checksum for this binary data. This also causes the isChecksumManuallySet flag to be true. When using the WLP Repository the checksum is generated by the repository at create or update time as an MD5 Hex representation. Therefore, users that are using a WLP Repository are encouraged not to use this method and to allow the repository to fill in the checksum.

  Parameters
    `checksum` - the checksum to set.

### isChecksumManuallySet

    public boolean isChecksumManuallySet()

  If the `setChecksum(String)` method is called this will return true. It is an indication to the underlying repository implementation that the user has explicitly set the checksum. If using a WLP Repository users are encouraged not to set the checksum explicitly and to allow the repository to fill in the checksum.

  Returns
    true if the `setChecksum(String)` method has been called, false otherwise.

### equals

    public boolean equals(Object obj)

  Indicates whether some other BinaryValue is "equal to" this one.

  Overrides:
    `equals` in class `Object`
  Parameters
    `obj` - the reference object with which to compare.
  Returns
    True if the given object is the same as this BinaryValue.

### hashCode

    public int hashCode()

  Returns a hash code value for this binary value.

  Overrides:
    `hashCode` in class `Object`
  Returns
    a hash code value for this binary value.

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

Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.