compressors
Class LZ77v01
java.lang.Object
compressors.LZ77v01
public class LZ77v01
- extends java.lang.Object
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LZ77v01
public LZ77v01()
LZ77v01
public LZ77v01(java.lang.String s)
encode
public java.util.ArrayList<Tuple> encode()
- Encodes string rawData, stores the encoded data in encodedData and returns encodedData
decode
public java.lang.String decode()
- Decodes encodedData into a String, stores the string in decodedData and returns the string.
The original message has been encoded into a collection of
Tuple objects where each object contains the following
information:
1. offset points backwards to the beginning of a
match relative to the current location. Has a
value of 0 if there is no match for the next
character.
2. stringLen specifies the length of the match or 0
if there is no match for the next character.
3. nextChar is the first non-matching character
following a match, or the next character if there
is no match.
It would not be particularly difficult at this point
to iterate on the collection and to produce a binary
stream containing these three values. For example,
depending on the values specified for searchWindowLen
and lookAheadWindowLen, the first two values listed above
could be encoded into the number of bits required to
contain the largest possible offset value and the
largest possible stringLen value. The character from the
Tuple object could be encoded into eight bits. Then,
the set of bits required to describe the Tuple could be
inserted into a stream of bits.
This demonstration program does not produce such a
compressed binary file.
getCompressionFactor
public double getCompressionFactor()
- Performs an analysis of the compression between rawData and encodedData, prints the results and returns the compression factor.
getRawData
public java.lang.String getRawData()
- Returns:
- the rawData
setRawData
public void setRawData(java.lang.String rawData)
- Parameters:
rawData
- the rawData to set
getEncodedData
public java.util.ArrayList<Tuple> getEncodedData()
- Returns:
- the encodedData
setEncodedData
public void setEncodedData(java.util.ArrayList<Tuple> encodedData)
- Parameters:
encodedData
- the encodedData to set
getSearchWindowLen
public int getSearchWindowLen()
- Returns:
- the searchWindowLen
setSearchWindowLen
public void setSearchWindowLen(int searchWindowLen)
- Parameters:
searchWindowLen
- the searchWindowLen to set
getLookAheadWindowLen
public int getLookAheadWindowLen()
- Returns:
- the lookAheadWindowLen
setLookAheadWindowLen
public void setLookAheadWindowLen(int lookAheadWindowLen)
- Parameters:
lookAheadWindowLen
- the lookAheadWindowLen to set
main
public static void main(java.lang.String[] args)