public class CompressedString extends java.lang.Object implements java.lang.CharSequence, java.lang.Comparable<CompressedString>
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| Modifier and Type | Field and Description |
|---|---|
protected byte |
BITSPERCHAR
Number of bits per character
|
protected byte[] |
data
The string
|
protected int |
length
Number of characters in this CompressedString
|
protected int |
startBit
StartBit (for subsequence)
|
| Modifier | Constructor and Description |
|---|---|
protected |
CompressedString(byte[] data,
int startBit,
int length)
Duplicates a CompressedString (for subSequence)
|
|
CompressedString(java.lang.CharSequence s1)
Compresses a CharSequence with 6 bits
|
|
CompressedString(java.lang.CharSequence s1,
int bits)
Compresses a CharSequence
|
| Modifier and Type | Method and Description |
|---|---|
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
|
protected byte BITSPERCHAR
protected byte[] data
protected int startBit
protected int length
protected CompressedString(byte[] data,
int startBit,
int length)
public CompressedString(java.lang.CharSequence s1,
int bits)
public CompressedString(java.lang.CharSequence s1)
public int hashCode()
hashCode in class java.lang.Objectpublic int length()
length in interface java.lang.CharSequencepublic int size()
public int bits()
public char charAt(int index)
charAt in interface java.lang.CharSequencepublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic 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.CharSequencepublic java.lang.String toString()
toString in interface java.lang.CharSequencetoString in class java.lang.Objectpublic static void main(java.lang.String[] args)