Menu

Start with cb2java

juanouton
2007-02-12
2017-01-02
  • juanouton

    juanouton - 2007-02-12

    Hello. I need help for running cb2java. I don´r know how to use this jar file.
    I´m using eclipse (3.2) and i have imported the jar file like a plugin but it doesn't work.
    Please i need to know how to use it.
    Thanks

     
    • dubwai

      dubwai - 2007-02-13

      The first thing to realize is that this is not a plugin or any kind of gui editor for application data.  This is a library that you would include a Java application that needs to work with COBOL copybook defined application data.

      If you are looking for a GUI, look at the RecordEditor project here on sourceforge.

      Otherwise, if you want to use this in an application, you just need to add it to your classpath.

      Here's a short example to help get started.  I've gotten a few questions like this lately so I am going to get some documentation up shortly.

          import net.sf.cb2java.copybook.*;
          import net.sf.sb2java.copybook.data.*;

          public static void main(String[] args)
          {
              Copybook document = parse("simple", new
      FileReader("simple.cpy"));
                             
              Record documentData = document.parseData(new
      FileInputStream("simple.data"));
                 
              recurse(documentData, "");
          }

          static void recurse(GroupData group, String indent)
          {
              for (Iterator i = group.getChildren().iterator();
      i.hasNext();) {
                  Data data = (Data) i.next();
          
                  System.out.print(indent + data.getName() + ": ");

                  if (data.isLeaf()) {
                      System.out.println(data.getValue());
                  } else {
                      System.out.println();
                      recurse((GroupData) data, indent + "  ");
                  }
              }
          }

       
    • dubwai

      dubwai - 2007-02-13

      I uploaded the Javadocs under the 0.3.1 version.  This should help with getting started.

       
    • sonicaaaa

      sonicaaaa - 2007-10-10

      hello. i'm not able to get cbl2java working.

      with the sample code you posted, i receive this exception and i have no clue on what's the matter

      Exception in thread "main" java.lang.ExceptionInInitializerError
          at net.sf.cb2java.copybook.Item.createDocument(Unknown Source)
          at net.sf.cb2java.copybook.Item.createElement(Unknown Source)
          at net.sf.cb2java.copybook.Item.getElement(Unknown Source)
          at net.sf.cb2java.copybook.CopybookAnalyzer.walkTree(Unknown Source)
          at net.sf.cb2java.copybook.CopybookAnalyzer.outARecordDescription(Unknown Source)
          at net.sf.cb2xml.sablecc.analysis.DepthFirstAdapter.caseARecordDescription(DepthFirstAdapter.java:57)
          at net.sf.cb2xml.sablecc.node.ARecordDescription.apply(ARecordDescription.java:33)
          at net.sf.cb2xml.sablecc.analysis.DepthFirstAdapter.caseStart(DepthFirstAdapter.java:31)
          at net.sf.cb2xml.sablecc.node.Start.apply(Start.java:30)
          at net.sf.cb2java.copybook.CopybookParser.parse(Unknown Source)
          at jsp.test.testCBL2Java.main(testCBL2Java.java:22)

      do you have any clue? just wanna add that the copy is handled correctly by RecordEditor

      thanks

      sonica

       
      • dubwai

        dubwai - 2007-10-11

        Can you provide the copy that you are attempting to parse?  Also, is there a cause in the stack trace?  I can't see where the error occurred exactly.  I can't really see what would go wrong in the code that it's pointing to.

        thanks,

        -James

         
  • gopi

    gopi - 2017-01-02

    By using a code I have parsed cobol copy file ie I am able to retrieve child elements from groups. Now I am unable to detect data types of cobol copy file how can I do this using cb2java.

     

Log in to post a comment.

MongoDB Logo MongoDB