Methods Summary |
---|
org.apache.poi.hdgf.other_lzw.LZW$ByteArray | decodeOne(int code)
// Either "ABA" or null, w="AB"
ByteArray str = dict.strFromNum(code) ;
if (str==null) {
str = w.conc(w.getAt(0)) ;
dict.add(str) ;
} else
if (! w.isEmpty())
dict.add(w.conc(str.getAt(0))) ;
w = str ;
return w ;
|
public void | decompress(java.io.InputStream is, java.io.OutputStream os)
is = new BitInputStream(is) ;
ByteArray str ; // Next entry
int code ; // Next code to be read
while ((code=readCode(is))>=0) {
if (stopped)
break ;
str = decodeOne(code) ;
os.write(str.getBytes()) ;
}
|
int | encodeLast()
ByteArray nw = w ;
w = emptyBA ;
return dict.numFromStr(nw) ;
|
int | encodeOneChar(int n)
byte c = (byte) n ;
ByteArray nw = w.conc(c) ;
int code = dict.numFromStr(nw) ;
// if it exists then we continue to search for a longer string
if (code!=-1) {
w = nw ;
return -1 ;
} else {
dict.add(nw) ;
nw = w ;
w = new ByteArray(c) ;
return dict.numFromStr(nw) ;
}
|
int | readCode(java.io.InputStream is)
int num = 0 ;
for (int i=0;i<numOfBits;++i) {
int next = is.read() ;
if (next<0)
return -1 ;
num += next<<i ;
}
return num ;
|
public void | stop() stopped = true ;
|
void | writeCode(java.io.OutputStream os, int code)
for (int i=0;i<numOfBits;++i) {
os.write(code&1) ;
code /= 2 ;
}
|