Package org.dict.zip
Class DictZipHeader
- java.lang.Object
-
- org.dict.zip.DictZipHeader
-
public class DictZipHeader extends Object
DictZip header structure and handler.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DictZipHeader.CompressionLevel
Compression levels.static class
DictZipHeader.OperatingSystem
Operating systems.
-
Field Summary
Fields Modifier and Type Field Description protected int[]
chunks
Each chunk size.
-
Constructor Summary
Constructors Constructor Description DictZipHeader(long dataSize, int bufferSize)
Initialize DictZip header from data and buffer size.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getChunkCount()
Return chunk count.int
getChunkLength()
Return chunk length.DictZipHeader.CompressionLevel
getExtraFlag()
Get extra flag.String
getFilename()
Return filename set to header.BitSet
getGzipFlag()
Get gzip flag as bitset.int
getHeaderLength()
Get header length.DictZipHeader.OperatingSystem
getHeaderOS()
Get OS field.long
getMemberLength()
Get member length.long
getMtime()
Return modification date/time in second from epoch.int
getOffset(long start)
Offset getter.long
getPosition(long start)
Return dictionary position.String
getType()
Return zip type, whether gzip or dzip.static DictZipHeader
readHeader(InputStream is, CRC32 crc)
Read dictzip header from file.static DictZipHeader
readHeader(String s)
Read dictzip header from file.void
setComment(String comment)
Set comment field.void
setExtraFlag(DictZipHeader.CompressionLevel flag)
Set extra flag.void
setFilename(String filename)
Set filename field.void
setHeaderCRC(boolean val)
Set Header CRC flag.void
setHeaderOS(DictZipHeader.OperatingSystem os)
Set OS field of header.void
setMtime(long mtime)
Set mtime field.String
toString()
static void
writeHeader(DictZipHeader h, OutputStream out)
Writes GZIP member header.
-
-
-
Method Detail
-
readHeader
public static DictZipHeader readHeader(String s) throws IOException
Read dictzip header from file.- Parameters:
s
- Filename- Returns:
- DictZipHeader object.
- Throws:
IOException
- when error in file read.
-
readHeader
public static DictZipHeader readHeader(InputStream is, CRC32 crc) throws IOException
Read dictzip header from file.- Parameters:
is
- input stream for retrieve header.crc
- CRC32 value for check.- Returns:
- dictzip header object.
- Throws:
IOException
- when error in file read.
-
writeHeader
public static void writeHeader(DictZipHeader h, OutputStream out) throws IOException
Writes GZIP member header.- Parameters:
h
- DictZipHeader header values.out
- output stream to write.- Throws:
IOException
- when error in file output.
-
getOffset
public final int getOffset(long start) throws IllegalArgumentException
Offset getter.- Parameters:
start
- total offset bytes.- Returns:
- offset in the chunk.
- Throws:
IllegalArgumentException
- when index is out of boundary.
-
getPosition
public final long getPosition(long start) throws IllegalArgumentException
Return dictionary position.- Parameters:
start
- total offset bytes.- Returns:
- chunk position.
- Throws:
IllegalArgumentException
- when index is out of boundary.
-
setHeaderCRC
public void setHeaderCRC(boolean val)
Set Header CRC flag.- Parameters:
val
- true when set header CRC.
-
getGzipFlag
public BitSet getGzipFlag()
Get gzip flag as bitset.- Returns:
- flag as BitSet value.
-
getType
public final String getType()
Return zip type, whether gzip or dzip.- Returns:
- type name.
-
getChunkLength
public int getChunkLength()
Return chunk length.- Returns:
- length in int.
-
getChunkCount
public int getChunkCount()
Return chunk count.- Returns:
- int number.
-
getMtime
public long getMtime()
Return modification date/time in second from epoch.- Returns:
- long second from epoch.
-
getFilename
public String getFilename()
Return filename set to header.- Returns:
- filename set to header.
-
setHeaderOS
public void setHeaderOS(DictZipHeader.OperatingSystem os)
Set OS field of header.- Parameters:
os
- Operating System
-
getHeaderOS
public DictZipHeader.OperatingSystem getHeaderOS()
Get OS field.- Returns:
- OS field value.
-
setExtraFlag
public void setExtraFlag(DictZipHeader.CompressionLevel flag)
Set extra flag.- Parameters:
flag
- compression level.
-
getExtraFlag
public DictZipHeader.CompressionLevel getExtraFlag()
Get extra flag.- Returns:
- flag compression level.
-
setMtime
public void setMtime(long mtime)
Set mtime field.- Parameters:
mtime
- modification time.
-
setFilename
public void setFilename(String filename)
Set filename field.filename should be in ISO-8859-1 charset.
- Parameters:
filename
- name to set.
-
setComment
public void setComment(String comment)
Set comment field.comment should be in ISO-8859-1 charset.
- Parameters:
comment
- comment string.
-
getMemberLength
public long getMemberLength()
Get member length.- Returns:
- gzip member length
-
getHeaderLength
public int getHeaderLength()
Get header length.- Returns:
- header length
-
-