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

public final Class ZipLong

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Static Imports
org.apache.tools.zip.ZipConstants.BYTE_MASK, .ZipConstants.WORD

Utility class that represents a four byte integer with conversion rules for the big endian byte order of ZIP files.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final long
private static final int
public static final ZipLong
CFH_SIG

Central File Header Signature

public static final ZipLong
DD_SIG

Data Descriptor signature

public static final ZipLong
LFH_SIG

Local File Header Signature

private final long
pack-priv static final ZipLong
ZIP64_MAGIC

Value stored in size and similar fields if ZIP64 extensions are used.

Constructor Summary

AccessConstructor and Description
public
ZipLong(long
the long to store as a ZipLong
value
)

Create instance from a number.

public
ZipLong(byte[]
the bytes to store as a ZipLong
bytes
)

Create instance from bytes.

public
ZipLong(byte[]
the bytes to store as a ZipLong
bytes
,
int
the offset to start
offset
)

Create instance from the four bytes starting at offset.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public boolean

Returns:

true if the objects are equal
equals
(Object
an object to compare
o
)

Overrides java.lang.Object.equals.

Override to make two instances with same value equal.
public byte[]

Returns:

value as four bytes in big endian order
getBytes
()

Get value as four bytes in big endian byte order.

public static byte[]

Returns:

value as four bytes in big endian byte order
getBytes
(long
the value to convert
value
)

Get value as four bytes in big endian byte order.

public long

Returns:

value as a long
getValue
()

Get value as Java long.

public static long

Returns:

the corresponding Java long value
getValue
(byte[]
the array of bytes
bytes
,
int
the offset to start
offset
)

Helper method to get the value as a Java long from four bytes starting at given array offset

public static long

Returns:

the corresponding Java long value
getValue
(byte[]
the array of bytes
bytes
)

Helper method to get the value as a Java long from a four-byte array

public int

Returns:

the value stored in the ZipLong
hashCode
()

Overrides java.lang.Object.hashCode.

Override to make two instances with same value equal.
public static void
putLong(long
the Java long to convert to bytes
value
,
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
)

put the value as four bytes in big endian byte order.

public void
putLong(byte[] buf, int offset)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

BYTE_1back to summary
private static final int BYTE_1
BYTE_1_MASKback to summary
private static final int BYTE_1_MASK
BYTE_1_SHIFTback to summary
private static final int BYTE_1_SHIFT
BYTE_2back to summary
private static final int BYTE_2
BYTE_2_MASKback to summary
private static final int BYTE_2_MASK
BYTE_2_SHIFTback to summary
private static final int BYTE_2_SHIFT
BYTE_3back to summary
private static final int BYTE_3
BYTE_3_MASKback to summary
private static final long BYTE_3_MASK
BYTE_3_SHIFTback to summary
private static final int BYTE_3_SHIFT
CFH_SIGback to summary
public static final ZipLong CFH_SIG

Central File Header Signature

DD_SIGback to summary
public static final ZipLong DD_SIG

Data Descriptor signature

LFH_SIGback to summary
public static final ZipLong LFH_SIG

Local File Header Signature

valueback to summary
private final long value
ZIP64_MAGICback to summary
pack-priv static final ZipLong ZIP64_MAGIC

Value stored in size and similar fields if ZIP64 extensions are used.

Constructor Detail

ZipLongback to summary
public ZipLong(long value)

Create instance from a number.

Parameters
value:long

the long to store as a ZipLong

Since
1.1
ZipLongback to summary
public ZipLong(byte[] bytes)

Create instance from bytes.

Parameters
bytes:byte[]

the bytes to store as a ZipLong

Since
1.1
ZipLongback to summary
public ZipLong(byte[] bytes, int offset)

Create instance from the four bytes starting at offset.

Parameters
bytes:byte[]

the bytes to store as a ZipLong

offset:int

the offset to start

Since
1.1

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Override to make two instances with same value equal.

Parameters
o:Object

an object to compare

Returns:boolean

true if the objects are equal

Annotations
@Override
Since
1.1
getBytesback to summary
public byte[] getBytes()

Get value as four bytes in big endian byte order.

Returns:byte[]

value as four bytes in big endian order

Since
1.1
getBytesback to summary
public static byte[] getBytes(long value)

Get value as four bytes in big endian byte order.

Parameters
value:long

the value to convert

Returns:byte[]

value as four bytes in big endian byte order

getValueback to summary
public long getValue()

Get value as Java long.

Returns:long

value as a long

Since
1.1
getValueback to summary
public static long getValue(byte[] bytes, int offset)

Helper method to get the value as a Java long from four bytes starting at given array offset

Parameters
bytes:byte[]

the array of bytes

offset:int

the offset to start

Returns:long

the corresponding Java long value

getValueback to summary
public static long getValue(byte[] bytes)

Helper method to get the value as a Java long from a four-byte array

Parameters
bytes:byte[]

the array of bytes

Returns:long

the corresponding Java long value

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Override to make two instances with same value equal.

Returns:int

the value stored in the ZipLong

Annotations
@Override
Since
1.1
putLongback to summary
public static void putLong(long value, byte[] buf, int offset)

put the value as four bytes in big endian byte order.

Parameters
value:long

the Java long to convert to bytes

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

putLongback to summary
public void putLong(byte[] buf, int offset)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override