Module ibm.jzos

Class PackedDecimalAsIntField

    • Constructor Summary

      Constructors 
      Constructor Description
      PackedDecimalAsIntField​(int offset, int precision, boolean signed)
      Construct an instance
    • Method Summary

      All Methods Instance Methods Concrete 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 receiver
      int getInt​(byte[] buffer)
      Answer a int from the given byte array buffer, at the offset of this field.
      int getInt​(byte[] buffer, int bufOffset)
      Answer a 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 bytes
      int getPrecision()
      Answer the number of decimal digits of precision.
      boolean isSigned()
      Answer whether the field is signed
      void putInt​(int value, byte[] buffer)
      Put a int into the given byte array buffer, at the offset of this field.
      void putInt​(int value, byte[] buffer, int bufOffset)
      Put a int into the given byte array buffer, at the bufOffset + offset of this field.
      void setOffset​(int offset)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PackedDecimalAsIntField

        public PackedDecimalAsIntField​(int offset,
                                       int precision,
                                       boolean signed)
        Construct an instance
        Parameters:
        offset - position of this field
        precision - total number of digits <= 9. If even, this value is rounded up to the next odd number.
        signed - if true the last nibble is a sign
    • Method Detail

      • getByteLength

        public int getByteLength()
        Answer the length of the field described by the receiver
        Specified by:
        getByteLength in interface Field
        Returns:
        int
      • getOffset

        public int getOffset()
        Answer the offset of this field into some array of bytes
        Specified by:
        getOffset in interface Field
        Returns:
        int
      • getPrecision

        public int getPrecision()
        Answer the number of decimal digits of precision.
        Returns:
        int
      • getInt

        public int getInt​(byte[] buffer)
                   throws java.lang.IllegalArgumentException
        Answer a int from the given byte array buffer, at the offset of this field.

        Note: the data is not checked for valid decimal digits, although the sign nibble is checked for a valid value in the range x'A'-x'F'.

        Specified by:
        getInt in interface IntAccessor
        Parameters:
        buffer - the byte array
        Returns:
        int
        Throws:
        java.lang.IllegalArgumentException - if the field contains an invalid sign
      • getInt

        public int getInt​(byte[] buffer,
                          int bufOffset)
                   throws java.lang.IllegalArgumentException
        Answer a int from the given byte array buffer, at the bufOffset + offset of this field.

        Note: the data is not checked for valid decimal digits, although the sign nibble is checked for a valid value in the range x'A'-x'F'.

        Specified by:
        getInt in interface IntAccessor
        Parameters:
        buffer - the byte array
        bufOffset - the additional offset into the byte array
        Returns:
        int
        Throws:
        java.lang.IllegalArgumentException - if the field contains an invalid sign
      • putInt

        public void putInt​(int value,
                           byte[] buffer)
                    throws java.lang.IllegalArgumentException
        Put a int into the given byte array buffer, at the offset of this field.

        Note: If the field is unsigned, a x'F' is supplied as the sign nibble in the field.

        Specified by:
        putInt in interface IntAccessor
        Parameters:
        value - the signed int value
        buffer - 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 int into the given byte array buffer, at the bufOffset + offset of this field.

        Note: If the field is unsigned, a x'F' is supplied as the sign nibble in the field.

        Specified by:
        putInt in interface IntAccessor
        Parameters:
        value - the signed int value
        buffer - the byte array
        bufOffset - the additional offset into the byte array
        Throws:
        java.lang.IllegalArgumentException - if the value is out of range
      • isSigned

        public boolean isSigned()
        Answer whether the field is signed
        Specified by:
        isSigned in interface IntAccessor
      • 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