|
SolarMetric Kodo JDO 2.5.8 generated on January 11 2004 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--serp.util.CompressedString
A CompressedString
holds on to a compressed form of
a String, as well as a Reference
that caches the uncompressed
version. The toString()
method will
transparently decompress the String if it has not been
cached. A CompressedString
is useful for maintaining
caches of very large Strings, such as a cache of the
complete contents of a set or text files. Note that decompressing
the Strings can be a very slow operation.
By default, a GZIPOutputStream
is used to compress the
String using gzip compression, which can achieve very high
compression ratios (between 50% and 95%). More information on
gzip can be found
in the RFC
description.
Constructor Summary | |
CompressedString(String str)
Construct a new CompressedString that holds
a compressed version of the specified String. |
|
CompressedString(String str,
boolean useWeakReference)
Construct a new CompressedString that holds
a compressed version of the specified String. |
Method Summary | |
void |
clearCache()
Clear out the contents of the String cache. |
int |
compareTo(Object other)
Compares the String forms. |
protected byte[] |
compressString(String str)
Compress the specified String into an array of bytes. |
(package private) Reference |
createReference(Object forObject)
Create a new reference for the specified object. |
boolean |
equals(Object other)
Two CompressedString |
int |
getCompressedSize()
Returns the size of the compressed bytes. |
int |
hashCode()
hashCode is calculated by summing up all the individual bytes. |
boolean |
isCompressed()
Returns true of the String cache has been lost, and only the compressed form is being held. |
String |
toString()
Return the raw String form. |
protected String |
uncompressString(byte[] compressed)
Uncompress the specified String from an array of bytes. |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public CompressedString(String str)
CompressedString
that holds
a compressed version of the specified String. By default,
the String will be cached using a WeakReference
.public CompressedString(String str, boolean useWeakReference)
CompressedString
that holds
a compressed version of the specified String. By default,
the String will be cached using a WeakReference
.str
- the String to compressuseWeakReference
- if true
,
then a WeakReference
will be used to cache the String. If false
, a
SoftReference
will be used.Method Detail |
public int compareTo(Object other)
compareTo
in interface Comparable
public boolean equals(Object other)
CompressedStrings are equal if they both
use the same reference type and all the compressed bytes
are the same.
- Overrides:
equals
in class Object
public int hashCode()
hashCode
in class Object
Reference createReference(Object forObject)
WeakReference
or SoftReference
,
depending on how the CompressedString
was created.public String toString()
toString
in class Object
public int getCompressedSize()
public boolean isCompressed()
public void clearCache()
protected byte[] compressString(String str)
GZIPOutputStream
in order
to use gzip compression. This method can be overridden
in order to use a different compression algorithm.IllegalStateException
- if comprssion problems occurprotected String uncompressString(byte[] compressed)
GZIPInputStream
in order
to use gzip compression. This method can be overridden
in order to use a different compression algorithm.IllegalStateException
- if decomprssion problems occur
|
SolarMetric Kodo JDO 2.5.8 generated on January 11 2004 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |