Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/puppycrawl/tools/checkstyle/bcel/AbstractCheckVisitor.java


1   //Tested with BCEL-5.1
2   //http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
3   
4   package com.puppycrawl.tools.checkstyle.bcel;
5   
6   import java.util.Set;
7   
8   import com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter;
9   import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
10  import com.puppycrawl.tools.checkstyle.api.LocalizedMessages;
11  
12  /**
13   * Abstract class for checks with visitors.
14   * @author Rick Giles
15   */
16  //TODO: Refactor with class Check
17  public abstract class AbstractCheckVisitor
18      extends AbstractViolationReporter
19      implements IObjectSetVisitor
20  {
21      /** the object for collecting messages. */
22      private LocalizedMessages mMessages;
23  
24      /** @see com.puppycrawl.tools.checkstyle.bcel.IParserCheck */
25      public org.apache.bcel.classfile.Visitor getClassFileVisitor()
26      {
27          return new EmptyClassFileVisitor();
28      }
29  
30      /**
31       * @see com.puppycrawl.tools.checkstyle.bcel.IParserCheck
32       */
33      public org.apache.bcel.generic.Visitor getGenericVisitor()
34      {
35          return new EmptyGenericVisitor();
36      }
37  
38       /**
39       * Initialse the check. This is the time to verify that the check has
40       * everything required to perform it job.
41       */
42      public void init()
43      {
44      }
45  
46      /**
47       * Destroy the check. It is being retired from service.
48       */
49      public void destroy()
50      {
51      }
52  
53      /**
54       * Set the global object used to collect messages.
55       * @param aMessages the messages to log with
56       */
57      public final void setMessages(LocalizedMessages aMessages)
58      {
59          mMessages = aMessages;
60      }
61  
62      /**
63       * Log an error message.
64       *
65       * @param aLine the line number where the error was found
66       * @param aKey the message that describes the error
67       * @param aArgs the details of the message
68       *
69       * @see java.text.MessageFormat
70       */
71      protected final void log(int aLine, String aKey, Object aArgs[])
72      {
73          mMessages.add(
74              new LocalizedMessage(
75                  aLine,
76                  getMessageBundle(),
77                  aKey,
78                  aArgs,
79                  getSeverityLevel(),
80                  this.getClass()));
81      }
82  
83      /**
84       * @see com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
85       */
86      protected void log(int aLine, int aCol, String aKey, Object[] aArgs)
87      {
88      }
89  
90      /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
91      public void visitObject(Object aObject)
92      {
93      }
94  
95      /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
96      public void leaveObject(Object aObject)
97      {
98      }
99  
100     /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
101     public void visitSet(Set aJavaClassDefs)
102     {
103     }
104 
105     /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
106     public void leaveSet(Set aJavaClassDefs)
107     {
108     }
109 
110     /**
111      * Gets the deep BCEL visitor.
112      * @return the deep BCEL visitor for this check.
113      */
114     public abstract IDeepVisitor getVisitor();
115 }