Class EbcdicConvertor

java.lang.Object
com.softwaremining.jcl.EbcdicConvertor

public class EbcdicConvertor extends Object
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:
 
    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, ...)]
   where 
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)"
note on JCL Type Record Definition above
  • 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 NEW Line characters: Use softwaremining.properties CRLF_FORMAT=windows or CRLF_FORMAT=unix to control Line-Sequential Terminators

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 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 datafile
      inputFileName - - full name/path of the ebcidic datafile
      OutputFileName - - 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 datafile
      inputFileName - - full name/path of the ASCII datafile
      OutputFileName - - 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

      public static void main(String[] args)
      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 fields
      ebcdicToAscii -
      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

      public static String convertString(String data, boolean ebcdicToAscii)
      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

      public static void convertPlainFile(String inFileName, String outFileName, boolean ebcdicToAscii)
      convert a string from/to ascii/ebcdic
      Parameters:
      ebcdicToAscii -
      data -