Class IsoValue<T>

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class IsoValue<T>
    extends java.lang.Object
    implements java.lang.Cloneable
    Represents a value that is stored in a field inside an ISO8583 message. It can format the value when the message is generated. Some values have a fixed length, other values require a length to be specified so that the value can be padded to the specified length. LLVAR and LLLVAR values do not need a length specification because the length is calculated from the stored value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      IsoValue<T> clone()
      Returns a copy of the receiver that references the same value object.
      boolean equals​(java.lang.Object other)
      Returns true of the other object is also an IsoValue and has the same type and length, and if other.getValue().equals(getValue()) returns true.
      java.lang.String getCharacterEncoding()  
      CustomFieldEncoder<T> getEncoder()
      Returns the CustomFieldEncoder for this value.
      int getLength()
      Returns the length of the stored value, of the length of the formatted value in case of NUMERIC or ALPHA.
      java.util.TimeZone getTimeZone()  
      IsoType getType()
      Returns the ISO type to which the value must be formatted.
      T getValue()
      Returns the stored value without any conversion or formatting.
      int hashCode()  
      void setCharacterEncoding​(java.lang.String value)  
      void setTimeZone​(java.util.TimeZone value)
      Sets the timezone, useful for date fields.
      java.lang.String toString()
      Returns the formatted value as a String.
      void write​(java.io.OutputStream outs, boolean binary, boolean forceStringEncoding)  
      void write​(java.io.OutputStream outs, boolean binary, boolean forceStringEncoding, boolean forceHexadecimalLength)
      Writes the formatted value to a stream, with the length header if it's a variable length type.
      protected void writeLengthHeader​(int l, java.io.OutputStream outs, IsoType type, boolean binary, boolean forceStringEncoding, boolean forceHexadecimalLength)  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • IsoValue

        public IsoValue​(IsoType t,
                        T value)
      • IsoValue

        public IsoValue​(IsoType t,
                        T value,
                        CustomFieldEncoder<T> custom)
        Creates a new instance that stores the specified value as the specified type. Useful for storing LLVAR or LLLVAR types, as well as fixed-length value types like DATE10, DATE4, AMOUNT, etc.
        Parameters:
        t - the ISO type.
        value - The value to be stored.
        custom - An optional CustomFieldEncoder for the value.
      • IsoValue

        public IsoValue​(IsoType t,
                        T val,
                        int len)
      • IsoValue

        public IsoValue​(IsoType t,
                        T val,
                        int len,
                        boolean hexa)
      • IsoValue

        public IsoValue​(IsoType t,
                        T val,
                        int len,
                        boolean hexa,
                        CustomFieldEncoder<T> custom)
        Creates a new instance that stores the specified value as the specified type. Useful for storing fixed-length value types.
        Parameters:
        t - The ISO8583 type for this field.
        val - The value to store in the field.
        len - The length for the value.
        hexa - Flag if length is encoded as hexadecimal value
        custom - An optional CustomFieldEncoder for the value.
    • Method Detail

      • getType

        public IsoType getType()
        Returns the ISO type to which the value must be formatted.
      • getLength

        public int getLength()
        Returns the length of the stored value, of the length of the formatted value in case of NUMERIC or ALPHA. It doesn't include the field length header in case of LLVAR or LLLVAR.
      • getValue

        public T getValue()
        Returns the stored value without any conversion or formatting.
      • setCharacterEncoding

        public void setCharacterEncoding​(java.lang.String value)
      • getCharacterEncoding

        public java.lang.String getCharacterEncoding()
      • setTimeZone

        public void setTimeZone​(java.util.TimeZone value)
        Sets the timezone, useful for date fields.
      • getTimeZone

        public java.util.TimeZone getTimeZone()
      • toString

        public java.lang.String toString()
        Returns the formatted value as a String. The formatting depends on the type of the receiver.
        Overrides:
        toString in class java.lang.Object
      • clone

        public IsoValue<T> clone()
        Returns a copy of the receiver that references the same value object.
        Overrides:
        clone in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Returns true of the other object is also an IsoValue and has the same type and length, and if other.getValue().equals(getValue()) returns true.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getEncoder

        public CustomFieldEncoder<T> getEncoder()
        Returns the CustomFieldEncoder for this value.
      • writeLengthHeader

        protected void writeLengthHeader​(int l,
                                         java.io.OutputStream outs,
                                         IsoType type,
                                         boolean binary,
                                         boolean forceStringEncoding,
                                         boolean forceHexadecimalLength)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public void write​(java.io.OutputStream outs,
                          boolean binary,
                          boolean forceStringEncoding)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public void write​(java.io.OutputStream outs,
                          boolean binary,
                          boolean forceStringEncoding,
                          boolean forceHexadecimalLength)
                   throws java.io.IOException
        Writes the formatted value to a stream, with the length header if it's a variable length type.
        Parameters:
        outs - The stream to which the value will be written.
        binary - Specifies whether the value should be written in binary or text format.
        forceStringEncoding - When using text format, force the encoding of length headers for variable-length fields to be done with the proper character encoding. When false, the length headers are encoded as ASCII; this used to be the only behavior.
        Throws:
        java.io.IOException