Class MyLzwCompressor
- java.lang.Object
-
- org.apache.commons.imaging.common.mylzw.MyLzwCompressor
-
public class MyLzwCompressor extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
MyLzwCompressor.ByteArray
static interface
MyLzwCompressor.Listener
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteOrder
byteOrder
private int
clearCode
private int
codes
private int
codeSize
private boolean
earlyLimit
private int
eoiCode
private int
initialCodeSize
private MyLzwCompressor.Listener
listener
private java.util.Map<MyLzwCompressor.ByteArray,java.lang.Integer>
map
-
Constructor Summary
Constructors Constructor Description MyLzwCompressor(int initialCodeSize, java.nio.ByteOrder byteOrder, boolean earlyLimit)
MyLzwCompressor(int initialCodeSize, java.nio.ByteOrder byteOrder, boolean earlyLimit, MyLzwCompressor.Listener listener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
addTableEntry(MyBitOutputStream bos, byte[] bytes, int start, int length)
private boolean
addTableEntry(MyBitOutputStream bos, MyLzwCompressor.ByteArray key)
private MyLzwCompressor.ByteArray
arrayToKey(byte b)
private MyLzwCompressor.ByteArray
arrayToKey(byte[] bytes, int start, int length)
private void
clearTable()
private int
codeFromString(byte[] bytes, int start, int length)
byte[]
compress(byte[] bytes)
private void
incrementCodeSize()
private void
initializeStringTable()
private boolean
isInTable(byte[] bytes, int start, int length)
private void
writeClearCode(MyBitOutputStream bos)
private void
writeCode(MyBitOutputStream bos, int code)
private void
writeDataCode(MyBitOutputStream bos, int code)
private void
writeEoiCode(MyBitOutputStream bos)
-
-
-
Field Detail
-
codeSize
private int codeSize
-
initialCodeSize
private final int initialCodeSize
-
codes
private int codes
-
byteOrder
private final java.nio.ByteOrder byteOrder
-
earlyLimit
private final boolean earlyLimit
-
clearCode
private final int clearCode
-
eoiCode
private final int eoiCode
-
listener
private final MyLzwCompressor.Listener listener
-
map
private final java.util.Map<MyLzwCompressor.ByteArray,java.lang.Integer> map
-
-
Constructor Detail
-
MyLzwCompressor
public MyLzwCompressor(int initialCodeSize, java.nio.ByteOrder byteOrder, boolean earlyLimit)
-
MyLzwCompressor
public MyLzwCompressor(int initialCodeSize, java.nio.ByteOrder byteOrder, boolean earlyLimit, MyLzwCompressor.Listener listener)
-
-
Method Detail
-
initializeStringTable
private void initializeStringTable()
-
clearTable
private void clearTable()
-
incrementCodeSize
private void incrementCodeSize()
-
arrayToKey
private MyLzwCompressor.ByteArray arrayToKey(byte b)
-
arrayToKey
private MyLzwCompressor.ByteArray arrayToKey(byte[] bytes, int start, int length)
-
writeDataCode
private void writeDataCode(MyBitOutputStream bos, int code) throws java.io.IOException
- Throws:
java.io.IOException
-
writeClearCode
private void writeClearCode(MyBitOutputStream bos) throws java.io.IOException
- Throws:
java.io.IOException
-
writeEoiCode
private void writeEoiCode(MyBitOutputStream bos) throws java.io.IOException
- Throws:
java.io.IOException
-
writeCode
private void writeCode(MyBitOutputStream bos, int code) throws java.io.IOException
- Throws:
java.io.IOException
-
isInTable
private boolean isInTable(byte[] bytes, int start, int length)
-
codeFromString
private int codeFromString(byte[] bytes, int start, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
addTableEntry
private boolean addTableEntry(MyBitOutputStream bos, byte[] bytes, int start, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
addTableEntry
private boolean addTableEntry(MyBitOutputStream bos, MyLzwCompressor.ByteArray key) throws java.io.IOException
- Throws:
java.io.IOException
-
compress
public byte[] compress(byte[] bytes) throws java.io.IOException
- Throws:
java.io.IOException
-
-