Draft 01/30/01

com.ibm.converters
Class Decimal

java.lang.Object
  |
  +--com.ibm.converters.Decimal

public class Decimal
extends Object

Converters from fixed point decimal bytes to java.math.BigDecimal, double, or long.

Author:
Specification: Paul Ostler, John Vonau; Implementation: Sandy Pickering, Mike Fulton, Christine Casey

Field Summary
static int COBOL2_ZONED_DECIMAL
          Intel 80/86, Unix, and VAX zoned decimal fixed point representation.
static int NUMERIC_CHARACTER
          Cross-platform character-based decimal fixed point representation.
static int PACKED_DECIMAL
          Packed Decimal representation for System/390, AS/400, Unix, VAX and Intel 80/86.
static int ZONED_DECIMAL
          AS/400, and System/390 zoned decimal fixed point representation.
 
Method Summary
static BigDecimal cobol2ZonedDecimalBytesToBigDecimal(byte[] buffer, int offset, int length, int scale)
          Build a Java BigDecimal from Cobol/2 zoned decimal bytes.
static double cobol2ZonedDecimalBytesToDouble(byte[] buffer, int offset, int length, int scale)
          Build a Java double from Cobol/2 zoned decimal bytes.
static long cobol2ZonedDecimalBytesToLong(byte[] buffer, int offset, int length)
          Build a Java long from Cobol/2 zoned decimal bytes.
static BigDecimal getBigDecimal(byte[] buffer, int offset, int precision, int scale, int representation, String encoding)
          Build a java.math.BigDecimal from a fixed point decimal byte representation.
static double getDouble(byte[] buffer, int offset, int precision, int scale, int representation, String encoding)
          Build a Java double from a fixed point decimal byte representation.
static long getLong(byte[] buffer, int offset, int precision, int representation, String encoding)
          Build a Java long from a fixed point decimal byte representation.
static BigDecimal numericCharacterBytesToBigDecimal(byte[] buffer, int offset, int length, int scale, String encoding)
          Build a java.math.BigDecimal from numeric character bytes.
static double numericCharacterBytesToDouble(byte[] buffer, int offset, int length, int scale, String encoding)
          Build a Java double from numeric character bytes.
static long numericCharacterBytesToLong(byte[] buffer, int offset, int length, String encoding)
          Build a Java long from numeric character bytes.
static BigDecimal packedDecimalBytesToBigDecimal(byte[] buffer, int offset, int length, int scale)
          Build a java.math.BigDecimal from packed decimal bytes.
static double packedDecimalBytesToDouble(byte[] buffer, int offset, int length, int scale)
          Build a Java double from packed decimal bytes.
static long packedDecimalBytesToLong(byte[] buffer, int offset, int length)
          Build a Java long from packed decimal bytes.
static BigDecimal zonedDecimalBytesToBigDecimal(byte[] buffer, int offset, int length, int scale)
          Build a Java BigDecimal from zoned decimal bytes.
static double zonedDecimalBytesToDouble(byte[] buffer, int offset, int length, int scale)
          Build a Java double from zoned decimal bytes.
static long zonedDecimalBytesToLong(byte[] buffer, int offset, int length)
          Build a Java long from zoned decimal bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PACKED_DECIMAL

public static final int PACKED_DECIMAL
Packed Decimal representation for System/390, AS/400, Unix, VAX and Intel 80/86.

ZONED_DECIMAL

public static final int ZONED_DECIMAL
AS/400, and System/390 zoned decimal fixed point representation.

COBOL2_ZONED_DECIMAL

public static final int COBOL2_ZONED_DECIMAL
Intel 80/86, Unix, and VAX zoned decimal fixed point representation.

NUMERIC_CHARACTER

public static final int NUMERIC_CHARACTER
Cross-platform character-based decimal fixed point representation.
Method Detail

getBigDecimal

public static BigDecimal getBigDecimal(byte[] buffer,
                                       int offset,
                                       int precision,
                                       int scale,
                                       int representation,
                                       String encoding)
Build a java.math.BigDecimal from a fixed point decimal byte representation.

Supported representations are:

Parameters:
encoding - The encoding for NUMERIC_CHARACTER representation only, ignored for all other representations.
Throws:
IllegalArgumentException - if the specified representation is not recognized.

getDouble

public static double getDouble(byte[] buffer,
                               int offset,
                               int precision,
                               int scale,
                               int representation,
                               String encoding)
Build a Java double from a fixed point decimal byte representation.

Supported representations are:

Parameters:
encoding - The encoding is for NUMERIC_CHARACTER representation only, ignored for all other representations.
Throws:
IllegalArgumentException - if the specified representation is not recognized.

getLong

public static long getLong(byte[] buffer,
                           int offset,
                           int precision,
                           int representation,
                           String encoding)
Build a Java long from a fixed point decimal byte representation.

Supported representations are:

The scale is assumed to be zero, this converter is typically used for DECIMAL(19,0).

Parameters:
encoding - The encoding is for NUMERIC_CHARACTER representation only, ignored for all other representations.
Throws:
IllegalArgumentException - if the specified representation is not recognized.

packedDecimalBytesToBigDecimal

public static BigDecimal packedDecimalBytesToBigDecimal(byte[] buffer,
                                                        int offset,
                                                        int length,
                                                        int scale)
Build a java.math.BigDecimal from packed decimal bytes.

packedDecimalBytesToDouble

public static double packedDecimalBytesToDouble(byte[] buffer,
                                                int offset,
                                                int length,
                                                int scale)
Build a Java double from packed decimal bytes.

packedDecimalBytesToLong

public static long packedDecimalBytesToLong(byte[] buffer,
                                            int offset,
                                            int length)
Build a Java long from packed decimal bytes.

numericCharacterBytesToBigDecimal

public static BigDecimal numericCharacterBytesToBigDecimal(byte[] buffer,
                                                           int offset,
                                                           int length,
                                                           int scale,
                                                           String encoding)
Build a java.math.BigDecimal from numeric character bytes.
Throws:
UnsupportedOperationException - not yet implemented.

numericCharacterBytesToDouble

public static double numericCharacterBytesToDouble(byte[] buffer,
                                                   int offset,
                                                   int length,
                                                   int scale,
                                                   String encoding)
Build a Java double from numeric character bytes.
Throws:
UnsupportedOperationException - not yet implemented.

numericCharacterBytesToLong

public static long numericCharacterBytesToLong(byte[] buffer,
                                               int offset,
                                               int length,
                                               String encoding)
Build a Java long from numeric character bytes.
Throws:
UnsupportedOperationException - not yet implemented.

zonedDecimalBytesToBigDecimal

public static BigDecimal zonedDecimalBytesToBigDecimal(byte[] buffer,
                                                       int offset,
                                                       int length,
                                                       int scale)
Build a Java BigDecimal from zoned decimal bytes.
Throws:
UnsupportedOperationException - not yet implemented.

zonedDecimalBytesToDouble

public static double zonedDecimalBytesToDouble(byte[] buffer,
                                               int offset,
                                               int length,
                                               int scale)
Build a Java double from zoned decimal bytes.
Throws:
UnsupportedOperationException - not yet implemented.

zonedDecimalBytesToLong

public static long zonedDecimalBytesToLong(byte[] buffer,
                                           int offset,
                                           int length)
Build a Java long from zoned decimal bytes.
Throws:
UnsupportedOperationException - not yet implemented.

cobol2ZonedDecimalBytesToBigDecimal

public static BigDecimal cobol2ZonedDecimalBytesToBigDecimal(byte[] buffer,
                                                             int offset,
                                                             int length,
                                                             int scale)
Build a Java BigDecimal from Cobol/2 zoned decimal bytes.
Throws:
UnsupportedOperationException - not yet implemented.

cobol2ZonedDecimalBytesToDouble

public static double cobol2ZonedDecimalBytesToDouble(byte[] buffer,
                                                     int offset,
                                                     int length,
                                                     int scale)
Build a Java double from Cobol/2 zoned decimal bytes.
Throws:
UnsupportedOperationException - not yet implemented.

cobol2ZonedDecimalBytesToLong

public static long cobol2ZonedDecimalBytesToLong(byte[] buffer,
                                                 int offset,
                                                 int length)
Build a Java long from Cobol/2 zoned decimal bytes.
Throws:
UnsupportedOperationException - not yet implemented.

Draft 01/30/01

Send comments or suggestions to jcc@us.ibm.com