Package org.apache.commons.imaging.mylzw
Class MyLzwCompressor
- java.lang.Object
-
- org.apache.commons.imaging.mylzw.MyLzwCompressor
-
public class MyLzwCompressor extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classMyLzwCompressor.ByteArraystatic interfaceMyLzwCompressor.Listener
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteOrderbyteOrderprivate intclearCodeprivate intcodesprivate intcodeSizeprivate booleanearlyLimitprivate inteoiCodeprivate intinitialCodeSizeprivate MyLzwCompressor.Listenerlistenerprivate 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 booleanaddTableEntry(MyBitOutputStream bos, byte[] bytes, int start, int length)private booleanaddTableEntry(MyBitOutputStream bos, MyLzwCompressor.ByteArray key)private MyLzwCompressor.ByteArrayarrayToKey(byte b)private MyLzwCompressor.ByteArrayarrayToKey(byte[] bytes, int start, int length)private voidclearTable()private intcodeFromString(byte[] bytes, int start, int length)byte[]compress(byte[] bytes)private voidincrementCodeSize()private voidinitializeStringTable()private booleanisInTable(byte[] bytes, int start, int length)private voidwriteClearCode(MyBitOutputStream bos)private voidwriteCode(MyBitOutputStream bos, int code)private voidwriteDataCode(MyBitOutputStream bos, int code)private voidwriteEoiCode(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
-
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
-
arrayToKey
private MyLzwCompressor.ByteArray arrayToKey(byte b)
-
arrayToKey
private MyLzwCompressor.ByteArray arrayToKey(byte[] bytes, int start, int length)
-
clearTable
private void clearTable()
-
codeFromString
private int codeFromString(byte[] bytes, int start, int length) throws ImagingException- Throws:
ImagingException
-
compress
public byte[] compress(byte[] bytes) throws java.io.IOException- Throws:
java.io.IOException
-
incrementCodeSize
private void incrementCodeSize()
-
initializeStringTable
private void initializeStringTable()
-
isInTable
private boolean isInTable(byte[] bytes, int start, int length)
-
writeClearCode
private void writeClearCode(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
-
writeDataCode
private void writeDataCode(MyBitOutputStream bos, int code) throws java.io.IOException
- Throws:
java.io.IOException
-
writeEoiCode
private void writeEoiCode(MyBitOutputStream bos) throws java.io.IOException
- Throws:
java.io.IOException
-
-