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

public final Class ZipShort

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

Utility class that represents a two 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 final int

Constructor Summary

AccessConstructor and Description
public
ZipShort(int
the int to store as a ZipShort
value
)

Create instance from a number.

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

Create instance from bytes.

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

Create instance from the two 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:

the value as a a two byte array in big endian byte order
getBytes
()

Get value as two bytes in big endian byte order.

public static byte[]

Returns:

the converted int as a byte array in big endian byte order
getBytes
(int
the Java int to convert to bytes
value
)

Get value as two bytes in big endian byte order.

public int

Returns:

value as a Java int
getValue
()

Get value as Java int.

public static int

Returns:

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

Helper method to get the value as a java int from two bytes starting at given array offset

public static int

Returns:

the corresponding java int value
getValue
(byte[]
the array of bytes
bytes
)

Helper method to get the value as a java int from a two-byte array

public int

Returns:

the value stored in the ZipShort
hashCode
()

Overrides java.lang.Object.hashCode.

Override to make two instances with same value equal.
public static void
putShort(int
the Java int 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-2
offset
)

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

public String
toString()

Overrides java.lang.Object.toString.

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

Field Detail

BYTE_1_MASKback to summary
private static final int BYTE_1_MASK
BYTE_1_SHIFTback to summary
private static final int BYTE_1_SHIFT
valueback to summary
private final int value

Constructor Detail

ZipShortback to summary
public ZipShort(int value)

Create instance from a number.

Parameters
value:int

the int to store as a ZipShort

Since
1.1
ZipShortback to summary
public ZipShort(byte[] bytes)

Create instance from bytes.

Parameters
bytes:byte[]

the bytes to store as a ZipShort

Since
1.1
ZipShortback to summary
public ZipShort(byte[] bytes, int offset)

Create instance from the two bytes starting at offset.

Parameters
bytes:byte[]

the bytes to store as a ZipShort

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 two bytes in big endian byte order.

Returns:byte[]

the value as a a two byte array in big endian byte order

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

Get value as two bytes in big endian byte order.

Parameters
value:int

the Java int to convert to bytes

Returns:byte[]

the converted int as a byte array in big endian byte order

getValueback to summary
public int getValue()

Get value as Java int.

Returns:int

value as a Java int

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

Helper method to get the value as a java int from two bytes starting at given array offset

Parameters
bytes:byte[]

the array of bytes

offset:int

the offset to start

Returns:int

the corresponding java int value

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

Helper method to get the value as a java int from a two-byte array

Parameters
bytes:byte[]

the array of bytes

Returns:int

the corresponding java int 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 ZipShort

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

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

Parameters
value:int

the Java int 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-2

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