Package org.jpos.iso

Class ISOStringFieldPackager

    • Constructor Detail

      • ISOStringFieldPackager

        public ISOStringFieldPackager()
        Constructs a default ISOStringFieldPackager. There is no padding, no length prefix and a literal interpretation. The set methods must be called to make this ISOBaseFieldPackager useful.
      • ISOStringFieldPackager

        public ISOStringFieldPackager​(Padder padder,
                                      Interpreter interpreter,
                                      Prefixer prefixer)
        Constructs an ISOStringFieldPackager with a specific Padder, Interpreter and Prefixer. The length and description should be set with setLength() and setDescription methods.
        Parameters:
        padder - The type of padding used.
        interpreter - The interpreter used to encode the field.
        prefixer - The type of length prefixer used to encode this field.
      • ISOStringFieldPackager

        public ISOStringFieldPackager​(int maxLength,
                                      java.lang.String description,
                                      Padder padder,
                                      Interpreter interpreter,
                                      Prefixer prefixer)
        Creates an ISOStringFieldPackager.
        Parameters:
        maxLength - The maximum length of the field in characters or bytes depending on the datatype.
        description - The description of the field. For human readable output.
        interpreter - The interpreter used to encode the field.
        padder - The type of padding used.
        prefixer - The type of length prefixer used to encode this field.
    • Method Detail

      • setPadder

        public void setPadder​(Padder padder)
        Sets the Padder.
        Parameters:
        padder - The padder to use during packing and unpacking.
      • setInterpreter

        public void setInterpreter​(Interpreter interpreter)
        Sets the Interpreter.
        Parameters:
        interpreter - The interpreter to use in packing and unpacking.
      • setPrefixer

        public void setPrefixer​(Prefixer prefixer)
        Sets the length prefixer.
        Parameters:
        prefixer - The length prefixer to use during packing and unpacking.
      • unpack

        public int unpack​(ISOComponent c,
                          byte[] b,
                          int offset)
                   throws ISOException
        Unpacks the byte array into the component.
        Specified by:
        unpack in class ISOFieldPackager
        Parameters:
        c - The component to unpack into.
        b - The byte array to unpack.
        offset - The index in the byte array to start unpacking from.
        Returns:
        The number of bytes consumed unpacking the component.
        Throws:
        ISOException
      • unpack

        public void unpack​(ISOComponent c,
                           java.io.InputStream in)
                    throws java.io.IOException,
                           ISOException
        Unpack the input stream into the component.
        Overrides:
        unpack in class ISOFieldPackager
        Parameters:
        c - The Component to unpack into.
        in - Input stream where the packed bytes come from.
        Throws:
        java.io.IOException - Thrown if there's a problem reading the input stream.
        ISOException
      • checkLength

        protected void checkLength​(int len,
                                   int maxLength)
                            throws java.lang.IllegalArgumentException
        Checks the length of the data against the maximum, and throws an IllegalArgumentException. This is designed to be called from field Packager constructors and the setLength() method.
        Parameters:
        len - The length of the data for this field packager.
        maxLength - The maximum length allowed for this type of field packager. This depends on the prefixer that is used.
        Throws:
        java.lang.IllegalArgumentException - If len > maxLength.