1 Reply Latest reply on Sep 26, 2013 4:39 AM by Gary Brown

    Simple question

    carra P Newbie



      I am confused about how to access the protocols from Java code. I just want to be able to access the roles, the protocol and write them down in the console.

      What I wrote so far:


      public class MyProtocolExtracter {


        private Journal m_journal = null;

        private ProtocolContext m_context = null;

        private ProtocolParser m_parser;

        private Content m_content;

        private ProtocolProjector m_projector;

        ProtocolModel model = null;


        public void viewProtocol(){


        File f = new File("C:\\Users\\Corra\\workspace\\simple_validator\\src\\main\\resources\\org\\scribble\\samples\\Booking\\Booking.spr");

        m_content = new FileContent(f);

        try {

        model = m_parser.parse(m_context,m_content, m_journal);

        } catch (IOException e) {

        // TODO Auto-generated catch block




        Protocol p = model.getProtocol();






      public class MainClass{


        public static void main(String[] args) {

        MyProtocolExtracter ex = new MyProtocolExtracter();





      This gives me NullPointerException. I guess I took the wrong way and need some help. Thank you!

        • 1. Re: Simple question
          Gary Brown Master



          Without seeing the stack trace I am assuming the npe was on the line with "model.getProtocol()".


          The parser usually returns a 'null' model if the protocol was invalid in some way. Any parsing errors would be reported to the journal, but from your code it looks like you have not created a Journal. If you create an instance of this interface, and print the errors, it should help to resolve any issues.


          BTW - just to let you know, there is a new effort at Imperial College to define a new version of the scribble language, which is significantly different to the one implemented in this version of the tools. So feel free to play with this version, but just be aware the next major version will be significantly different.