com.ibm.jtopenlite

Class Conv

  • java.lang.Object
    • com.ibm.jtopenlite.Conv


  • public final class Conv
    extends java.lang.Object
    Utility class for converting data from one format to another.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static byte[] blankPadEBCDIC10(java.lang.String s)
      Converts the specified String into a total of ten CCSID 37 bytes, blank padding with EBCDIC 0x40 as necessary.
      static double byteArrayToDouble(byte[] data, int offset)
      Converts the specified bytes into a double value.
      static float byteArrayToFloat(byte[] data, int offset)
      Converts the specified bytes into a float value.
      static int byteArrayToInt(byte[] data, int offset)
      Converts the specified bytes into an int value.
      static long byteArrayToLong(byte[] data, int offset)
      Converts the specified bytes into a long value.
      static short byteArrayToShort(byte[] data, int offset)
      Converts the specified bytes into a short value.
      static java.lang.String bytesToHexString(byte[] data, int offset, int length)
      Converts the specified bytes into their hexadecimal String representation.
      static java.lang.String bytesToHexString(byte[] data, int offset, int length, char[] buffer)
      Converts the specified bytes into their hexadecimal String representation.
      static java.lang.String decfloat16ByteArrayToString(byte[] data, int offset)
      Converts the specified 8 bytes in decfloat16 format into a String.
      static java.lang.String decfloat34ByteArrayToString(byte[] data, int offset)
      Converts the specified 16 bytes in decfloat34 format into a String.
      static byte[] doubleToByteArray(double d)
      Converts the specified double value into 8 bytes.
      static void doubleToByteArray(double d, byte[] data, int offset)
      Converts the specified double value into 8 bytes.
      static void doubleToPackedDecimal(double d, byte[] data, int offset, int numDigits, int scale) 
      static byte[] doubleToPackedDecimal(double d, int numDigits, int scale) 
      static void doubleToZonedDecimal(double d, byte[] data, int offset, int numDigits, int scale) 
      static byte[] doubleToZonedDecimal(double d, int numDigits, int scale) 
      static java.lang.String ebcdicByteArrayToString(byte[] data, char[] buffer) 
      static java.lang.String ebcdicByteArrayToString(byte[] data, int offset, int length)
      Converts the specified CCSID 37 bytes into a String.
      static java.lang.String ebcdicByteArrayToString(byte[] data, int offset, int length, char[] buffer)
      Converts the specified CCSID 37 bytes into a String.
      static java.lang.String ebcdicByteArrayToString(byte[] data, int offset, int length, char[] buffer, int ccsid)
      Converts the specific CCSID bytes into a String.
      static java.lang.String ebcdicByteArrayToString(byte[] data, int offset, int length, int ccsid)
      Converts the specific CCSID bytes into a String.
      static char ebcdicByteToChar(byte b)
      Converts the specified CCSID 37 byte into a Unicode char without creating any intermediate objects.
      static byte[] floatToByteArray(float f)
      Converts the specified float value into 4 bytes.
      static void floatToByteArray(float f, byte[] data, int offset)
      Converts the specified float value into 4 bytes.
      static java.lang.String getDefaultNLV()
      Return the default NLV for the client corresponding to the Java locale.
      static byte[] hexStringToBytes(java.lang.String value)
      Converts the specified hexadecimal String into its constituent byte values.
      static int hexStringToBytes(java.lang.String value, byte[] data, int offset)
      Converts the specified hexadecimal String into its constituent byte values.
      static byte[] intToByteArray(int value)
      Converts the specified int value into 4 bytes.
      static void intToByteArray(int value, byte[] data, int offset)
      Converts the specified int value into 4 bytes.
      static boolean isSupported(int ccsid)
      Returns true if the conversion to or from the specific CCSID is supported by the methods on this class.
      static byte[] longToByteArray(long longValue)
      Converts the specified long value into 8 bytes.
      static void longToByteArray(long longValue, byte[] data, int offset)
      Converts the specified long value into 8 bytes.
      static void longToZonedDecimal(long l, byte[] data, int offset, int numDigits)
      The scale is 0, and 0 < numDigits <= 20.
      static double packedDecimalToDouble(byte[] data, int offset, int numDigits, int scale) 
      static java.lang.String packedDecimalToString(byte[] data, int offset, int numDigits, int scale)
      Converts the specified packed decimal bytes into a String.
      static java.lang.String packedDecimalToString(byte[] data, int offset, int numDigits, int scale, char[] buffer)
      Converts the specified packed decimal bytes into a String.
      static void shortToByteArray(int value, byte[] data, int offset)
      Converts the specified short value into 2 bytes.
      static void stringToBlankPadEBCDICByteArray(java.lang.String s, byte[] data, int offset, int length)
      Converts the specified String into CCSID 37 bytes, padding the byte array with EBCDIC spaces (0x40) up to length bytes.
      static void stringToBlankPadEBCDICByteArray(java.lang.String s, byte[] data, int offset, int length, int ccsid)
      Converts the specified String into bytes for the specified CCSID, padding the byte array with spaces up to length bytes.
      static void stringToBlankPadUnicodeByteArray(java.lang.String s, byte[] data, int offset, int length)
      Converts the specified String into Unicode bytes, padding the byte array with Unicode spaces (0x0020) up to length bytes.
      static int stringToEBCDICByteArray(java.lang.String s, byte[] data, int offset, int ccsid)
      Converts the specified String into the appropriate byte values for the specified CCSID.
      static byte[] stringToEBCDICByteArray(java.lang.String s, int ccsid)
      Converts the specified String into the appropriate byte values for the specified CCSID.
      static int stringToEBCDICByteArray(java.lang.String s, int length, byte[] data, int offset, int ccsid)
      Converts the specified String into the appropriate byte values for the specified CCSID.
      static byte[] stringToEBCDICByteArray37(java.lang.String s)
      Converts the specified String into CCSID 37 bytes.
      static int stringToEBCDICByteArray37(java.lang.String s, byte[] data, int offset)
      Converts the specified String into CCSID 37 bytes.
      static int stringToEBCDICByteArray37(java.lang.String s, int length, byte[] data, int offset) 
      static byte[] stringToPackedDecimal(java.lang.String s, int numDigits)
      Converts the specified String (number) into packed decimal bytes.
      static void stringToPackedDecimal(java.lang.String s, int numDigits, byte[] buffer, int offset)
      Converts the specified String (number) into packed decimal bytes.
      static byte[] stringToUnicodeByteArray(java.lang.String s)
      Converts the specified String into Unicode bytes.
      static int stringToUnicodeByteArray(java.lang.String s, byte[] data, int offset)
      Converts the specified String into Unicode bytes.
      static void stringToUnicodeByteArray(java.lang.String s, byte[] data, int offset, int byteLength) 
      static int stringToUnicodeByteArray(java.lang.String s, int length, byte[] data, int offset) 
      static int stringToUtf8ByteArray(java.lang.String s, int length, byte[] data, int offset) 
      static byte[] stringToZonedDecimal(java.lang.String s, int numDigits)
      Converts the specified String (number) into zoned decimal bytes.
      static void stringToZonedDecimal(java.lang.String s, int numDigits, byte[] buffer, int offset)
      Converts the specified String (number) into zoned decimal bytes.
      static java.lang.String unicodeByteArrayToString(byte[] data, int offset, int length)
      Converts the specified Unicode bytes into a String.
      static java.lang.String unicodeByteArrayToString(byte[] data, int offset, int length, char[] buffer)
      Converts the specified Unicode bytes into a String.
      static double zonedDecimalToDouble(byte[] data, int offset, int numDigits, int scale) 
      static int zonedDecimalToInt(byte[] data, int offset, int numDigits)
      The scale is 0, and 0 < numDigits <= 10.
      static long zonedDecimalToLong(byte[] data, int offset, int numDigits)
      The scale is 0, and 0 < numDigits <= 20.
      static java.lang.String zonedDecimalToString(byte[] data, int offset, int numDigits, int scale)
      Converts the specified zoned decimal bytes into a String.
      static java.lang.String zonedDecimalToString(byte[] data, int offset, int numDigits, int scale, char[] buffer)
      Converts the specified zoned decimal bytes into a String.
      • Methods inherited from class java.lang.Object

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

      • bytesToHexString

        public static final java.lang.String bytesToHexString(byte[] data,
                                        int offset,
                                        int length)
        Converts the specified bytes into their hexadecimal String representation.
      • bytesToHexString

        public static final java.lang.String bytesToHexString(byte[] data,
                                        int offset,
                                        int length,
                                        char[] buffer)
        Converts the specified bytes into their hexadecimal String representation.
      • hexStringToBytes

        public static final byte[] hexStringToBytes(java.lang.String value)
        Converts the specified hexadecimal String into its constituent byte values.
      • hexStringToBytes

        public static final int hexStringToBytes(java.lang.String value,
                           byte[] data,
                           int offset)
        Converts the specified hexadecimal String into its constituent byte values.
      • stringToEBCDICByteArray37

        public static final byte[] stringToEBCDICByteArray37(java.lang.String s)
        Converts the specified String into CCSID 37 bytes.
      • stringToEBCDICByteArray37

        public static final int stringToEBCDICByteArray37(java.lang.String s,
                                    byte[] data,
                                    int offset)
        Converts the specified String into CCSID 37 bytes.
      • stringToEBCDICByteArray37

        public static final int stringToEBCDICByteArray37(java.lang.String s,
                                    int length,
                                    byte[] data,
                                    int offset)
      • stringToEBCDICByteArray

        public static final byte[] stringToEBCDICByteArray(java.lang.String s,
                                     int ccsid)
                                                    throws java.io.UnsupportedEncodingException
        Converts the specified String into the appropriate byte values for the specified CCSID.
        Throws:
        java.io.UnsupportedEncodingException - Thrown if conversion to or from the specified CCSID is not supported.
      • stringToEBCDICByteArray

        public static final int stringToEBCDICByteArray(java.lang.String s,
                                  byte[] data,
                                  int offset,
                                  int ccsid)
                                                 throws java.io.UnsupportedEncodingException
        Converts the specified String into the appropriate byte values for the specified CCSID.
        Throws:
        java.io.UnsupportedEncodingException - Thrown if conversion to or from the specified CCSID is not supported.
      • stringToEBCDICByteArray

        public static final int stringToEBCDICByteArray(java.lang.String s,
                                  int length,
                                  byte[] data,
                                  int offset,
                                  int ccsid)
                                                 throws java.io.UnsupportedEncodingException
        Converts the specified String into the appropriate byte values for the specified CCSID.
        Throws:
        java.io.UnsupportedEncodingException - Thrown if conversion to or from the specified CCSID is not supported.
      • stringToUnicodeByteArray

        public static final byte[] stringToUnicodeByteArray(java.lang.String s)
        Converts the specified String into Unicode bytes. returns the number of bytes.
      • stringToUnicodeByteArray

        public static final int stringToUnicodeByteArray(java.lang.String s,
                                   byte[] data,
                                   int offset)
        Converts the specified String into Unicode bytes.
      • stringToUnicodeByteArray

        public static final int stringToUnicodeByteArray(java.lang.String s,
                                   int length,
                                   byte[] data,
                                   int offset)
      • stringToUnicodeByteArray

        public static void stringToUnicodeByteArray(java.lang.String s,
                                    byte[] data,
                                    int offset,
                                    int byteLength)
      • stringToUtf8ByteArray

        public static final int stringToUtf8ByteArray(java.lang.String s,
                                int length,
                                byte[] data,
                                int offset)
      • stringToBlankPadUnicodeByteArray

        public static final void stringToBlankPadUnicodeByteArray(java.lang.String s,
                                            byte[] data,
                                            int offset,
                                            int length)
        Converts the specified String into Unicode bytes, padding the byte array with Unicode spaces (0x0020) up to length bytes.
      • unicodeByteArrayToString

        public static final java.lang.String unicodeByteArrayToString(byte[] data,
                                                int offset,
                                                int length)
        Converts the specified Unicode bytes into a String. The length is in bytes, and should be twice the length of the returned String.
      • unicodeByteArrayToString

        public static final java.lang.String unicodeByteArrayToString(byte[] data,
                                                int offset,
                                                int length,
                                                char[] buffer)
        Converts the specified Unicode bytes into a String. The length is in bytes, and should be twice the length of the returned String.
      • stringToBlankPadEBCDICByteArray

        public static final void stringToBlankPadEBCDICByteArray(java.lang.String s,
                                           byte[] data,
                                           int offset,
                                           int length)
        Converts the specified String into CCSID 37 bytes, padding the byte array with EBCDIC spaces (0x40) up to length bytes.
      • stringToBlankPadEBCDICByteArray

        public static final void stringToBlankPadEBCDICByteArray(java.lang.String s,
                                           byte[] data,
                                           int offset,
                                           int length,
                                           int ccsid)
                                                          throws java.io.UnsupportedEncodingException
        Converts the specified String into bytes for the specified CCSID, padding the byte array with spaces up to length bytes.
        Throws:
        java.io.UnsupportedEncodingException - Thrown if conversion to or from the specified CCSID is not supported.
      • ebcdicByteToChar

        public static final char ebcdicByteToChar(byte b)
        Converts the specified CCSID 37 byte into a Unicode char without creating any intermediate objects.
      • ebcdicByteArrayToString

        public static final java.lang.String ebcdicByteArrayToString(byte[] data,
                                               int offset,
                                               int length)
        Converts the specified CCSID 37 bytes into a String. Note: You might as well just use new String(data,"Cp037") to avoid the extra char array this method needs to create. Note: You cannot use new String(data,"Cp037" because this is not supported on all JVMS
      • ebcdicByteArrayToString

        public static final java.lang.String ebcdicByteArrayToString(byte[] data,
                                               char[] buffer)
      • ebcdicByteArrayToString

        public static final java.lang.String ebcdicByteArrayToString(byte[] data,
                                               int offset,
                                               int length,
                                               char[] buffer)
        Converts the specified CCSID 37 bytes into a String.
      • ebcdicByteArrayToString

        public static final java.lang.String ebcdicByteArrayToString(byte[] data,
                                               int offset,
                                               int length,
                                               int ccsid)
                                                              throws java.io.UnsupportedEncodingException
        Converts the specific CCSID bytes into a String.
        Throws:
        java.io.UnsupportedEncodingException - Thrown if conversion to or from the specified CCSID is not supported.
      • ebcdicByteArrayToString

        public static final java.lang.String ebcdicByteArrayToString(byte[] data,
                                               int offset,
                                               int length,
                                               char[] buffer,
                                               int ccsid)
                                                              throws java.io.UnsupportedEncodingException
        Converts the specific CCSID bytes into a String.
        Throws:
        java.io.UnsupportedEncodingException - Thrown if conversion to or from the specified CCSID is not supported.
      • isSupported

        public static boolean isSupported(int ccsid)
        Returns true if the conversion to or from the specific CCSID is supported by the methods on this class.
      • byteArrayToLong

        public static final long byteArrayToLong(byte[] data,
                           int offset)
        Converts the specified bytes into a long value.
      • byteArrayToInt

        public static final int byteArrayToInt(byte[] data,
                         int offset)
        Converts the specified bytes into an int value.
      • byteArrayToShort

        public static final short byteArrayToShort(byte[] data,
                             int offset)
        Converts the specified bytes into a short value.
      • shortToByteArray

        public static final void shortToByteArray(int value,
                            byte[] data,
                            int offset)
        Converts the specified short value into 2 bytes.
      • intToByteArray

        public static final byte[] intToByteArray(int value)
        Converts the specified int value into 4 bytes.
      • intToByteArray

        public static final void intToByteArray(int value,
                          byte[] data,
                          int offset)
        Converts the specified int value into 4 bytes.
      • longToByteArray

        public static final byte[] longToByteArray(long longValue)
        Converts the specified long value into 8 bytes.
      • longToByteArray

        public static final void longToByteArray(long longValue,
                           byte[] data,
                           int offset)
        Converts the specified long value into 8 bytes.
      • blankPadEBCDIC10

        public static final byte[] blankPadEBCDIC10(java.lang.String s)
        Converts the specified String into a total of ten CCSID 37 bytes, blank padding with EBCDIC 0x40 as necessary.
      • byteArrayToFloat

        public static final float byteArrayToFloat(byte[] data,
                             int offset)
        Converts the specified bytes into a float value.
      • floatToByteArray

        public static final void floatToByteArray(float f,
                            byte[] data,
                            int offset)
        Converts the specified float value into 4 bytes.
      • floatToByteArray

        public static final byte[] floatToByteArray(float f)
        Converts the specified float value into 4 bytes.
      • byteArrayToDouble

        public static final double byteArrayToDouble(byte[] data,
                               int offset)
        Converts the specified bytes into a double value.
      • doubleToByteArray

        public static final void doubleToByteArray(double d,
                             byte[] data,
                             int offset)
        Converts the specified double value into 8 bytes.
      • doubleToByteArray

        public static final byte[] doubleToByteArray(double d)
        Converts the specified double value into 8 bytes.
      • decfloat16ByteArrayToString

        public static final java.lang.String decfloat16ByteArrayToString(byte[] data,
                                                   int offset)
        Converts the specified 8 bytes in decfloat16 format into a String.
      • decfloat34ByteArrayToString

        public static final java.lang.String decfloat34ByteArrayToString(byte[] data,
                                                   int offset)
        Converts the specified 16 bytes in decfloat34 format into a String.
      • packedDecimalToString

        public static final java.lang.String packedDecimalToString(byte[] data,
                                             int offset,
                                             int numDigits,
                                             int scale)
        Converts the specified packed decimal bytes into a String.
      • packedDecimalToString

        public static final java.lang.String packedDecimalToString(byte[] data,
                                             int offset,
                                             int numDigits,
                                             int scale,
                                             char[] buffer)
        Converts the specified packed decimal bytes into a String. The number of bytes used from data is equal to numDigits/2+1.
      • packedDecimalToDouble

        public static final double packedDecimalToDouble(byte[] data,
                                   int offset,
                                   int numDigits,
                                   int scale)
      • doubleToPackedDecimal

        public static final byte[] doubleToPackedDecimal(double d,
                                   int numDigits,
                                   int scale)
      • doubleToPackedDecimal

        public static final void doubleToPackedDecimal(double d,
                                 byte[] data,
                                 int offset,
                                 int numDigits,
                                 int scale)
      • stringToPackedDecimal

        public static final byte[] stringToPackedDecimal(java.lang.String s,
                                   int numDigits)
        Converts the specified String (number) into packed decimal bytes.
      • stringToPackedDecimal

        public static final void stringToPackedDecimal(java.lang.String s,
                                 int numDigits,
                                 byte[] buffer,
                                 int offset)
        Converts the specified String (number) into packed decimal bytes. The string must have the correct number of decimal digits for the conversion to be correct.
      • zonedDecimalToString

        public static final java.lang.String zonedDecimalToString(byte[] data,
                                            int offset,
                                            int numDigits,
                                            int scale)
        Converts the specified zoned decimal bytes into a String.
      • zonedDecimalToString

        public static final java.lang.String zonedDecimalToString(byte[] data,
                                            int offset,
                                            int numDigits,
                                            int scale,
                                            char[] buffer)
        Converts the specified zoned decimal bytes into a String.
      • zonedDecimalToLong

        public static final long zonedDecimalToLong(byte[] data,
                              int offset,
                              int numDigits)
        The scale is 0, and 0 < numDigits <= 20.
      • zonedDecimalToInt

        public static final int zonedDecimalToInt(byte[] data,
                            int offset,
                            int numDigits)
        The scale is 0, and 0 < numDigits <= 10.
      • zonedDecimalToDouble

        public static final double zonedDecimalToDouble(byte[] data,
                                  int offset,
                                  int numDigits,
                                  int scale)
      • doubleToZonedDecimal

        public static final byte[] doubleToZonedDecimal(double d,
                                  int numDigits,
                                  int scale)
      • doubleToZonedDecimal

        public static final void doubleToZonedDecimal(double d,
                                byte[] data,
                                int offset,
                                int numDigits,
                                int scale)
      • longToZonedDecimal

        public static final void longToZonedDecimal(long l,
                              byte[] data,
                              int offset,
                              int numDigits)
        The scale is 0, and 0 < numDigits <= 20.
      • stringToZonedDecimal

        public static final byte[] stringToZonedDecimal(java.lang.String s,
                                  int numDigits)
        Converts the specified String (number) into zoned decimal bytes.
      • stringToZonedDecimal

        public static final void stringToZonedDecimal(java.lang.String s,
                                int numDigits,
                                byte[] buffer,
                                int offset)
        Converts the specified String (number) into zoned decimal bytes.
      • getDefaultNLV

        public static java.lang.String getDefaultNLV()
        Return the default NLV for the client corresponding to the Java locale.
        Returns:
        the default client NLV