Class ZipEntry
- java.lang.Object
-
- java.util.zip.ZipEntry
-
- org.apache.commons.compress.archivers.zip.ZipEntry
-
- All Implemented Interfaces:
java.lang.Cloneable
public class ZipEntry extends java.util.zip.ZipEntryExtension that adds better handling of extra fields and provides access to the internal and external file attributes.- Version:
- $Revision: 155439 $
- Author:
- Stefan Bodewig
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Objectc_lockReflectionHelper for JDK 1.1private static java.lang.reflect.Methodc_setCompressedSizeMethodHelper for JDK 1.1private static booleanc_triedToGetMethodHelper for JDK 1.1static intCENATTstatic intCENATXstatic intCENCOMstatic intCENCRCstatic intCENDSKstatic intCENEXTstatic intCENFLGstatic intCENHDRstatic intCENHOWstatic intCENLENstatic intCENNAMstatic intCENOFFstatic longCENSIGstatic intCENSIZstatic intCENTIMstatic intCENVEMstatic intCENVERstatic intENDCOMstatic intENDHDRstatic intENDOFFstatic longENDSIGstatic intENDSIZstatic intENDSUBstatic intENDTOTstatic intEXTCRCstatic intEXTHDRstatic intEXTLENstatic longEXTSIGstatic intEXTSIZstatic intLOCCRCstatic intLOCEXTstatic intLOCFLGstatic intLOCHDRstatic intLOCHOWstatic intLOCLENstatic intLOCNAMstatic longLOCSIGstatic intLOCSIZstatic intLOCTIMstatic intLOCVERprivate java.lang.Longm_compressedSizeHelper for JDK 1.1 <-> 1.2 incompatibility.private longm_externalAttributesprivate java.util.ArrayListm_extraFieldsprivate intm_internalAttributes
-
Constructor Summary
Constructors Constructor Description ZipEntry(java.lang.String name)Creates a new zip entry with the specified name.ZipEntry(java.util.zip.ZipEntry entry)Creates a new zip entry with fields taken from the specified zip entry.ZipEntry(ZipEntry entry)Creates a new zip entry with fields taken from the specified zip entry.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExtraField(ZipExtraField extraField)Adds an extra fields - replacing an already present extra field of the same type.private static voidcheckSCS()Try to get a handle to the setCompressedSize method.java.lang.Objectclone()Overwrite clonebyte[]getCentralDirectoryExtra()Retrieves the extra data for the central directory.longgetCompressedSize()Override to make this class work in JDK 1.1 like a 1.2 class.longgetExternalAttributes()Retrieves the external file attributes.ZipExtraField[]getExtraFields()Retrieves extra fields.intgetInternalAttributes()Retrieves the internal file attributes.byte[]getLocalFileDataExtra()Retrieves the extra data for the local file data.private static booleanhaveSetCompressedSize()Are we running JDK 1.2 or higher?private static voidperformSetCompressedSize(ZipEntry entry, long size)Invoke setCompressedSize via reflection.voidremoveExtraField(ZipShort type)Remove an extra fields.voidsetComprSize(long size)Make this class work in JDK 1.1 like a 1.2 class.voidsetExternalAttributes(long externalAttributes)Sets the external file attributes.protected voidsetExtra()Unfortunatelyjava.util.zip.ZipOutputStreamseems to access the extra data directly, so overriding getExtra doesn't help - we need to modify super's data directly.voidsetExtra(byte[] extra)Throws an Exception if extra data cannot be parsed into extra fields.voidsetExtraFields(ZipExtraField[] fields)Replaces all currently attached extra fields with the new array.voidsetInternalAttributes(int value)Sets the internal file attributes.-
Methods inherited from class java.util.zip.ZipEntry
getComment, getCrc, getCreationTime, getExtra, getLastAccessTime, getLastModifiedTime, getMethod, getName, getSize, getTime, getTimeLocal, hashCode, isDirectory, setComment, setCompressedSize, setCrc, setCreationTime, setLastAccessTime, setLastModifiedTime, setMethod, setSize, setTime, setTimeLocal, toString
-
-
-
-
Field Detail
-
c_setCompressedSizeMethod
private static java.lang.reflect.Method c_setCompressedSizeMethod
Helper for JDK 1.1- Since:
- 1.2
-
c_lockReflection
private static final java.lang.Object c_lockReflection
Helper for JDK 1.1- Since:
- 1.2
-
c_triedToGetMethod
private static boolean c_triedToGetMethod
Helper for JDK 1.1- Since:
- 1.2
-
m_extraFields
private final java.util.ArrayList m_extraFields
-
m_internalAttributes
private int m_internalAttributes
-
m_externalAttributes
private long m_externalAttributes
-
m_compressedSize
private java.lang.Long m_compressedSize
Helper for JDK 1.1 <-> 1.2 incompatibility.- Since:
- 1.2
-
LOCSIG
public static final long LOCSIG
- See Also:
- Constant Field Values
-
EXTSIG
public static final long EXTSIG
- See Also:
- Constant Field Values
-
CENSIG
public static final long CENSIG
- See Also:
- Constant Field Values
-
ENDSIG
public static final long ENDSIG
- See Also:
- Constant Field Values
-
LOCHDR
public static final int LOCHDR
- See Also:
- Constant Field Values
-
EXTHDR
public static final int EXTHDR
- See Also:
- Constant Field Values
-
CENHDR
public static final int CENHDR
- See Also:
- Constant Field Values
-
ENDHDR
public static final int ENDHDR
- See Also:
- Constant Field Values
-
LOCVER
public static final int LOCVER
- See Also:
- Constant Field Values
-
LOCFLG
public static final int LOCFLG
- See Also:
- Constant Field Values
-
LOCHOW
public static final int LOCHOW
- See Also:
- Constant Field Values
-
LOCTIM
public static final int LOCTIM
- See Also:
- Constant Field Values
-
LOCCRC
public static final int LOCCRC
- See Also:
- Constant Field Values
-
LOCSIZ
public static final int LOCSIZ
- See Also:
- Constant Field Values
-
LOCLEN
public static final int LOCLEN
- See Also:
- Constant Field Values
-
LOCNAM
public static final int LOCNAM
- See Also:
- Constant Field Values
-
LOCEXT
public static final int LOCEXT
- See Also:
- Constant Field Values
-
EXTCRC
public static final int EXTCRC
- See Also:
- Constant Field Values
-
EXTSIZ
public static final int EXTSIZ
- See Also:
- Constant Field Values
-
EXTLEN
public static final int EXTLEN
- See Also:
- Constant Field Values
-
CENVEM
public static final int CENVEM
- See Also:
- Constant Field Values
-
CENVER
public static final int CENVER
- See Also:
- Constant Field Values
-
CENFLG
public static final int CENFLG
- See Also:
- Constant Field Values
-
CENHOW
public static final int CENHOW
- See Also:
- Constant Field Values
-
CENTIM
public static final int CENTIM
- See Also:
- Constant Field Values
-
CENCRC
public static final int CENCRC
- See Also:
- Constant Field Values
-
CENSIZ
public static final int CENSIZ
- See Also:
- Constant Field Values
-
CENLEN
public static final int CENLEN
- See Also:
- Constant Field Values
-
CENNAM
public static final int CENNAM
- See Also:
- Constant Field Values
-
CENEXT
public static final int CENEXT
- See Also:
- Constant Field Values
-
CENCOM
public static final int CENCOM
- See Also:
- Constant Field Values
-
CENDSK
public static final int CENDSK
- See Also:
- Constant Field Values
-
CENATT
public static final int CENATT
- See Also:
- Constant Field Values
-
CENATX
public static final int CENATX
- See Also:
- Constant Field Values
-
CENOFF
public static final int CENOFF
- See Also:
- Constant Field Values
-
ENDSUB
public static final int ENDSUB
- See Also:
- Constant Field Values
-
ENDTOT
public static final int ENDTOT
- See Also:
- Constant Field Values
-
ENDSIZ
public static final int ENDSIZ
- See Also:
- Constant Field Values
-
ENDOFF
public static final int ENDOFF
- See Also:
- Constant Field Values
-
ENDCOM
public static final int ENDCOM
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ZipEntry
public ZipEntry(java.lang.String name)
Creates a new zip entry with the specified name.- Parameters:
name- the name of entry- Since:
- 1.1
-
ZipEntry
public ZipEntry(java.util.zip.ZipEntry entry) throws java.util.zip.ZipExceptionCreates a new zip entry with fields taken from the specified zip entry.- Parameters:
entry- the JDK ZipEntry to adapt- Throws:
java.util.zip.ZipException- if can not create entry- Since:
- 1.1
-
ZipEntry
public ZipEntry(ZipEntry entry) throws java.util.zip.ZipException
Creates a new zip entry with fields taken from the specified zip entry.- Parameters:
entry- the entry to adapt- Throws:
java.util.zip.ZipException- if can not create entry- Since:
- 1.1
-
-
Method Detail
-
checkSCS
private static void checkSCS()
Try to get a handle to the setCompressedSize method.- Since:
- 1.2
-
haveSetCompressedSize
private static boolean haveSetCompressedSize()
Are we running JDK 1.2 or higher?- Returns:
- Description of the Returned Value
- Since:
- 1.2
-
performSetCompressedSize
private static void performSetCompressedSize(ZipEntry entry, long size)
Invoke setCompressedSize via reflection.- Parameters:
entry- Description of Parametersize- Description of Parameter- Since:
- 1.2
-
setComprSize
public void setComprSize(long size)
Make this class work in JDK 1.1 like a 1.2 class.This either stores the size for later usage or invokes setCompressedSize via reflection.
- Parameters:
size- The new ComprSize value- Since:
- 1.2
-
setExternalAttributes
public void setExternalAttributes(long externalAttributes)
Sets the external file attributes.- Parameters:
externalAttributes- The new ExternalAttributes value- Since:
- 1.1
-
setExtra
public void setExtra(byte[] extra) throws java.lang.RuntimeExceptionThrows an Exception if extra data cannot be parsed into extra fields.- Overrides:
setExtrain classjava.util.zip.ZipEntry- Parameters:
extra- The new Extra value- Throws:
java.lang.RuntimeException- if fail to set extra data- Since:
- 1.1
-
setExtraFields
public void setExtraFields(ZipExtraField[] fields)
Replaces all currently attached extra fields with the new array.- Parameters:
fields- The new ExtraFields value- Since:
- 1.1
-
setInternalAttributes
public void setInternalAttributes(int value)
Sets the internal file attributes.- Parameters:
value- The new InternalAttributes value- Since:
- 1.1
-
getCentralDirectoryExtra
public byte[] getCentralDirectoryExtra()
Retrieves the extra data for the central directory.- Returns:
- The CentralDirectoryExtra value
- Since:
- 1.1
-
getCompressedSize
public long getCompressedSize()
Override to make this class work in JDK 1.1 like a 1.2 class.- Overrides:
getCompressedSizein classjava.util.zip.ZipEntry- Returns:
- The CompressedSize value
- Since:
- 1.2
-
getExternalAttributes
public long getExternalAttributes()
Retrieves the external file attributes.- Returns:
- The ExternalAttributes value
- Since:
- 1.1
-
getExtraFields
public ZipExtraField[] getExtraFields()
Retrieves extra fields.- Returns:
- The ExtraFields value
- Since:
- 1.1
-
getInternalAttributes
public int getInternalAttributes()
Retrieves the internal file attributes.- Returns:
- The InternalAttributes value
- Since:
- 1.1
-
getLocalFileDataExtra
public byte[] getLocalFileDataExtra()
Retrieves the extra data for the local file data.- Returns:
- The LocalFileDataExtra value
- Since:
- 1.1
-
addExtraField
public void addExtraField(ZipExtraField extraField)
Adds an extra fields - replacing an already present extra field of the same type.- Parameters:
extraField- The feature to be added to the ExtraField attribute- Since:
- 1.1
-
clone
public java.lang.Object clone()
Overwrite clone- Overrides:
clonein classjava.util.zip.ZipEntry- Returns:
- Description of the Returned Value
- Since:
- 1.1
-
removeExtraField
public void removeExtraField(ZipShort type)
Remove an extra fields.- Parameters:
type- Description of Parameter- Since:
- 1.1
-
setExtra
protected void setExtra()
Unfortunatelyjava.util.zip.ZipOutputStreamseems to access the extra data directly, so overriding getExtra doesn't help - we need to modify super's data directly.- Since:
- 1.1
-
-