Top Description Fields Constructors Methods
org.apache.tools.zip

public abstract Class ZipUtil

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.Calendar, .Date, java.util.zip.CRC32

Utility class for handling DOS and Java time conversions.
Since
Ant 1.8.1

Field Summary

Modifier and TypeField and Description
private static final byte[]
DOS_TIME_MIN

Smallest date/time ZIP can handle.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static long

Returns:

the unsigned int as a long.
adjustToLong
(int
the value to treat as unsigned int.
i
)

Assumes a negative integer really is a positive integer that has wrapped around and re-creates the original value.

pack-priv static boolean

Returns:

boolean
canHandleEntryData
(ZipEntry entry)

Whether this library is able to read or write the given entry.

pack-priv static void
checkRequestedFeatures(ZipEntry ze)

Checks whether the entry requires features not (yet) supported by the library and throws an exception if it does.

pack-priv static byte[]

Returns:

byte[]
copy
(byte[]
byte[]
from
)

Create a copy of the given array - or return null if the argument is null.

public static long

Returns:

long
dosToJavaTime
(long
long
dosTime
)

Converts DOS time to Java time (number of milliseconds since epoch).

public static Date

Returns:

a Date instance corresponding to the given time.
fromDosTime
(ZipLong
contains the stored DOS time.
zipDosTime
)

Convert a DOS date/time field to a Date object.

private static String
getUnicodeStringIfOriginalMatches(AbstractUnicodeExtraField
AbstractUnicodeExtraField
f
,
byte[]
byte[]
orig
)

If the stored CRC matches the one of the given name, return the Unicode name of the given field.

pack-priv static void
setNameAndCommentFromExtraFields(ZipEntry
ZipEntry
ze
,
byte[]
byte[]
originalNameBytes
,
byte[]
byte[]
commentBytes
)

If the entry has Unicode*ExtraFields and the CRCs of the names/comments match those of the extra fields, transfer the known Unicode values from the extra field.

private static boolean

Returns:

true if the entry isn't encrypted at all
supportsEncryptionOf
(ZipEntry entry)

Whether this library supports the encryption used by the given entry.

private static boolean

Returns:

true if the compression method is STORED or DEFLATED
supportsMethodOf
(ZipEntry entry)

Whether this library supports the compression method used by the given entry.

public static ZipLong

Returns:

the date as a ZipLong
toDosTime
(Date
the Date to convert
time
)

Convert a Date object to a DOS date/time field.

public static byte[]

Returns:

the date as a byte array
toDosTime
(long
number of milliseconds since the epoch
t
)

Convert a Date object to a DOS date/time field.

public static void
toDosTime(long
number of milliseconds since the epoch
t
,
byte[]
the output buffer
buf
,
int
The offset within the output buffer of the first byte to be written. must be non-negative and no larger than buf.length-4
offset
)

Convert a Date object to a DOS date/time field.

pack-priv static void
toDosTime(Calendar c, long t, byte[] buf, int offset)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DOS_TIME_MINback to summary
private static final byte[] DOS_TIME_MIN

Smallest date/time ZIP can handle.

Constructor Detail

ZipUtilback to summary
public ZipUtil()

Method Detail

adjustToLongback to summary
public static long adjustToLong(int i)

Assumes a negative integer really is a positive integer that has wrapped around and re-creates the original value.

This methods is no longer used as of Apache Ant 1.9.0

Parameters
i:int

the value to treat as unsigned int.

Returns:long

the unsigned int as a long.

canHandleEntryDataback to summary
pack-priv static boolean canHandleEntryData(ZipEntry entry)

Whether this library is able to read or write the given entry.

Returns:boolean

boolean

checkRequestedFeaturesback to summary
pack-priv static void checkRequestedFeatures(ZipEntry ze) throws UnsupportedZipFeatureException

Checks whether the entry requires features not (yet) supported by the library and throws an exception if it does.

copyback to summary
pack-priv static byte[] copy(byte[] from)

Create a copy of the given array - or return null if the argument is null.

Parameters
from:byte[]

byte[]

Returns:byte[]

byte[]

dosToJavaTimeback to summary
public static long dosToJavaTime(long dosTime)

Converts DOS time to Java time (number of milliseconds since epoch).

Parameters
dosTime:long

long

Returns:long

long

fromDosTimeback to summary
public static Date fromDosTime(ZipLong zipDosTime)

Convert a DOS date/time field to a Date object.

Parameters
zipDosTime:ZipLong

contains the stored DOS time.

Returns:Date

a Date instance corresponding to the given time.

getUnicodeStringIfOriginalMatchesback to summary
private static String getUnicodeStringIfOriginalMatches(AbstractUnicodeExtraField f, byte[] orig)

If the stored CRC matches the one of the given name, return the Unicode name of the given field.

If the field is null or the CRCs don't match, return null instead.

Parameters
f:AbstractUnicodeExtraField

AbstractUnicodeExtraField

orig:byte[]

byte[]

setNameAndCommentFromExtraFieldsback to summary
pack-priv static void setNameAndCommentFromExtraFields(ZipEntry ze, byte[] originalNameBytes, byte[] commentBytes)

If the entry has Unicode*ExtraFields and the CRCs of the names/comments match those of the extra fields, transfer the known Unicode values from the extra field.

Parameters
ze:ZipEntry

ZipEntry

originalNameBytes:byte[]

byte[]

commentBytes:byte[]

byte[]

supportsEncryptionOfback to summary
private static boolean supportsEncryptionOf(ZipEntry entry)

Whether this library supports the encryption used by the given entry.

Returns:boolean

true if the entry isn't encrypted at all

supportsMethodOfback to summary
private static boolean supportsMethodOf(ZipEntry entry)

Whether this library supports the compression method used by the given entry.

Returns:boolean

true if the compression method is STORED or DEFLATED

toDosTimeback to summary
public static ZipLong toDosTime(Date time)

Convert a Date object to a DOS date/time field.

Parameters
time:Date

the Date to convert

Returns:ZipLong

the date as a ZipLong

toDosTimeback to summary
public static byte[] toDosTime(long t)

Convert a Date object to a DOS date/time field.

Stolen from InfoZip's fileio.c

Parameters
t:long

number of milliseconds since the epoch

Returns:byte[]

the date as a byte array

toDosTimeback to summary
public static void toDosTime(long t, byte[] buf, int offset)

Convert a Date object to a DOS date/time field.

Stolen from InfoZip's fileio.c

Parameters
t:long

number of milliseconds since the epoch

buf:byte[]

the output buffer

offset:int

The offset within the output buffer of the first byte to be written. must be non-negative and no larger than buf.length-4

toDosTimeback to summary
pack-priv static void toDosTime(Calendar c, long t, byte[] buf, int offset)