Package com.softwaremining.jcl
Class EbcdicConvertor
java.lang.Object
com.softwaremining.jcl.EbcdicConvertor
EBCDIC To ASCII Data Migration utility class
LIMITATION: May not work on classes which have complicated REDEFINIONS. The system will convert all characters apart from those associated with Packed-Decimal (PD) fields. Ie even when a NON-PD field REDEFINES a PD field, the presence of the PD field will cause the characters at that position to be excluded from conversion
Usage:
Notes on GRP_SELECTOR: useful when the record contains REDEFINES. It allows specifying conditions where each REDEFINE group can be applied.
E.g: 1,1,EQ,A,GRP_1 means when first character equals "A" then perform Ebcdic conversion using structure defined by GRP_1
and 1,1,EQ,X'F3',GRP_2 means when first character equals 0xF3 then perform Ebcdic conversion using structure defined by GRP_2
Please note the names come from the generated Data-Access-Objects (DAO). In the DAO's all '-' characters would have been replaced by underscore '_' characters. Ie GRP_1 instead of GRP-1 .
LIMITATION: May not work on classes which have complicated REDEFINIONS. The system will convert all characters apart from those associated with Packed-Decimal (PD) fields. Ie even when a NON-PD field REDEFINES a PD field, the presence of the PD field will cause the characters at that position to be excluded from conversion
Usage:
java com.softwaremining.jcl.EbcdicConvertor direction full-ClassName input-filename output-filename [forceNewLine (true or false)] [-GRP_SELECTOR=(pos,length,condType,condValue,GRP_NAME,AND/OR, ...)] wherenote on JCL Type Record Definition above
direction: e2a (for EBCDIC to ASCII), a2e (for ASCII to EBCDIC) full-ClassName or record-definition e.g. com.myapp.idata.TestWrapper or JCL Type Record Definition (1,20,CH,21,4,PD,24,60,CH)
input-filename e.g. ../data/input-record.txt output-filename e.g. ../data/output-record.txt [OPTIONAL] forceNewLine : (deprecated use -forceNewLine]): the fifth argument (without a prefix) can be true or false. When true, FORCES the output-file records to be delimited by new line char. Default is false When 'false' the system will CR/LF characters (if any) at end of each record. [OPTIONAL] -forceNewLine=true/false [Optional] :true or false. Default is false. When true, FORCES the output-file records to be delimited by new line char. When 'false' the system will CR/LF characters (if any) at end of each record [OPTIONAL] -GRP_SELECTOR=(pos,length,condType,condValue,GRP_NAME,AND/OR, ...) e.g. (1,1,EQ,A,GRP_1 ,OR,1,1,EQ,X'F3',GRP_2 )" [OPTIONAL] -rdw=true/false)"
- 1,20,CH - characters position 1 through 20 (length=20) characters of data to be Alphanumeric and requiring EBCDIC <-> ASCII conversion
- 21,4,PD - defines characters position 21 through 24 (Length=4) to be PACKED-DECIMAL and excluded from character-set conversions
- 25,60,CH- defines characters position 25 through 65 (length=60) to be Alphanumeric and requiring EBCDIC <-> ASCII conversion
Notes on GRP_SELECTOR: useful when the record contains REDEFINES. It allows specifying conditions where each REDEFINE group can be applied.
E.g: 1,1,EQ,A,GRP_1 means when first character equals "A" then perform Ebcdic conversion using structure defined by GRP_1
and 1,1,EQ,X'F3',GRP_2 means when first character equals 0xF3 then perform Ebcdic conversion using structure defined by GRP_2
Please note the names come from the generated Data-Access-Objects (DAO). In the DAO's all '-' characters would have been replaced by underscore '_' characters. Ie GRP_1 instead of GRP-1 .
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final void
asciiToEbcdic
(CBLBean dataClass, String inputFileName, String outputFileName, boolean forceNewLineType) Deprecated.static int
ASCIIToEBCDIC
(int ascii) translate a single byte 0 ..static char[]
convertBytes
(byte[] data, boolean ebcdicToAscii) static char[]
convertChars
(char[] data, boolean ebcdicToAscii) convert a string from/to ascii/ebcdicstatic void
convertPlainFile
(String inFileName, String outFileName, boolean ebcdicToAscii) convert a string from/to ascii/ebcdicstatic char[]
convertRecordLine
(char[] originalChars, List<AbstractCBLField> allCompFields, boolean ebcdicToAscii) convert a string line for the record containing Fieldsstatic char[]
convertRecordLine_SingleField
(char[] nextLine, int memoryPosition, List<AbstractCBLField> fieldList, boolean ebcdicToAscii) Deprecated.static String
convertString
(String data, boolean ebcdicToAscii) convert a string from/to ascii/ebcdicstatic final void
ebcdicToAscii
(CBLBean dataClass, String inputFileName, String outputFileName, boolean forceNewLineType) Deprecated.static int
EBCDICToASCII
(int ebcdic) Convert a single byte 0 ..static void
Application Entry Point
-
Constructor Details
-
EbcdicConvertor
public EbcdicConvertor()
-
-
Method Details
-
ebcdicToAscii
@Deprecated public static final void ebcdicToAscii(CBLBean dataClass, String inputFileName, String outputFileName, boolean forceNewLineType) throws IOException Deprecated.Convert a datafile containing EBCDIC datafile to ASCII Note that the persistenceFile should contain the full definition of the Binary and Non-binary fields. Ie it cannot be used with a persistenceFile which contains a large Filler definition. LIMITATION: Does not work with classes containing REDEFINED items- Parameters:
dataClass
- : Class representing the structure of to the datafileinputFileName
- - full name/path of the ebcidic datafileOutputFileName
- - full name./path of the target ASCII file.- Throws:
IOException
-
asciiToEbcdic
@Deprecated public static final void asciiToEbcdic(CBLBean dataClass, String inputFileName, String outputFileName, boolean forceNewLineType) throws IOException Deprecated.Convert a datafile containing ASCII datafile to EBCDIC Note that the persistenceFile should contain the full definition of the Binary and Non-binary fields. Ie it cannot be used with a persistenceFile which contains a large Filler definition. LIMITATION: Does not work with classes containing REDEFINED items- Parameters:
dataClass
- : Class representing the structure of to the datafileinputFileName
- - full name/path of the ASCII datafileOutputFileName
- - full name./path of the target EBCDIC file.- Throws:
IOException
-
ASCIIToEBCDIC
public static int ASCIIToEBCDIC(int ascii) translate a single byte 0 .. 255 from ASCII (Latin-1) to EBCDIC. Also works with signed bytes -128 .. 127. -
EBCDICToASCII
public static int EBCDICToASCII(int ebcdic) Convert a single byte 0 .. 255 from EBCDIC to ASCII (Latin-1). Also works with signed bytes -128 .. 127. -
main
Application Entry Point -
convertRecordLine
public static char[] convertRecordLine(char[] originalChars, List<AbstractCBLField> allCompFields, boolean ebcdicToAscii) convert a string line for the record containing Fields- Parameters:
originalChars
-allCompFields
- - conversion should exclude computation fieldsebcdicToAscii
-- Returns:
-
convertRecordLine_SingleField
@Deprecated public static char[] convertRecordLine_SingleField(char[] nextLine, int memoryPosition, List<AbstractCBLField> fieldList, boolean ebcdicToAscii) Deprecated.convert a string line for the record containing Fields- Parameters:
nextLine
-fieldList
-ebcdicToAscii
-- Returns:
-
convertString
convert a string from/to ascii/ebcdic- Parameters:
data
-ebcdicToAscii
-- Returns:
-
convertChars
public static char[] convertChars(char[] data, boolean ebcdicToAscii) convert a string from/to ascii/ebcdic- Parameters:
data
-ebcdicToAscii
-- Returns:
-
convertBytes
public static char[] convertBytes(byte[] data, boolean ebcdicToAscii) -
convertPlainFile
convert a string from/to ascii/ebcdic- Parameters:
ebcdicToAscii
-data
-
-