Class LZEncoder
java.lang.Object
org.graalvm.shadowed.org.tukaani.xz.lz.LZEncoder
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyUncompressed(OutputStream out, int backward, int len) intfillWindow(byte[] in, int off, int len) Copies new data into the LZEncoder's buffer.intgetAvail()Get the number of bytes available, including the current byte.intgetByte(int backward) Gets the byte from the given backward offset.intgetByte(int forward, int backward) Gets the byte from the given forward minus backward offset.static LZEncodergetInstance(int dictSize, int extraSizeBefore, int extraSizeAfter, int niceLen, int matchLenMax, int mf, int depthLimit, ArrayCache arrayCache) Creates a new LZEncoder.abstract MatchesRuns match finder for the next byte and returns the matches found.intgetMatchLen(int dist, int lenLimit) Get the length of a match at the given distance.intgetMatchLen(int forward, int dist, int lenLimit) Get the length of a match at the given distance and forward offset.static intgetMemoryUsage(int dictSize, int extraSizeBefore, int extraSizeAfter, int matchLenMax, int mf) Gets approximate memory usage of the LZEncoder base structure and the match finder as kibibytes.intgetPos()Gets the lowest four bits of the absolute offset of the current byte.booleanhasEnoughData(int alreadyReadLen) Tests if there is enough input available to let the caller encode at least one more byte.booleanReturns true if at least one byte has already been run through the match finder.voidputArraysToCache(ArrayCache arrayCache) voidMarks that there is no more input remaining.voidMarks that all the input needs to be made available in the encoded output.voidsetPresetDict(int dictSize, byte[] presetDict) Sets a preset dictionary.abstract voidskip(int len) Skips the given number of bytes in the match finder.booleanverifyMatches(Matches matches) Verifies that the matches returned by the match finder are valid.
-
Field Details
-
MF_HC4
public static final int MF_HC4- See Also:
-
MF_BT4
public static final int MF_BT4- See Also:
-
-
Method Details
-
getMemoryUsage
public static int getMemoryUsage(int dictSize, int extraSizeBefore, int extraSizeAfter, int matchLenMax, int mf) Gets approximate memory usage of the LZEncoder base structure and the match finder as kibibytes. -
getInstance
public static LZEncoder getInstance(int dictSize, int extraSizeBefore, int extraSizeAfter, int niceLen, int matchLenMax, int mf, int depthLimit, ArrayCache arrayCache) Creates a new LZEncoder.- Parameters:
dictSize- dictionary sizeextraSizeBefore- number of bytes to keep available in the history in addition to dictSizeextraSizeAfter- number of bytes that must be available after current position + matchLenMaxniceLen- if a match of at leastniceLenbytes is found, be happy with it and stop looking for longer matchesmatchLenMax- don't test for matches longer thanmatchLenMaxbytesmf- match finder IDdepthLimit- match finder search depth limit
-
putArraysToCache
-
setPresetDict
public void setPresetDict(int dictSize, byte[] presetDict) Sets a preset dictionary. If a preset dictionary is wanted, this function must be called immediately after creating the LZEncoder before any data has been encoded. -
fillWindow
public int fillWindow(byte[] in, int off, int len) Copies new data into the LZEncoder's buffer. -
isStarted
public boolean isStarted()Returns true if at least one byte has already been run through the match finder. -
setFlushing
public void setFlushing()Marks that all the input needs to be made available in the encoded output. -
setFinishing
public void setFinishing()Marks that there is no more input remaining. The read position can be advanced until the end of the data. -
hasEnoughData
public boolean hasEnoughData(int alreadyReadLen) Tests if there is enough input available to let the caller encode at least one more byte. -
copyUncompressed
- Throws:
IOException
-
getAvail
public int getAvail()Get the number of bytes available, including the current byte.Note that the result is undefined if
getMatchesorskiphasn't been called yet and no preset dictionary is being used. -
getPos
public int getPos()Gets the lowest four bits of the absolute offset of the current byte. Bits other than the lowest four are undefined. -
getByte
public int getByte(int backward) Gets the byte from the given backward offset.The current byte is at
0, the previous byte at1etc. To get a byte at zero-based distance, usegetByte(dist + 1).This function is equivalent to
getByte(0, backward). -
getByte
public int getByte(int forward, int backward) Gets the byte from the given forward minus backward offset. The forward offset is added to the current position. This lets one read bytes ahead of the current byte. -
getMatchLen
public int getMatchLen(int dist, int lenLimit) Get the length of a match at the given distance.- Parameters:
dist- zero-based distance of the match to testlenLimit- don't test for a match longer than this- Returns:
- length of the match; it is in the range [0, lenLimit]
-
getMatchLen
public int getMatchLen(int forward, int dist, int lenLimit) Get the length of a match at the given distance and forward offset.- Parameters:
forward- forward offsetdist- zero-based distance of the match to testlenLimit- don't test for a match longer than this- Returns:
- length of the match; it is in the range [0, lenLimit]
-
verifyMatches
Verifies that the matches returned by the match finder are valid. This is meant to be used in an assert statement. This is totally useless for actual encoding since match finder's results should naturally always be valid if it isn't broken.- Parameters:
matches- return value fromgetMatches- Returns:
- true if matches are valid, false if match finder is broken
-
getMatches
Runs match finder for the next byte and returns the matches found. -
skip
public abstract void skip(int len) Skips the given number of bytes in the match finder.
-