com.bea.content
Class BinaryValue

java.lang.Object
  extended by com.bea.content.BinaryValue
All Implemented Interfaces
Serializable

public class BinaryValue
extends Object
implements Serializable

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

A BinaryValue must always contain the contentType, name and size. If the bytes are not present (they are not contained on when retrieving a Property for performance reasons), they can be retrieved through INodeManager.getStream(ContentContext, ID, String) for Property bytes and ITypeManager.getStream(ContentContext, ID, ID) for PropertyChoice bytes. A size of -1, means it is not available.

After using a BinaryValue, it is necessary to close the value InputStream.

A binary value'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 value be persisted to the filesystem by its name.

See Also
Serialized Form

Constructor Summary
BinaryValue()
          Constructs an empty BinaryValue.
BinaryValue(String contentType, String name, int size)
          Constructs a BinaryValue without the bytes.
BinaryValue(String contentType, String name, int size, InputStream value)
          Constructs a full BinaryValue.
 
Method Summary
 Object clone()
          Clones a binary value.
 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.
 InputStream getValue()
          Gets the binary data.
 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 value.
 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.
 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BinaryValue

public BinaryValue()
Constructs an empty BinaryValue.


BinaryValue

public BinaryValue(String contentType,
                   String name,
                   int size)
Constructs a BinaryValue without the bytes.

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 value.

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 value.
value - - the the binary value as a an InputStream.
Method Detail

getContentType

public String getContentType()
Gets the content type for the binary data. For example, "mimetypevalue;charset=charsetvalue"


setContentType

public void setContentType(String contentType)
Sets the content type for the binary data. For example, "mimetypevalue;charset=charsetvalue".


getName

public String getName()
Gets the filename for the binary data, including the file extension. For example, foo.html


setName

public void setName(String name)
Sets the filename for the binary data, including the file extension. For example, foo.html


getValue

public InputStream getValue()
Gets the binary data.

WARNING: If using this interface to retrieve binary content from a BEA Repository, please read the javadoc for RepositoryConfig. After using the value, it is necessary to close the InputStream.


setValue

public void setValue(InputStream value)
Sets the binary data.


getSize

public int getSize()
Returns the size in bytes.


setSize

public void setSize(int size)
Sets the size in bytes.


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 binary value. Note that binary value 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 BEA 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 value. This also causes the isChecksumManuallySet flag to be true. When using the BEA repository the checksum is generated by the repository at create or update time as an MD5 Hex representation. Therefore, users that are using a BEA 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 BEA 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.


Copyright © 2006 BEA Systems, Inc. All Rights Reserved