Berkeley DB
version 4.2.52

com.sleepycat.bdb
Class DataThang

java.lang.Object
  |
  +--com.sleepycat.db.Dbt
        |
        +--com.sleepycat.bdb.DataThang
All Implemented Interfaces:
DataBuffer

public final class DataThang
extends Dbt
implements DataBuffer

(internal) An extension of a Berkeley DB thang (Dbt) that supports the DataBuffer interface for bindings and other added utilities.

NOTE: This classes is internal and may be changed incompatibly or deleted in the future. It is public only so it may be used by subpackages.


Constructor Summary
DataThang()
          Creates a thang with no data.
DataThang(byte[] bytes)
          Creates a thang containing the given data data.
DataThang(DataThang copyFrom)
          Creates a thang with a copy of the data from the given thang.
 
Method Summary
 void clearDataFormation()
          Sets the formation associated with the data in this buffer to null.
 int compareTo(Dbt key2)
          Returns -1 if the byte array of this thang is less than that of the given thang, 0 if they are equal, or 1 if greater.
 void copy(DataThang copyFrom)
          Copies the data from the given thang to this thang..
static void dump(Dbt dbt, PrintStream out)
          Prints the byte array of the given thing to the given stream using toString() to convert the bytes to a string.
 void dump(PrintStream out)
          Prints the byte array of this thing to the given stream using toString() to convert the bytes to a string.
 boolean equals(Dbt other)
          Returns whether the byte array of this thang is equal to that of the given thang.
 byte[] getBytes()
          Returns the data for this thang.
 ByteArrayInputStream getByteStream()
          Returns the data for this thang as a byte array input stream..
 byte[] getDataBytes()
          Returns the byte array of the data buffer.
 Object getDataFormation()
          Returns the formation associated with the data in this buffer.
 int getDataLength()
          Returns the byte length of the data in the array.
 int getDataOffset()
          Returns the byte offset of the data in the array.
 void increment()
          Increments the data value for this thang, treating the byte array as a Java BigInteger where the bytes are in MSB-first order.
 void setBytes(byte[] bytes)
          Sets the data for this thang.
 void setBytes(byte[] bytes, int offset, int length)
          Sets the data for this thang.
 void setData(byte[] data, int offset, int length)
          Sets the data in this buffer to the given value.
 void setDataFormation(Object formation)
          Sets the formation associated with the data in this buffer.
 String toString()
          Converts the byte array of this thang to space-separated integers, and suffixed by the record number if applicable.
static String toString(Dbt dbt)
          Converts the byte array of this thang to space-separated integers, and suffixed by the record number if applicable.
 
Methods inherited from class com.sleepycat.db.Dbt
get_data, get_dlen, get_doff, get_flags, get_object, get_offset, get_recno_key_data, get_size, get_ulen, getData, getFlags, getObject, getOffset, getPartialLength, getPartialOffset, getRecordNumber, getSize, getUserBufferLength, set_data, set_dlen, set_doff, set_flags, set_object, set_offset, set_recno_key_data, set_size, set_ulen, setData, setFlags, setObject, setOffset, setPartialLength, setPartialOffset, setRecordNumber, setSize, setUserBufferLength
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataThang

public DataThang()
Creates a thang with no data.


DataThang

public DataThang(byte[] bytes)
Creates a thang containing the given data data.

Parameters:
bytes - the initial data.

DataThang

public DataThang(DataThang copyFrom)
Creates a thang with a copy of the data from the given thang.

Parameters:
copyFrom - a data thang to clone.
Method Detail

copy

public void copy(DataThang copyFrom)
Copies the data from the given thang to this thang..

Parameters:
copyFrom - a data thang to clone.

setBytes

public void setBytes(byte[] bytes)
Sets the data for this thang.

Parameters:
bytes - the new data.

setBytes

public void setBytes(byte[] bytes,
                     int offset,
                     int length)
Sets the data for this thang.

Parameters:
bytes - the new data.
offset - the new data offset.
length - the new data length.

getBytes

public byte[] getBytes()
Returns the data for this thang.

Returns:
the data for this thang.

getByteStream

public ByteArrayInputStream getByteStream()
Returns the data for this thang as a byte array input stream..

Returns:
the data as a stream.

increment

public void increment()
Increments the data value for this thang, treating the byte array as a Java BigInteger where the bytes are in MSB-first order. The byte array will be increased in size if necessary.


compareTo

public int compareTo(Dbt key2)
Returns -1 if the byte array of this thang is less than that of the given thang, 0 if they are equal, or 1 if greater. The comparison is performed by treating the bytes as unsigned integers to match the Berkeley DB default key comparison algorithm.

Parameters:
key2 - the key to compare.
Returns:
the comparison result.

equals

public boolean equals(Dbt other)
Returns whether the byte array of this thang is equal to that of the given thang.

Parameters:
other - the thang to compare.
Returns:
whether their data is equal.

dump

public void dump(PrintStream out)
Prints the byte array of this thing to the given stream using toString() to convert the bytes to a string.

Parameters:
out - the stream to write to.

dump

public static void dump(Dbt dbt,
                        PrintStream out)
Prints the byte array of the given thing to the given stream using toString() to convert the bytes to a string.

Parameters:
dbt - the data thang to dump.
out - the stream to write to.

toString

public static String toString(Dbt dbt)
Converts the byte array of this thang to space-separated integers, and suffixed by the record number if applicable.

Parameters:
dbt - the thang to convert.

toString

public String toString()
Converts the byte array of this thang to space-separated integers, and suffixed by the record number if applicable.

Overrides:
toString in class Object

setData

public void setData(byte[] data,
                    int offset,
                    int length)
Description copied from interface: DataBuffer
Sets the data in this buffer to the given value. The byte array given will be owned by this buffer object after this method is called and must not be modified thereafter. This method must clear the data formation for this buffer.

Specified by:
setData in interface DataBuffer
Parameters:
data - is the data array and must not be modified after this method is called.
offset - is the byte offset of the data in the array.
length - is the byte length of the data in the array.

getDataBytes

public byte[] getDataBytes()
Description copied from interface: DataBuffer
Returns the byte array of the data buffer. This array is owned by the buffer object and should not be modified.

Specified by:
getDataBytes in interface DataBuffer
Returns:
the byte array of the data buffer.

getDataOffset

public int getDataOffset()
Description copied from interface: DataBuffer
Returns the byte offset of the data in the array.

Specified by:
getDataOffset in interface DataBuffer
Returns:
the byte offset of the data in the array.

getDataLength

public int getDataLength()
Description copied from interface: DataBuffer
Returns the byte length of the data in the array.

Specified by:
getDataLength in interface DataBuffer
Returns:
the byte length of the data in the array.

setDataFormation

public void setDataFormation(Object formation)
Description copied from interface: DataBuffer
Sets the formation associated with the data in this buffer.

Specified by:
setDataFormation in interface DataBuffer
Parameters:
formation - is Object to set.

getDataFormation

public Object getDataFormation()
Description copied from interface: DataBuffer
Returns the formation associated with the data in this buffer.

Specified by:
getDataFormation in interface DataBuffer
Returns:
formation Object.

clearDataFormation

public void clearDataFormation()
Description copied from interface: DataBuffer
Sets the formation associated with the data in this buffer to null.

Specified by:
clearDataFormation in interface DataBuffer

Berkeley DB
version 4.2.52

Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.