@Override
  public void exitMethodBody(MethodBodyContext ctx) {
    if (patternMatchedInMethod
        && !nearestMatchingIfsForPattern.isEmpty()
        && nearestMatchingsIfsForMethod != null) {

      if (nearestMatchingsIfsForMethod.containsKey(actMethodFrMap)) {
        if (LogUtil.isDebugEnabled(LOG_NAME)) {
          LogUtil.debug(CLASS_NAME, "exitMethodBody:", actMethodFrMap + "==>", LOG_NAME);
        }
        nearestMatchingsIfsForMethod.get(actMethodFrMap).putAll(nearestMatchingIfsForPattern);
      } else {
        nearestMatchingsIfsForMethod.put(actMethodFrMap, nearestMatchingIfsForPattern);
      }
      patternText.append("\nNearest Matching If map\n");
      patternText.append("\n" + nearestMatchingIfsForPattern);
      actMethodFrMap = null;
    }
    if (patternMatchedInMethod && nearestMatchingIfsForPattern.isEmpty()) {
      count++;
      if (LogUtil.isDebugEnabled(LOG_NAME)) {
        LogUtil.debug(CLASS_NAME, "Statistics:", ruleID + "==>POJO not generated", LOG_NAME);
      }
    }
  }
  @Override
  public void exitClassDeclaration(ClassDeclarationContext ctx) {
    try {
      // To test need to remove
      if (LogUtil.isDebugEnabled(LOG_NAME)) {
        LogUtil.debug(
            CLASS_NAME,
            "exitClassDeclaration",
            "NearestMatch==>" + nearestMatchingsIfsForMethod,
            LOG_NAME);
      }

      conditionWriter.write(conditionText.toString());
      patternMatchWriter.write(patternText.toString());
      if (LogUtil.isDebugEnabled(LOG_NAME)) {
        // LogUtil.debug(CLASS_NAME,"exitClassDeclaration"
        // ,conditionWriter.toString(), LOG_NAME);
        // LogUtil.debug(CLASS_NAME,ctx.Identifier().getText(),"Skip count==>"+count,
        // LOG_NAME);
      }
    } catch (IOException ie) {
      System.out.println("exitclass" + ie.toString());
      LogUtil.error(CLASS_NAME, "exitClassDeclaration", ie.toString(), LOG_NAME);
      // ie.printStackTrace();
    }
  }
  private void getJavaDocMatch() {
    // TODO Auto-generated method stub

    try {
      matchedindex = new HashMap<Integer, String>();
      // Need to modify regex Pattern as StackOverFlow Error
      String regex = "/\\*\\*([^\\*]|\\*(?!/))*?.*?\\*/";
      Pattern pattern = Pattern.compile(regex);
      Matcher matcher = pattern.matcher(tokens.getText());

      // System.out.println(matcher.matches());
      if (tokens.getText() != null) {
        while (matcher.find()) { // find the next match

          if (LogUtil.isDebugEnabled(LOG_NAME)) {
            // System.out.println("(matcher.group()==>"+(matcher.group()));
            LogUtil.debug(CLASS_NAME, "Pattern==>", " " + matcher.group(), LOG_NAME);
          }
          for (String searchKeyword : searchPatterns) {
            if (searchKeyword != null) {
              if (matcher.group().contains(searchKeyword)) {
                /*
                 * System.out.println(
                 * "Keyword matched in Javadoc ==>" +
                 * matcher.group() + "\" starting at index " +
                 * matcher.start() + " and ending at index " +
                 * matcher.end());
                 */
                matchedindex.put(matcher.end(), matcher.group());
                break;
              }
            }
          }
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      System.out.println(ex.toString() + "");
      if (LogUtil.isDebugEnabled(LOG_NAME)) {
        // System.out.println("Javadoc exception==>" + ex.toString());
        LogUtil.debug(CLASS_NAME, "Pattern==>", " " + ex.getStackTrace(), LOG_NAME);
      }
    }
  }
  @Override
  public void enterClassDeclaration(ClassDeclarationContext ctx) {

    boolean patternFound = false;
    conditionText = new StringBuffer();
    patternText = new StringBuffer();
    // System.out.println("Class Data ==>"+tokens.getText());
    if (ctx == null || ctx.Identifier() == null) {
      return;
    }
    // System.out.println("Class name==>"+ ctx.Identifier().getText());
    if (LogUtil.isDebugEnabled(LOG_NAME)) {
      LogUtil.debug(CLASS_NAME, "", "Class name==>" + ctx.Identifier().getText(), LOG_NAME);
    }
    // getJavaDocMatch();

    className = ctx.Identifier().getText();

    if (className.toLowerCase().indexOf("processfacade") != -1
        || className.toLowerCase().indexOf("processdelegate") != -1) {
      conditionText.append(
          "\nProcessCalls References are found. Class : " + ctx.Identifier().getText() + "\n");
      patternText.append(
          "\nProcessCalls References are found. Class : " + ctx.Identifier().getText() + "\n");
    }

    conditionText.append("\n Class name-->" + ctx.Identifier().getText() + "\n");

    if (searchPatterns != null) {

      for (String searchKeyword : searchPatterns) {

        String actualPropertyValue = "";
        if (messageMap != null && messageMap.get(searchKeyword) != null) {
          actualPropertyValue = " [" + messageMap.get(searchKeyword) + "] ";
        }
        // System.out.println("SearchKeyword ==> "+searchKeyword+" =
        // "+rewriter.getText().toUpperCase().contains(searchKeyword.toUpperCase()));
        if (searchKeyword != null) {
          try {
            String keywordWOQuote = Pattern.quote(searchKeyword);
            pattern = Pattern.compile(keywordWOQuote, Pattern.CASE_INSENSITIVE);
            System.out.println(pattern.compile(keywordWOQuote));
            // Need to add pattern for finding keyword
            // if(rewriter.getText().indexOf(searchKeyword)!=-1) {
            if (pattern.matcher(rewriter.getText()).find()) {
              conditionText.append(
                  "Pattern Matched for searchPattern-->"
                      + searchKeyword
                      + actualPropertyValue
                      + "\n");
              actClassName = ctx.Identifier().getText();
              patternText.append("\n Class name-->" + className + "\n");
              patternText.append(
                  "Pattern Matched for searchPattern-->"
                      + searchKeyword
                      + actualPropertyValue
                      + "\n");

              // System.out.println("Pattern Matched for
              // searchPattern=="+searchKeyword+actualPropertyValue);
              if (LogUtil.isDebugEnabled(LOG_NAME)) {
                LogUtil.debug(
                    CLASS_NAME,
                    "enterClassDeclaration",
                    "Pattern Matched for searchPattern=" + searchKeyword + actualPropertyValue,
                    LOG_NAME);
              }
              patternFound = true;
            }
          } catch (Exception ex) {
            ex.printStackTrace();
          }
        }
      }
    }
    if (!patternFound) throw new PatternNotFoundException("Keyword not match");
  }