All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class IS.hi.logir.cryptonite.Data

java.lang.Object
   |
   +----IS.hi.logir.cryptonite.Data

public class Data
extends Object
implements Serializable, Fingerprintable
The Data class is hods an ordered pair (n,buf), where buf is an array of bytes containing data in the first n bytes. This is used to return data from methods where we want to re-use arrays if possible and only re-allocate them if we need to them.

For example, the call Key.encrypt(buf, dest) takes a parameter of type Data in dest and if the encrypted array is no larger than dest.buf, it just writes the encrypted data to it. Otherwise dest.buf is enlarged. In either case, dest.n is the actual number of bytes of encrypted data.

Author:
Logi Ragnarsson (logir@hi.is)
See Also:
Key

Variable Index

 o buf
 o EMPTY
 o n

Constructor Index

 o Data()
Create a new empty Data object.
 o Data(byte[])
Create a new data object around the bytes in buffer.
 o Data(byte[], int)
Create a new data object around the first m bytes in buffer.
 o Data(int)
Create a new empty data object that can hold m bytes without being enlarged.

Method Index

 o enlarge(int)
Make sure that the object can hold at least m bytes.
 o enlargeSafe(int)
Make sure that the object can hold at least m bytes, without destroying the data it contains.
 o getFingerprint()
 o reallocate(int)
Reallocate the buffer and make it m bytest large.
 o resizeSafe(int)
Resize the buffer so it can hold as close to m bytes as possible without losing data.

Variables

 o n
 public int n
 o buf
 public byte buf[]
 o EMPTY
 private static byte EMPTY[]

Constructors

 o Data
 public Data()
Create a new empty Data object.

 o Data
 public Data(int m)
Create a new empty data object that can hold m bytes without being enlarged.

 o Data
 public Data(byte buffer[])
Create a new data object around the bytes in buffer. The buffer must contain at least m bytes.

 o Data
 public Data(byte buffer[],
             int m)
Create a new data object around the first m bytes in buffer. The buffer must contain at least m bytes.

Methods

 o enlarge
 public synchronized void enlarge(int m)
Make sure that the object can hold at least m bytes. This clears the object.

 o enlargeSafe
 public synchronized void enlargeSafe(int m)
Make sure that the object can hold at least m bytes, without destroying the data it contains.

 o reallocate
 public synchronized void reallocate(int m)
Reallocate the buffer and make it m bytest large. This clears the object.

 o resizeSafe
 public synchronized void resizeSafe(int m)
Resize the buffer so it can hold as close to m bytes as possible without losing data.

 o getFingerprint
 public Fingerprint getFingerprint()

All Packages  Class Hierarchy  This Package  Previous  Next  Index