- java.lang.Object
-
- com.ibm.jzos.fields.BinaryAsIntField
-
- All Implemented Interfaces:
Field
,IntAccessor
- Direct Known Subclasses:
BinarySignedIntField
,BinaryUnsignedIntField
public class BinaryAsIntField extends java.lang.Object implements IntAccessor
A 1-4 byte binaryField
with int accessors.- Since:
- 2.1.0
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_FIELD_WIDTH
static int
MAX_FIELD_WIDTH
static int
SIGNED_MAX_LEN1_VAL
static int
SIGNED_MAX_LEN2_VAL
static int
SIGNED_MAX_LEN3_VAL
static int
SIGNED_MAX_LEN4_VAL
static int
SIGNED_MIN_LEN1_VAL
static int
SIGNED_MIN_LEN2_VAL
static int
SIGNED_MIN_LEN3_VAL
static int
SIGNED_MIN_LEN4_VAL
static int
UNSIGNED_MAX_LEN1_VAL
static int
UNSIGNED_MAX_LEN2_VAL
static int
UNSIGNED_MAX_LEN3_VAL
static int
UNSIGNED_MAX_LEN4_VAL
-
Constructor Summary
Constructors Constructor Description BinaryAsIntField(int offset)
Construct a signed instance with a field width = DEFAULT_FIELD_WIDTH = 4.BinaryAsIntField(int offset, int length)
Construct a signed instance with a given offset and length.BinaryAsIntField(int offset, int length, boolean signed)
Construct an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(java.lang.Integer anInteger, int anInt)
Compare an Integer, possibly null, with an int for equality.int
getByteLength()
Answer the length of the field described by the receiverint
getInt(byte[] buffer)
Answer an int from the given byte array buffer, at the offset of this field.int
getInt(byte[] buffer, int bufOffset)
Answer an int from the given byte array buffer, at the bufOffset + offset of this field.int
getOffset()
Answer the offset of this field into some array of bytesboolean
isSigned()
Answer true if this field described a signed binary int, false if unsigned.void
putInt(int value, byte[] buffer)
Put a signed int into the given byte array buffer, at the offset of this field.void
putInt(int value, byte[] buffer, int bufOffset)
Put a signed int into thegiven byte array buffer, at the bufOffset + offset of this field.void
setOffset(int offset)
void
setSigned(boolean signed)
Deprecated.Change the sign of the field.
-
-
-
Field Detail
-
MAX_FIELD_WIDTH
public static final int MAX_FIELD_WIDTH
- See Also:
- Constant Field Values
-
DEFAULT_FIELD_WIDTH
public static final int DEFAULT_FIELD_WIDTH
- See Also:
- Constant Field Values
-
SIGNED_MIN_LEN1_VAL
public static final int SIGNED_MIN_LEN1_VAL
- See Also:
- Constant Field Values
-
SIGNED_MAX_LEN1_VAL
public static final int SIGNED_MAX_LEN1_VAL
- See Also:
- Constant Field Values
-
SIGNED_MIN_LEN2_VAL
public static final int SIGNED_MIN_LEN2_VAL
- See Also:
- Constant Field Values
-
SIGNED_MAX_LEN2_VAL
public static final int SIGNED_MAX_LEN2_VAL
- See Also:
- Constant Field Values
-
SIGNED_MIN_LEN3_VAL
public static final int SIGNED_MIN_LEN3_VAL
- See Also:
- Constant Field Values
-
SIGNED_MAX_LEN3_VAL
public static final int SIGNED_MAX_LEN3_VAL
- See Also:
- Constant Field Values
-
SIGNED_MIN_LEN4_VAL
public static final int SIGNED_MIN_LEN4_VAL
- See Also:
- Constant Field Values
-
SIGNED_MAX_LEN4_VAL
public static final int SIGNED_MAX_LEN4_VAL
- See Also:
- Constant Field Values
-
UNSIGNED_MAX_LEN1_VAL
public static final int UNSIGNED_MAX_LEN1_VAL
- See Also:
- Constant Field Values
-
UNSIGNED_MAX_LEN2_VAL
public static final int UNSIGNED_MAX_LEN2_VAL
- See Also:
- Constant Field Values
-
UNSIGNED_MAX_LEN3_VAL
public static final int UNSIGNED_MAX_LEN3_VAL
- See Also:
- Constant Field Values
-
UNSIGNED_MAX_LEN4_VAL
public static final int UNSIGNED_MAX_LEN4_VAL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BinaryAsIntField
public BinaryAsIntField(int offset)
Construct a signed instance with a field width = DEFAULT_FIELD_WIDTH = 4.- Parameters:
offset
- int the offset in some byte array to the start of this field.
-
BinaryAsIntField
public BinaryAsIntField(int offset, int length)
Construct a signed instance with a given offset and length.- Parameters:
offset
- int the offset in some byte array to the start of this field.length
- int the size of the field in bytes
-
BinaryAsIntField
public BinaryAsIntField(int offset, int length, boolean signed)
Construct an instance.- Parameters:
offset
- int the offset in some byte array to the start of this field.length
- int the size of the field in bytessigned
- boolean true if the field is signed, false if unsigned.
-
-
Method Detail
-
getByteLength
public int getByteLength()
Answer the length of the field described by the receiver- Specified by:
getByteLength
in interfaceField
- Returns:
- int
-
getOffset
public int getOffset()
Answer the offset of this field into some array of bytes
-
setOffset
public void setOffset(int offset)
- Specified by:
setOffset
in interfaceField
- See Also:
getOffset()
-
getInt
public int getInt(byte[] buffer)
Answer an int from the given byte array buffer, at the offset of this field.- Specified by:
getInt
in interfaceIntAccessor
- Parameters:
buffer
- the byte array- Returns:
- int
- Throws:
java.lang.IllegalArgumentException
- if the value in the field is unsigned and too large to be represented as a java int
-
getInt
public int getInt(byte[] buffer, int bufOffset)
Answer an int from the given byte array buffer, at the bufOffset + offset of this field.- Specified by:
getInt
in interfaceIntAccessor
- Parameters:
buffer
- the byte arraybufOffset
- the additional offset into the byte array- Returns:
- int
- Throws:
java.lang.IllegalArgumentException
- if the value in the field is unsigned and too large to be represented as a java int
-
putInt
public void putInt(int value, byte[] buffer) throws java.lang.IllegalArgumentException
Put a signed int into the given byte array buffer, at the offset of this field.- Specified by:
putInt
in interfaceIntAccessor
- Parameters:
value
- the signed int valuebuffer
- the byte array- Throws:
java.lang.IllegalArgumentException
- if the value is out of range
-
putInt
public void putInt(int value, byte[] buffer, int bufOffset) throws java.lang.IllegalArgumentException
Put a signed int into thegiven byte array buffer, at the bufOffset + offset of this field.- Specified by:
putInt
in interfaceIntAccessor
- Parameters:
value
- the signed int valuebuffer
- the byte arraybufOffset
- the additional offset into the byte array- Throws:
java.lang.IllegalArgumentException
- if the value is out of range
-
isSigned
public boolean isSigned()
Answer true if this field described a signed binary int, false if unsigned.- Specified by:
isSigned
in interfaceIntAccessor
-
setSigned
public void setSigned(boolean signed)
Deprecated.Change the sign of the field. When Data Access Acceleration (DAA) is enabled, this method is not supported and an UnsupportedOperationException will be thrown.- See Also:
isSigned()
-
equals
public boolean equals(java.lang.Integer anInteger, int anInt)
Compare an Integer, possibly null, with an int for equality.- Parameters:
anInteger
-anInt
-- Returns:
- boolean true if equal, false otherwise
-
-