com.bankframe.ei.txnhandler.dataformat
Class DataFormatUtils

java.lang.Object
  |
  +--com.bankframe.ei.txnhandler.dataformat.DataFormatUtils

public class DataFormatUtils
extends java.lang.Object

This class is a utility class providing common methods for manipulating numerical data in Cobol and hex formats


Field Summary
static char CHAR_MINUS
           
static char CHAR_PERIOD
           
static char CHAR_PLUS
           
static byte INTEGER
           
static byte SHORT
           
 
Constructor Summary
DataFormatUtils()
          This method is the default constructor for the DataFormatUtils class.
 
Method Summary
static java.lang.String asciiToString(byte[] ascii)
          This method converts an ASCII string to java.lang.String format
static java.lang.String cobolNumberToString(byte[] input, java.lang.String fieldEncoding, boolean isSigned, int decBefore, int decAfter)
          This method converts a Cobol number in the byte array into a text String using the specified encoding.
static java.lang.String comp3ToString(byte[] input, int numWholeDigits, int numFractionalDigits)
          This method converts an COBOL COMP3 number to java.lang.String format
static java.lang.String compToString(byte[] input)
          This method converts an COBOL COMP number to java.lang.String format
static java.lang.String ebcdicToString(byte[] ebcdic)
          This method converts an EBCDIC string to java.lang.String format
static byte[] hexStringToBytes(java.lang.String input)
          This method converts a hex String representation to byte array
static boolean isSigned(java.lang.String sign)
          This method determines if the given string flag indicates a signed number has been specified.
static boolean padRight(java.lang.String fillAlignment)
          This method determines if the given string flag indicates right-padding has been specified.
static java.lang.String standardToString(byte[] input, int numWholeDigits, int numFractionalDigits)
          This method converts a COBOL standard number to java.lang.String format
static byte[] subset(byte[] data, int startIndex, int endIndex)
          This method gets a subset of the specified byte array
static byte[] toAscii(java.lang.String input)
          This method converts an java.lang.String to ascii bytes
static byte[] toCobolNumber(java.lang.String input, java.lang.String fieldEncoding, boolean isSigned, int decBefore, int decAfter)
          This method converts a number into a Cobol number in a byte array using the specified encoding.
static byte[] toComp(java.lang.String input, boolean signed, int inputSize)
          This method converts a numerical string to a COBOL COMP number
static byte[] toComp3(java.lang.String input, boolean signed, int maxWholeDigits, int maxFractionalDigits)
          This method converts a numerical string to COBOL COMP3
static byte[] toEbcdic(java.lang.String input)
          This method converts a string to EBCDIC encoding
static void toHex(byte[] input, java.lang.StringBuffer buffer)
          This method creates a hex representation of the given byte array.
static void toHex(byte input, java.lang.StringBuffer buffer)
          This method creates a hex representation of the given byte
static void toHex(int input, java.lang.StringBuffer buffer)
          This method creates a hex representation of the given integer.
static java.lang.String toHexDump(byte[] input)
          This method produces a hex dump of the specified byte array
static java.lang.String toHexString(byte input)
          This method creates a hex representation of the given byte
static java.lang.String toHexString(byte[] input)
          This method creates a hex representation of the given byte array.
static java.lang.String toHexString(int input)
          This method creates a hex representation of the given integer.
static byte[] toStandard(java.lang.String input, boolean signed, int maxWholeDigits, int maxFractionalDigits)
          This method converts a numerical string to a COBOL standard
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTEGER

public static final byte INTEGER
See Also:
Constant Field Values

SHORT

public static final byte SHORT
See Also:
Constant Field Values

CHAR_MINUS

public static final char CHAR_MINUS
See Also:
Constant Field Values

CHAR_PLUS

public static final char CHAR_PLUS
See Also:
Constant Field Values

CHAR_PERIOD

public static final char CHAR_PERIOD
See Also:
Constant Field Values
Constructor Detail

DataFormatUtils

public DataFormatUtils()
This method is the default constructor for the DataFormatUtils class.

Method Detail

padRight

public static boolean padRight(java.lang.String fillAlignment)
This method determines if the given string flag indicates right-padding has been specified.

Parameters:
fillAlignment - is the String to check
Returns:
boolean true if the String fillAlignment specifies padding the on the right, specified by the value TransactionHandlerConstants.ALIGN_RIGHT_TEXT.

isSigned

public static boolean isSigned(java.lang.String sign)
This method determines if the given string flag indicates a signed number has been specified.

Parameters:
sign - is the String to check
Returns:
boolean true if the String sign has the value, 1.

cobolNumberToString

public static java.lang.String cobolNumberToString(byte[] input,
                                                   java.lang.String fieldEncoding,
                                                   boolean isSigned,
                                                   int decBefore,
                                                   int decAfter)
This method converts a Cobol number in the byte array into a text String using the specified encoding.

Parameters:
input - is a byte array containing a Cobol number to convert
fieldEncoding - is the encoding format of the Cobol number input; STD, COMP3, COMP, X
isSigned - indicates if the Cobol number is signed
decBefore - indicates the number of places before the decimal point
decAfter - indicates the number of places after the decimal point
Returns:
String containing converted Cobol number in text form

toCobolNumber

public static byte[] toCobolNumber(java.lang.String input,
                                   java.lang.String fieldEncoding,
                                   boolean isSigned,
                                   int decBefore,
                                   int decAfter)
This method converts a number into a Cobol number in a byte array using the specified encoding.

Parameters:
input - contains the number to convert into a Cobol number format
fieldEncoding - is the encoding format to use for the Cobol number; STD, COMP3, COMP, X
isSigned - indicates if the Cobol number is signed
decBefore - indicates the number of places before the decimal point
decAfter - indicates the number of places after the decimal point
Returns:
byte[] containing the Cobol number

toHex

public static void toHex(byte input,
                         java.lang.StringBuffer buffer)
This method creates a hex representation of the given byte

Parameters:
input - is the byte to represent in hex
buffer - is a StringBuffer containing the hex representation of the byte

toHexString

public static java.lang.String toHexString(byte input)
This method creates a hex representation of the given byte

Parameters:
input - is the byte to represent in hex
Returns:
String containing the hex representation of the byte

toHex

public static void toHex(byte[] input,
                         java.lang.StringBuffer buffer)
This method creates a hex representation of the given byte array.

Parameters:
input - is the byte array to represent in hex
buffer - is a StringBuffer containing the hex representation of the byte array

toHexString

public static java.lang.String toHexString(byte[] input)
This method creates a hex representation of the given byte array.

Parameters:
input - is the byte array to represent in hex
Returns:
String containing the hex representation of the byte array

toHex

public static void toHex(int input,
                         java.lang.StringBuffer buffer)
This method creates a hex representation of the given integer.

Parameters:
input - is the integer to represent in hex
buffer - is a StringBuffer containing the hex representation of the integer

toHexString

public static java.lang.String toHexString(int input)
This method creates a hex representation of the given integer.

Parameters:
input - is the integer to represent in hex
Returns:
String containing the hex representation of the integer

toHexDump

public static java.lang.String toHexDump(byte[] input)
This method produces a hex dump of the specified byte array

Parameters:
input - is the byte[] to create a hex dump from
Returns:
String hex dump

hexStringToBytes

public static byte[] hexStringToBytes(java.lang.String input)
This method converts a hex String representation to byte array

Parameters:
input - is the hex String
Returns:
is the created byte array

toEbcdic

public static byte[] toEbcdic(java.lang.String input)
This method converts a string to EBCDIC encoding

Parameters:
input - is String to convert
Returns:
EBCDIC byte array

toAscii

public static byte[] toAscii(java.lang.String input)
This method converts an java.lang.String to ascii bytes

Parameters:
input - is String to convert
Returns:
ascii byte array

asciiToString

public static java.lang.String asciiToString(byte[] ascii)
This method converts an ASCII string to java.lang.String format

Parameters:
ascii - byte array
Returns:
String

ebcdicToString

public static java.lang.String ebcdicToString(byte[] ebcdic)
This method converts an EBCDIC string to java.lang.String format

Parameters:
ebcdic - byte array to convert
Returns:
String representation of the EBCDIC data

compToString

public static java.lang.String compToString(byte[] input)
This method converts an COBOL COMP number to java.lang.String format

Parameters:
input - is a Cobol number byte array
Returns:
Cobol number converted to a String

toComp

public static byte[] toComp(java.lang.String input,
                            boolean signed,
                            int inputSize)
This method converts a numerical string to a COBOL COMP number

Parameters:
input - is the numerical string
signed - indicates if the number is signed
inputSize - indicates the size of the Cobol number
Returns:
Cobol number byte array

comp3ToString

public static java.lang.String comp3ToString(byte[] input,
                                             int numWholeDigits,
                                             int numFractionalDigits)
This method converts an COBOL COMP3 number to java.lang.String format

Parameters:
input - is the Cobol byte array
numWholeDigits - is the number of places before decimal point
numFractionalDigits - is the number of places after decimal point
Returns:
Cobol number as a numerical String

toComp3

public static byte[] toComp3(java.lang.String input,
                             boolean signed,
                             int maxWholeDigits,
                             int maxFractionalDigits)
This method converts a numerical string to COBOL COMP3

Parameters:
input - is the numerical string
signed - indicates if the number is signed
Returns:
Cobol number byte array

standardToString

public static java.lang.String standardToString(byte[] input,
                                                int numWholeDigits,
                                                int numFractionalDigits)
This method converts a COBOL standard number to java.lang.String format

Parameters:
input - is the Cobol byte array
numWholeDigits - is the number of places before decimal point
numFractionalDigits - is the number of places after decimal point
Returns:
Cobol number as a numerical String

toStandard

public static byte[] toStandard(java.lang.String input,
                                boolean signed,
                                int maxWholeDigits,
                                int maxFractionalDigits)
This method converts a numerical string to a COBOL standard

Parameters:
input - is the numerical string
signed - indicates if the number is signed
Returns:
Cobol number byte array

subset

public static byte[] subset(byte[] data,
                            int startIndex,
                            int endIndex)
This method gets a subset of the specified byte array

Parameters:
data - is the byte array to get a subset of
startIndex - is the start index of the required subset
endIndex - is the end index of the required subset
Returns:
byte array subset


Copyright © 2005 Siebel Systems, Inc. All rights reserved.