neustore.base
Class StringData

java.lang.Object
  extended by neustore.base.StringData
All Implemented Interfaces:
Data

public class StringData
extends java.lang.Object
implements Data

A class that stores a variable-length String. Note that to write a StringData to disk, the occupied size is four bytes larger than the String size, for we also store the size of the String.

Author:
Donghui Zhang <donghui@ccs.neu.edu>

Field Summary
protected  int maxStringLength
          maximum length of a String.
 java.lang.String string
          the stored String
 
Constructor Summary
StringData(int _maxStringLength, java.lang.String _string)
          The constructor takes as input the max length of a string.
 
Method Summary
 java.lang.Object clone()
          Creates a new copy of the object.
 int maxSize()
          Returns the maximum number of bytes this type of object may occupy.
 void read(java.io.DataInputStream in)
          Reads the object from an input stream.
 int size()
           
 void write(java.io.DataOutputStream out)
          Writes the object to an output stream.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxStringLength

protected int maxStringLength
maximum length of a String.


string

public java.lang.String string
the stored String

Constructor Detail

StringData

public StringData(int _maxStringLength,
                  java.lang.String _string)
The constructor takes as input the max length of a string. The maxSize of this object is this maxStringLength + 4.

Parameters:
_maxStringLength - max length of a string
Method Detail

clone

public java.lang.Object clone()
Description copied from interface: Data
Creates a new copy of the object.

Specified by:
clone in interface Data
Overrides:
clone in class java.lang.Object
Returns:
the new copy

size

public int size()
Specified by:
size in interface Data

maxSize

public int maxSize()
Description copied from interface: Data
Returns the maximum number of bytes this type of object may occupy. It is used to support variable-length data.

Specified by:
maxSize in interface Data
Returns:
maximum number of bytes

read

public void read(java.io.DataInputStream in)
          throws java.io.IOException
Description copied from interface: Data
Reads the object from an input stream.

Specified by:
read in interface Data
Parameters:
in - input stream
Throws:
java.io.IOException

write

public void write(java.io.DataOutputStream out)
           throws java.io.IOException
Description copied from interface: Data
Writes the object to an output stream.

Specified by:
write in interface Data
Parameters:
out - output stream
Throws:
java.io.IOException