|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javatools.datatypes.CompressedString
public class CompressedString
This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools). It is licensed under the Creative Commons Attribution License (see http://creativecommons.org/licenses/by/3.0) by the YAGO-NAGA team (see http://mpii.de/yago-naga). This class represents an equivalence class of Strings. The equivalence class stores one prototype String, but compresses the String with 7, 6 or less bits per character (the String-class uses 16). This makes the CompressedString less memory consuming than a normal String, but possibly the original String cannot be reconstructed. The less bits you use, the less space you will consume, the less likely it will be that you can reconstruct the original String and the larger the equivalence class will be. Example:
System.out.println(new CompressedString("How are you?",7)); System.out.println(new CompressedString("How are you?",6)); System.out.println(new CompressedString("How are you?",5)); System.out.println(new CompressedString("How are you?",4)); System.out.println(new CompressedString("How are you?",3)); --> How are you? HOW ARE YOU? HOW ARE YOU? HOW@ARE@YOU HOG@ABE@IOEO
Constructor Summary | |
---|---|
CompressedString(java.lang.CharSequence s1)
Compresses a CharSequence with 6 bits |
|
CompressedString(java.lang.CharSequence s1,
int bits)
Compresses a CharSequence |
Method Summary | |
---|---|
int |
bits()
Returns the bits per character |
char |
charAt(int index)
Returns the character at position index |
int |
compareTo(java.lang.CharSequence s0)
1 if this CompressedString is lexically larger than the CompressedString of the argument, else -1 or 0 |
int |
compareTo(CompressedString s)
1 if this CompressedString is lexically larger than the the argument, else -1 or 0 |
boolean |
equals(java.lang.Object o)
Tells whether the argument (any CharSequence) is in the equivalence class of this CompressedString |
int |
hashCode()
Returns a hash-code |
int |
length()
Returns the number of characters in this CompressedString |
static void |
main(java.lang.String[] args)
Test routine |
java.lang.CharSequence |
normalize(java.lang.CharSequence s)
Normalizes (see Char.java) and upcases a CharSequence if necessary |
int |
size()
Returns the bytes used by this CompressedString |
java.lang.CharSequence |
subSequence(int start,
int end)
Returns a subsequence of this CompressedString (without duplicating the data) |
java.lang.String |
toString()
Tries to reconstruct the original String |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CompressedString(java.lang.CharSequence s1, int bits)
public CompressedString(java.lang.CharSequence s1)
Method Detail |
---|
public int hashCode()
hashCode
in class java.lang.Object
public int length()
length
in interface java.lang.CharSequence
public int size()
public int bits()
public char charAt(int index)
charAt
in interface java.lang.CharSequence
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.CharSequence normalize(java.lang.CharSequence s)
public int compareTo(java.lang.CharSequence s0)
public int compareTo(CompressedString s)
compareTo
in interface java.lang.Comparable<CompressedString>
public java.lang.CharSequence subSequence(int start, int end)
subSequence
in interface java.lang.CharSequence
public java.lang.String toString()
toString
in interface java.lang.CharSequence
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |