org.makumba
Class Text

java.lang.Object
  extended by org.makumba.Text

public class Text
extends Object

A makumba text, a byte array that can be converted to String when needed. When texts get big, they are swapped on disk. Text swapping is logged (see Logger, MakumbaSystem.setLoggingRoot(java.lang.String) in the logger "abstr.longContent" with Level.FINE logging level.


Field Summary
static int FILE_LIMIT
           
 
Constructor Summary
Text(byte[] b)
          make a Text from the given byte array.
Text(byte[] b, int start, int length)
          make a Text from the given byte array.
Text(InputStream is)
          make a Text by reading the input stream.
Text(InputStream is, int length)
          make a Text from the given input stream, with the given length The content in the input stream must match the length.
Text(String s)
          make a Text from the String.
 
Method Summary
 boolean compare(InputStream is)
          compare the content to the content of a given stream, and closes the stream
 boolean equals(Object other)
          Indicates whether the other object is "equal to" this Text.
 String getString()
          gets this Text as a String, which is potentially harmful for memory
static Text getText(Object value)
          convenience method for making a text out of another Text, InputStream, String, or byte[]
 int length()
           
 InputStream toBinaryStream()
          Read the text content as a binary stream.
 String toShortString(int length)
           
 String toString()
          converts the text content to a string
 void writeTo(OutputStream o)
          write content to the given output stream
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FILE_LIMIT

public static int FILE_LIMIT
Constructor Detail

Text

public Text(InputStream is,
            int length)
make a Text from the given input stream, with the given length The content in the input stream must match the length. No diskswap will be attempted. If you wish for the info to be swapped to disk, use the constructor Text(InputStream)


Text

public Text(InputStream is)
make a Text by reading the input stream. If there is a lot of data, it will be swapped to disk


Text

public Text(String s)
make a Text from the String. If there is a lot of data, it will be swapped to disk


Text

public Text(byte[] b)
make a Text from the given byte array. If there is a lot of data, it will be swapped to disk


Text

public Text(byte[] b,
            int start,
            int length)
make a Text from the given byte array. If there is a lot of data, it will be swapped to disk

Method Detail

toBinaryStream

public InputStream toBinaryStream()
Read the text content as a binary stream. Recommended for long content


length

public int length()

getText

public static Text getText(Object value)
convenience method for making a text out of another Text, InputStream, String, or byte[]


toString

public String toString()
converts the text content to a string

Overrides:
toString in class Object

toShortString

public String toShortString(int length)

writeTo

public void writeTo(OutputStream o)
             throws IOException
write content to the given output stream

Throws:
IOException

compare

public boolean compare(InputStream is)
                throws IOException
compare the content to the content of a given stream, and closes the stream

Throws:
IOException

equals

public boolean equals(Object other)
Indicates whether the other object is "equal to" this Text.

Overrides:
equals in class Object

getString

public String getString()
gets this Text as a String, which is potentially harmful for memory