com.ibm.as400.access

Class ValidationListTranslatedData

  • java.lang.Object
    • com.ibm.as400.access.ValidationListTranslatedData
  • Direct Known Subclasses:
    ValidationListAttributeData, ValidationListDataToEncrypt


    public class ValidationListTranslatedData
    extends java.lang.Object
    Represents language-specific information that is assigned in a standardized format to a validation list entry. This could be information in the non-encrypted data, encrypted data, or identifier portion of a validation list entry. Maximum lengths for each are 1000, 600, and 100 bytes, respectively.
    Author:
    Thomas Johnson (tom.johnson@kingland.com), Kingland Systems Corporation
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      int getByteLength()
      Returns the total length of the corresponding structure when this object is written to IBM i bytes for use by the validation list APIs.
      byte[] getBytes()
      Returns the IBM i bytes comprising the translated data.
      int getCcsid()
      Returns the coded character set identifier used to encode the translated bytes.
      protected int getReadOffsetCcsid()
      Returns the offset of CCSID information in the structure when the receiver is read from IBM i bytes.
      protected int getReadOffsetTByteLength()
      Returns the offset of the length of the translated bytes when the receiver is read from a IBM i byte structure.
      protected int getReadOffsetTBytes()
      Returns the offset of the translated bytes when the receiver is read from an IBM i byte structure.
      java.lang.String getString(AS400 as400)
      Returns the result of converting the assigned IBM i bytes to a Java String using the assigned CCSID.
      protected int getWriteNullDataLength()
      Returns the length to be specified in the written IBM i byte structure if the assigned data is null.
      protected int getWriteOffsetCcsid()
      Returns the offset of CCSID information in the structure when the receiver is written to IBM i bytes.
      protected int getWriteOffsetTByteLength()
      Returns the offset of the length of the translated bytes when the receiver is written to an IBM i byte structure.
      protected int getWriteOffsetTBytes()
      Returns the offset of the translated bytes when the receiver is written to an IBM i byte structure.
      protected boolean isValidCcsid(int ccsid)
      Indicates whether the given CCSID is valid for tagging IBM i data.
      void setBytes(byte[] bytes)
      Sets the IBM i bytes comprising the translated data.
      void setBytes(java.lang.String s, int ccsid, AS400 as400)
      Sets the bytes comprising the translated data from the given string.
      void setCcsid(int ccsid)
      Sets the coded character set identifier used to encode the translated bytes.
      byte[] toBytes()
      Returns the byte array resulting from converting this object to a structure usable by the system APIs.
      int toBytes(byte[] buffer, int offset)
      Converts this object to a byte structure usable by the system APIs.
      • Methods inherited from class java.lang.Object

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

      • ValidationListTranslatedData

        public ValidationListTranslatedData()
        Constructs a ValidationListTranslatedData.
      • ValidationListTranslatedData

        public ValidationListTranslatedData(byte[] buffer,
                                    int offset)
        Constructs a ValidationListTranslatedData from a structure stored as IBM i bytes.

        The offset indicates the starting position of the structure in the given buffer.

        Parameters:
        buffer - byte[]
        offset - int
      • ValidationListTranslatedData

        public ValidationListTranslatedData(int ccsid,
                                    byte[] bytes)
        Constructs a ValidationListTranslatedData from the specified IBM i bytes which are encoded in the given ccsid.
        Parameters:
        ccsid - int
        bytes - byte[]
      • ValidationListTranslatedData

        public ValidationListTranslatedData(java.lang.String s,
                                    int ccsid,
                                    AS400 as400)
        Constructs a ValidationListTranslatedData from the given string.

        The translated bytes are derived by converting the string to IBM i bytes using the given ccsid. The as400 is required to perform the conversion from text to bytes. A ccsid of 0 indicates to use the ccsid of the current user.

        Parameters:
        s - java.lang.String
        ccsid - int
        as400 - com.ibm.as400.access.AS400
    • Method Detail

      • getByteLength

        public int getByteLength()
        Returns the total length of the corresponding structure when this object is written to IBM i bytes for use by the validation list APIs.

        This is the length of the entire structure, not just the translated bytes.

        Returns:
        int
      • getBytes

        public byte[] getBytes()
        Returns the IBM i bytes comprising the translated data.

        For text conversion, the bytes will be interpreted using the assigned ccsid.

        Returns:
        byte[]
      • getCcsid

        public int getCcsid()
        Returns the coded character set identifier used to encode the translated bytes.

        Valid CCSID values are in the range 1 through 65535. The special value 0 can be used to indicate the default CCSID for the current user (when the validation list APIs are invoked on the system). In some cases, primarily attribute data, the special value -1 is also allowed. This indicates that no CCSID value is stored with the data (i.e. binary data, where no conversion is required).

        Returns:
        int
      • getReadOffsetCcsid

        protected int getReadOffsetCcsid()
        Returns the offset of CCSID information in the structure when the receiver is read from IBM i bytes.
        Returns:
        int
      • getReadOffsetTByteLength

        protected int getReadOffsetTByteLength()
        Returns the offset of the length of the translated bytes when the receiver is read from a IBM i byte structure.
        Returns:
        int
      • getReadOffsetTBytes

        protected int getReadOffsetTBytes()
        Returns the offset of the translated bytes when the receiver is read from an IBM i byte structure.
        Returns:
        int
      • getString

        public java.lang.String getString(AS400 as400)
        Returns the result of converting the assigned IBM i bytes to a Java String using the assigned CCSID. Returns null if the assigned ccsid is -1, since the bytes do not represent text.

        The as400 is required to perform the conversion.

        Parameters:
        as400 - com.ibm.as400.access.AS400
        Returns:
        java.lang.String
      • getWriteNullDataLength

        protected int getWriteNullDataLength()
        Returns the length to be specified in the written IBM i byte structure if the assigned data is null.

        Typically this value is set to 0. However, there are some cases where other values must be specified to maintain proper behavior. For example, when changing an entry a structure must be specified for the data to encrypt, even if the encrypted data should not be changed. However, if the data length in the structure is set to 0 instead of -1, the existing encrypted data is wiped out. This is undesirable since we don't always want the encrypted data changed. We might want to modify the unencrypted data (i.e. user statistics) while leaving the encrypted data (i.e. user password) unchanged.

        Returns:
        int
      • getWriteOffsetCcsid

        protected int getWriteOffsetCcsid()
        Returns the offset of CCSID information in the structure when the receiver is written to IBM i bytes.
        Returns:
        int
      • getWriteOffsetTByteLength

        protected int getWriteOffsetTByteLength()
        Returns the offset of the length of the translated bytes when the receiver is written to an IBM i byte structure.
        Returns:
        int
      • getWriteOffsetTBytes

        protected int getWriteOffsetTBytes()
        Returns the offset of the translated bytes when the receiver is written to an IBM i byte structure.
        Returns:
        int
      • isValidCcsid

        protected boolean isValidCcsid(int ccsid)
        Indicates whether the given CCSID is valid for tagging IBM i data.
        Returns:
        true if valid; false if not.
      • setBytes

        public void setBytes(byte[] bytes)
        Sets the IBM i bytes comprising the translated data.

        For text conversion, the bytes will be interpreted using the assigned ccsid.

        Parameters:
        bytes - byte[]
      • setBytes

        public void setBytes(java.lang.String s,
                    int ccsid,
                    AS400 as400)
        Sets the bytes comprising the translated data from the given string.

        The translated bytes are derived by converting the string to IBM i bytes using the given ccsid. The as400 is required to perform the conversion from text to bytes. A ccsid of 0 indicates to use the ccsid of the current user.

        Parameters:
        s - java.lang.String
        ccsid - int
        as400 - com.ibm.as400.access.AS400
      • setCcsid

        public void setCcsid(int ccsid)
        Sets the coded character set identifier used to encode the translated bytes.

        Valid CCSID values are in the range 1 through 65535. The special value 0 can be used to indicate the default CCSID for the current user (when the validation list APIs are invoked on the system). In some cases, primarily attribute data, the special value -1 is also allowed. This indicates that no CCSID value is stored with the data (i.e. binary data, where no conversion is required).

        Parameters:
        ccsid - int
      • toBytes

        public byte[] toBytes()
        Returns the byte array resulting from converting this object to a structure usable by the system APIs.
        Returns:
        byte[]
      • toBytes

        public int toBytes(byte[] buffer,
                  int offset)
        Converts this object to a byte structure usable by the system APIs.

        The IBM i bytes are inserted into the buffer starting at the given offset. The total number of bytes inserted is returned.

        Parameters:
        buffer - byte[]
        offset - int
        Returns:
        int