com.amazon.carbonado.lob
Class AbstractBlob

java.lang.Object
  extended by com.amazon.carbonado.lob.AbstractBlob
All Implemented Interfaces:
Blob, Lob
Direct Known Subclasses:
ByteArrayBlob, FileBlob

public abstract class AbstractBlob
extends Object
implements Blob

AbstractBlob implements a small set of common Blob methods.

Author:
Brian S O'Neill

Constructor Summary
protected AbstractBlob()
           
protected AbstractBlob(Repository repo)
          Use of this constructor indicates that setValue should operate within a transaction.
 
Method Summary
 String asString()
          Convenience method to capture all the Blob data as a single String, assuming UTF-8 encoding.
 String asString(Charset charset)
          Convenience method to capture all the Blob data as a single String, decoded against the given charset.
 String asString(String charsetName)
          Convenience method to capture all the Blob data as a single String, decoded against the given charset.
 boolean equals(Object obj)
          Two Lobs are considered equal if the object instances are the same or if they point to the same content.
 int hashCode()
           
 void setValue(String value)
          Convenience method to overwrite all Blob data with the value of a single String, applying UTF-8 encoding.
 void setValue(String value, Charset charset)
          Convenience method to overwrite all Blob data with the value of a single String, applying the given charset encoding.
 void setValue(String value, String charsetName)
          Convenience method to overwrite all Blob data with the value of a single String, applying the given charset encoding.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.amazon.carbonado.lob.Blob
getLength, openInputStream, openInputStream, openInputStream, openOutputStream, openOutputStream, openOutputStream, setLength
 
Methods inherited from interface com.amazon.carbonado.lob.Lob
getLocator
 

Constructor Detail

AbstractBlob

protected AbstractBlob()

AbstractBlob

protected AbstractBlob(Repository repo)
Use of this constructor indicates that setValue should operate within a transaction. A Repository is passed in for entering the transaction.

Parameters:
repo - optional repository to use for performing string conversion within transactions
Method Detail

asString

public String asString()
                throws FetchException
Description copied from interface: Blob
Convenience method to capture all the Blob data as a single String, assuming UTF-8 encoding. Call within a transaction scope to ensure the data does not change while the String is being built.

Specified by:
asString in interface Blob
Throws:
FetchException

asString

public String asString(String charsetName)
                throws FetchException
Description copied from interface: Blob
Convenience method to capture all the Blob data as a single String, decoded against the given charset. Call within a transaction scope to ensure the data does not change while the String is being built.

Specified by:
asString in interface Blob
Parameters:
charsetName - name of character set to decode String
Throws:
FetchException

asString

public String asString(Charset charset)
                throws FetchException
Description copied from interface: Blob
Convenience method to capture all the Blob data as a single String, decoded against the given charset. Call within a transaction scope to ensure the data does not change while the String is being built.

Specified by:
asString in interface Blob
Parameters:
charset - character set to decode String
Throws:
FetchException

setValue

public void setValue(String value)
              throws PersistException
Description copied from interface: Blob
Convenience method to overwrite all Blob data with the value of a single String, applying UTF-8 encoding. The Blob length may grow or shrink, to match the encoded String value. Call within a transaction scope to ensure the data and length does not change while the value is set.

Specified by:
setValue in interface Blob
Parameters:
value - Blob is overwritten with this value
Throws:
PersistException

setValue

public void setValue(String value,
                     String charsetName)
              throws PersistException
Description copied from interface: Blob
Convenience method to overwrite all Blob data with the value of a single String, applying the given charset encoding. The Blob length may grow or shrink, to match the encoded String value. Call within a transaction scope to ensure the data and length does not change while the value is set.

Specified by:
setValue in interface Blob
Parameters:
value - Blob is overwritten with this value
charsetName - name of character set to encode String
Throws:
PersistException

setValue

public void setValue(String value,
                     Charset charset)
              throws PersistException
Description copied from interface: Blob
Convenience method to overwrite all Blob data with the value of a single String, applying the given charset encoding. The Blob length may grow or shrink, to match the encoded String value. Call within a transaction scope to ensure the data and length does not change while the value is set.

Specified by:
setValue in interface Blob
Parameters:
value - Blob is overwritten with this value
charset - character set to encode String
Throws:
PersistException

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Description copied from interface: Lob
Two Lobs are considered equal if the object instances are the same or if they point to the same content. Lob data is not compared, as that would be expensive or it may result in a fetch exception.

Specified by:
equals in interface Lob
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.