com.amazon.carbonado.lob
Class CharArrayClob

java.lang.Object
  extended by com.amazon.carbonado.lob.AbstractClob
      extended by com.amazon.carbonado.lob.CharArrayClob
All Implemented Interfaces:
Clob, Lob

public class CharArrayClob
extends AbstractClob

Implementation of a Clob which is backed by a growable in-memory character array.

Author:
Brian S O'Neill

Constructor Summary
CharArrayClob(char[] data)
          Construct a CharArrayClob initially backed by the given character array.
CharArrayClob(char[] data, int length)
          Construct a CharArrayClob initially backed by the given character array.
CharArrayClob(int capacity)
          Construct a CharArrayClob with the given initial capacity.
 
Method Summary
 String asString()
          Convenience method to capture all the Clob data as a single String.
 long getLength()
          Returns the length of this Clob, in characters.
 Object getLocator()
          Always returns null.
 Reader openReader()
          Returns a Reader for reading Clob data, positioned at the start.
 Reader openReader(long pos)
          Returns a Reader for reading Clob data.
 Reader openReader(long pos, int bufferSize)
          Returns a Reader for reading Clob data.
 Writer openWriter()
          Returns a Writer for writing Clob data, positioned at the start.
 Writer openWriter(long pos)
          Returns a Writer for writing Clob data.
 Writer openWriter(long pos, int bufferSize)
          Returns a Writer for writing Clob data.
 void setLength(long length)
          Set the length of this Clob, in characters.
 
Methods inherited from class com.amazon.carbonado.lob.AbstractClob
equals, hashCode, setValue, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CharArrayClob

public CharArrayClob(int capacity)
Construct a CharArrayClob with the given initial capacity.

Parameters:
capacity - initial capacity of internal character array

CharArrayClob

public CharArrayClob(char[] data)
Construct a CharArrayClob initially backed by the given character array. The character array is not cloned until this CharArrayClob grows or shrinks.

Parameters:
data - initial data backing the Clob

CharArrayClob

public CharArrayClob(char[] data,
                     int length)
Construct a CharArrayClob initially backed by the given character array. The character array is not cloned until this CharArrayClob grows or shrinks.

Parameters:
data - initial data backing the Clob
length - initial length of data
Method Detail

openReader

public Reader openReader()
Description copied from interface: Clob
Returns a Reader for reading Clob data, positioned at the start. The Clob implementation selects an appropriate buffer size for the reader.

Returns:
Reader for this Blob, which is not guaranteed to be thread-safe

openReader

public Reader openReader(long pos)
Description copied from interface: Clob
Returns a Reader for reading Clob data. The Clob implementation selects an appropriate buffer size for the reader.

Parameters:
pos - desired zero-based position to read from
Returns:
Reader for this Blob, which is not guaranteed to be thread-safe

openReader

public Reader openReader(long pos,
                         int bufferSize)
Description copied from interface: Clob
Returns a Reader for reading Clob data. A suggested buffer size must be provided, but it might be ignored by the Clob implementation.

Parameters:
pos - desired zero-based position to read from
bufferSize - suggest that the reader buffer be at least this large (in characters)
Returns:
Reader for this Blob, which is not guaranteed to be thread-safe

getLength

public long getLength()
Description copied from interface: Clob
Returns the length of this Clob, in characters.


asString

public String asString()
Description copied from interface: Clob
Convenience method to capture all the Clob data as a single String. Call within a transaction scope to ensure the data does not change while the String is being built.

Specified by:
asString in interface Clob
Overrides:
asString in class AbstractClob

openWriter

public Writer openWriter()
Description copied from interface: Clob
Returns a Writer for writing Clob data, positioned at the start. The Clob implementation selects an appropriate buffer size for the writer.

Returns:
Writer for this Blob, which is not guaranteed to be thread-safe

openWriter

public Writer openWriter(long pos)
Description copied from interface: Clob
Returns a Writer for writing Clob data. The Clob implementation selects an appropriate buffer size for the writer.

Parameters:
pos - desired zero-based position to write to
Returns:
Writer for this Blob, which is not guaranteed to be thread-safe

openWriter

public Writer openWriter(long pos,
                         int bufferSize)
Description copied from interface: Clob
Returns a Writer for writing Clob data. A suggested buffer size must be provided, but it might be ignored by the Clob implementation.

Parameters:
pos - desired zero-based position to write to
bufferSize - suggest that the writer buffer be at least this large (in characters)
Returns:
Writer for this Blob, which is not guaranteed to be thread-safe

setLength

public void setLength(long length)
               throws PersistException
Description copied from interface: Clob
Set the length of this Clob, in characters. If the new length is shorter, the Clob is truncated. If the new length is longer, the Clob is padded with '\0' characters.

Parameters:
length - new length to set to
Throws:
PersistDeniedException - if Clob is read-only
PersistException

getLocator

public Object getLocator()
Always returns null.



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