4 Replies Latest reply on Sep 26, 2011 11:46 PM by John 'JB' Brock-Oracle

    Jdeveloper (11gR2) Extension ?.

      Hi All,

      By using the JDeveloper (11gR2) Extension ,

      1.Programmatically How can get the currently selected file name in jdeveloper ?.
      2. Programmatically how how can get the particular variable declartion Line number ?

      Vass Lee
        • 1. Re: Jdeveloper (11gR2) Extension ?.
          John 'JB' Brock-Oracle
          Your workspace (application) contains projects
          Your projects contain documents (files)
          If you want to find the name of a document you do it in the

          enter (AuditContext context, Document document){ } method

          In the blog example (http://blogs.oracle.com/jdevextensions/entry/don_t_fear_the_audit) , you will see that we test for the file name to see if it ends with VO.xml
            public void enter(AuditContext context, Document document) {
              String firstNodeOfdocument = document.getDocumentElement().getNodeName();
              if ("ViewObject".equals(firstNodeOfdocument)) {
                String filePath = context.getUrl().getPath();
                if (!filePath.substring(filePath.lastIndexOf("/") + 1).matches(".*VO.xml")) {
          You can do the same thing to get the file name. filePath, in the example above, returns the full path to the file that is currently being audited.

          If you perform an audit against a workspace, the audit framework will walk down a tree starting with the application, then going to the first project, and working through each of that projects documents, and the source of those documents, then move to the next project and repeats the steps.

          If you setup audits that contain code like the example above, it will find the file name of every single file that it comes across during the audit.

          You can choose to only audit one project, or just audit one file if you like. Which of course, would limit the places the audit looks.

          Edited by: John 'JB' Brock on Sep 21, 2011 10:00 AM
          • 2. Re: Jdeveloper (11gR2) Extension ?.
            John 'JB' Brock-Oracle
            You can get the line number of where the audit is currently performing it's task by calling:

            getLineOffset() method in the AuditContext class.

            The returned int is zero based, where as the IDE editor display is 1 based, so the number will be off by one. Example if the method returns 70, the real line that you will look at in the editor is 71.

            Hope that helps.
            • 3. Re: Jdeveloper (11gR2) Extension ?.
              Hi john,

              Can you guide me how to create audit rule for the following;

              In our case we should not use "+" to concatenate more than one strings. For this we need to write a audit rule. Please guilde how to achieve this.

              Thanks in advance.

              Lakshmi Narayanan.
              • 4. Re: Jdeveloper (11gR2) Extension ?.
                John 'JB' Brock-Oracle

                Please provide a code snip that shows the correct and incorrect formatting.

                Something like:

                String foo = a + b + c;
                String foo = a + b;