July 28, 2019

Cobol to Java Convertor - A Transformation Utility application

Cobol to Java Converter - A Transformation Utility

 Trying to make an application that can effeciently converts COBOL code to Java.

This project is on going on...


The function identifies the block of codes in COBOL and categories it, based on
CobolConstants.divisionIdentifier


public Map<String,List<String>> createCodeblocks() throws IOException {
codeBlocks = new HashMap<>();
String line = null;
List<String> elements = null;
String key = null;
while (null != (line = bufferedReader.readLine())) {
if (CobolConstants.divisionIdentifier.contains(line)) {
if (null != elements) {
codeBlocks.put(key, elements);
codeConstructor(key,elements);
}
key = line;
elements = new ArrayList<>();
} else {
elements.add(line);
}
}

return codeBlocks;
}


CodeConstructor is trying to constructor java code by finding the proper class based on the identifierdivisions in COBOL

private void codeConstructor(String key, List<String> elements) {
// TODO Auto-generated method stub
switch (key) {
case "IDENTIFICATION DIVISION.":
identificationDivision = new IdentificationDivision(key, elements);
identificationDivision.getConvertedCode();
break;

default:
break;
}
}



This step create the Java code from the COBOL code given

public void getConvertedCode() {

for(String code : codes) {
if(code.contains("PROGRAM-ID")) {
String name = code.replace("PROGRAM-ID.", "").replace(".", "");
System.out.println(" public class "+getNamingUtility().createClassName(name));

}
}

}


Input

PROGRAM-ID. Iteration-If

Output

public class iterationIf



For complete code, please check my github page, feel free to contact us...



5 comments:

  1. AnonymousJuly 28, 2019

    Today, I went to the beach with my kids. I found a sea shell and gave it to mmy 4 year old
    daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and screamed.
    There was a hermit crab inside and it pinched
    her ear. Shhe never wants to go back! LoL I know thiis is entirely offf topic
    but I had to tell someone!

    ReplyDelete
  2. AnonymousJuly 28, 2019

    Hey there! I know this iss kinda off topic but I was wondering which blog platform are you using for this website?
    I'm getting tired of Wordpress because I've
    had issues with hackers and I'm looking at option for another platform.
    I would be great if you could point me in the direction of a good platform.

    ReplyDelete
  3. AnonymousJuly 28, 2019

    Very great post. I just stumbled upkn your blog and wanted to say that I've reall enjoyed browsing your blog posts.

    After all I'll be subscribing to your rss feed and I'm hoping you write once
    more very soon!

    ReplyDelete
  4. Hi there! Do you know if they make any plugins to assist with Search
    Engine Optimization? I'm trying to get myy blog tto rank for some targeted keywords but I'm not seeing very good success.

    If you know of any please share. Kudos!

    ReplyDelete
  5. Hi, Neat post. There is a problem along with your web site in web explorer, may test this?
    IE nonethheless is thhe market chief and a lawrge element
    of people will leave out your great writing because of this problem.

    ReplyDelete

Your feedback may help others !!!

Facebook comments