Top Description Fields Constructors Methods
org.apache.commons.compress.archivers.zip

public final Class ZipLong

extends Object
implements Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable
Static Imports
org.apache.commons.compress.archivers.zip.ZipConstants.WORD

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

Field Summary

Modifier and TypeField and Description
public static final ZipLong
AED_SIG

Archive extra data record signature.

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 static final long
public static final ZipLong
SINGLE_SEGMENT_SPLIT_MARKER

Marks ZIP archives that were supposed to be split or spanned but only needed a single segment in then end (so are actually neither split nor spanned).

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(final byte[]
the bytes to store as a ZipLong
bytes
)

Constructs a new instance from bytes.

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

Creates instance from the four bytes starting at offset.

public
ZipLong(final int
the int to store as a ZipLong
value
)

create instance from a Java int.

public
ZipLong(final long
the long to store as a ZipLong
value
)

Creates instance from a number.

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
(final Object
an object to compare
o
)

Overrides java.lang.Object.equals.

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

Returns:

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

Gets value as four bytes in big-endian byte order.

public byte[]

Returns:

value as four bytes in big-endian order
getBytes
()

Gets value as four bytes in big-endian byte order.

public int

Returns:

value as int
getIntValue
()

Gets value as a (signed) Java int

public static long

Returns:

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

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

public static long

Returns:

the corresponding Java long value
getValue
(final byte[]
the array of bytes
bytes
,
final 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 long

Returns:

value as a long
getValue
()

Gets value as Java long.

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(final long
the Java long to convert to bytes
value
,
final byte[]
the output buffer
buf
,
final 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(final byte[] buf, final 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

AED_SIGback to summary
public static final ZipLong AED_SIG

Archive extra data record signature.

Since
1.5
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.

Actually, PKWARE uses this as marker for split/spanned archives and other archivers have started to use it as Data Descriptor signature (as well).

Since
1.1
LFH_SIGback to summary
public static final ZipLong LFH_SIG

Local File Header Signature

serialVersionUIDback to summary
private static final long serialVersionUID
SINGLE_SEGMENT_SPLIT_MARKERback to summary
public static final ZipLong SINGLE_SEGMENT_SPLIT_MARKER

Marks ZIP archives that were supposed to be split or spanned but only needed a single segment in then end (so are actually neither split nor spanned).

This is the "PK00" prefix found in some archives.

Since
1.5
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.

Since
1.3

Constructor Detail

ZipLongback to summary
public ZipLong(final byte[] bytes)

Constructs a new instance from bytes.

Parameters
bytes:byte[]

the bytes to store as a ZipLong

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

Creates instance from the four bytes starting at offset.

Parameters
bytes:byte[]

the bytes to store as a ZipLong

offset:int

the offset to start

ZipLongback to summary
public ZipLong(final int value)

create instance from a Java int.

Parameters
value:int

the int to store as a ZipLong

Since
1.15
ZipLongback to summary
public ZipLong(final long value)

Creates instance from a number.

Parameters
value:long

the long to store as a ZipLong

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(final 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
getBytesback to summary
public static byte[] getBytes(final long value)

Gets 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

getBytesback to summary
public byte[] getBytes()

Gets value as four bytes in big-endian byte order.

Returns:byte[]

value as four bytes in big-endian order

getIntValueback to summary
public int getIntValue()

Gets value as a (signed) Java int

Returns:int

value as int

Since
1.15
getValueback to summary
public static long getValue(final 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

getValueback to summary
public static long getValue(final byte[] bytes, final 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 long getValue()

Gets value as Java long.

Returns:long

value as a long

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
putLongback to summary
public static void putLong(final long value, final byte[] buf, final 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(final byte[] buf, final 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