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

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.bcel
Class ClassFileSetCheck  view ClassFileSetCheck download ClassFileSetCheck.java

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended bycom.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended bycom.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
              extended bycom.puppycrawl.tools.checkstyle.bcel.ClassFileSetCheck
All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable, com.puppycrawl.tools.checkstyle.api.FileSetCheck, IObjectSetVisitor

public class ClassFileSetCheck
extends com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
implements IObjectSetVisitor

Checks a set of class files using BCEL


Field Summary
private  java.util.Set mAllChecks
          all the registered checks
private  com.puppycrawl.tools.checkstyle.api.Context mChildContext
          context of child components
private  java.lang.ClassLoader mClassLoader
          class loader to resolve classes with.
private  com.puppycrawl.tools.checkstyle.ModuleFactory mModuleFactory
          a factory for creating submodules (i.e.
private  java.util.Set mObjectSetVisitors
          all visitors for IObjectSetVisitor visits
private  java.util.Set mTreeVisitors
          visitors for BCEL parse tree walk
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
 
Constructor Summary
ClassFileSetCheck()
          Creates a new ClassFileSetCheck instance.
 
Method Summary
private  java.util.Set extractJavaClasses(java.io.File aFile)
          Extracts the JavaClasses from .class, .zip, and .jar files.
private  java.util.Set extractJavaClasses(java.io.File[] aFiles)
          Gets the set of all JavaClasses within a set of Files.
 void finishLocalSetup()
          Provides a hook to finish the part of this compoent's setup that was not handled by the bean introspection.
private  void fireErrors()
          Notify all listeners about the errors in a file.
private  java.util.Set getObjectSetVisitors()
          Gets the set of all visitors for all the checks.
private  org.apache.bcel.classfile.Visitor getTreeVisitor()
          Gets the visitor for a parse tree walk.
 void leaveObject(java.lang.Object aObject)
          Finish the visit an object.
 void leaveSet(java.util.Set aSet)
          Finish the visit of a set.
 void process(java.io.File[] aFiles)
          Processes a set of files and fires errors to the MessageDispatcher.
private  void registerCheck(AbstractCheckVisitor aCheck)
          Register a check.
private  void registerVisitors()
          Registers all the visitors for IObjectSetVisitor visits, and for tree walk visits.
 void setClassLoader(java.lang.ClassLoader aClassLoader)
          Stores the class loader and makes it the Repository's class loader.
 void setModuleFactory(com.puppycrawl.tools.checkstyle.ModuleFactory aModuleFactory)
          Sets the module factory for creating child modules (Checks).
 void setupChild(com.puppycrawl.tools.checkstyle.api.Configuration aChildConf)
          Instantiates, configures and registers a Check that is specified in the provided configuration.
 void visitObject(java.lang.Object aObject)
          Visit an object.
 void visitSet(java.util.Set aSet)
          Visit a set itself.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
destroy, filter, fireErrors, getMessageCollector, getMessageDispatcher, log, log, setFileExtensions, setMessageDispatcher
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, setSeverity
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, getConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.puppycrawl.tools.checkstyle.api.Configurable
configure
 
Methods inherited from interface com.puppycrawl.tools.checkstyle.api.Contextualizable
contextualize
 

Field Detail

mTreeVisitors

private final java.util.Set mTreeVisitors
visitors for BCEL parse tree walk


mAllChecks

private final java.util.Set mAllChecks
all the registered checks


mObjectSetVisitors

private final java.util.Set mObjectSetVisitors
all visitors for IObjectSetVisitor visits


mClassLoader

private java.lang.ClassLoader mClassLoader
class loader to resolve classes with.


mChildContext

private com.puppycrawl.tools.checkstyle.api.Context mChildContext
context of child components


mModuleFactory

private com.puppycrawl.tools.checkstyle.ModuleFactory mModuleFactory
a factory for creating submodules (i.e. the Checks)

Constructor Detail

ClassFileSetCheck

public ClassFileSetCheck()
Creates a new ClassFileSetCheck instance. Initializes the acceptable file extensions.

Method Detail

setClassLoader

public void setClassLoader(java.lang.ClassLoader aClassLoader)
Stores the class loader and makes it the Repository's class loader.


setModuleFactory

public void setModuleFactory(com.puppycrawl.tools.checkstyle.ModuleFactory aModuleFactory)
Sets the module factory for creating child modules (Checks).


setupChild

public void setupChild(com.puppycrawl.tools.checkstyle.api.Configuration aChildConf)
                throws com.puppycrawl.tools.checkstyle.api.CheckstyleException
Instantiates, configures and registers a Check that is specified in the provided configuration.


finishLocalSetup

public void finishLocalSetup()
Description copied from class: com.puppycrawl.tools.checkstyle.api.AutomaticBean
Provides a hook to finish the part of this compoent's setup that was not handled by the bean introspection.

The default implementation does nothing.


registerCheck

private void registerCheck(AbstractCheckVisitor aCheck)
Register a check.


process

public void process(java.io.File[] aFiles)
Description copied from interface: com.puppycrawl.tools.checkstyle.api.FileSetCheck
Processes a set of files and fires errors to the MessageDispatcher. The file set to process might contain files that are not interesting to the FileSetCheck. Such files should be ignored, no error message should be fired for them. For example a FileSetCheck that checks java files should ignore html or properties files. Once processiong is done, it is highly recommended to call for the destroy method to close and remove the listeners.

Specified by:
process in interface com.puppycrawl.tools.checkstyle.api.FileSetCheck

getTreeVisitor

private org.apache.bcel.classfile.Visitor getTreeVisitor()
Gets the visitor for a parse tree walk.


registerVisitors

private void registerVisitors()
Registers all the visitors for IObjectSetVisitor visits, and for tree walk visits.


getObjectSetVisitors

private java.util.Set getObjectSetVisitors()
Gets the set of all visitors for all the checks.


extractJavaClasses

private java.util.Set extractJavaClasses(java.io.File[] aFiles)
Gets the set of all JavaClasses within a set of Files.


visitSet

public void visitSet(java.util.Set aSet)
Description copied from interface: IObjectSetVisitor
Visit a set itself.

Specified by:
visitSet in interface IObjectSetVisitor

visitObject

public void visitObject(java.lang.Object aObject)
Description copied from interface: IObjectSetVisitor
Visit an object. Normally this is an object of the set.

Specified by:
visitObject in interface IObjectSetVisitor

leaveObject

public void leaveObject(java.lang.Object aObject)
Description copied from interface: IObjectSetVisitor
Finish the visit an object. Normally this is an object of the set.

Specified by:
leaveObject in interface IObjectSetVisitor

leaveSet

public void leaveSet(java.util.Set aSet)
Description copied from interface: IObjectSetVisitor
Finish the visit of a set.

Specified by:
leaveSet in interface IObjectSetVisitor

extractJavaClasses

private java.util.Set extractJavaClasses(java.io.File aFile)
                                  throws java.io.IOException
Extracts the JavaClasses from .class, .zip, and .jar files.


fireErrors

private void fireErrors()
Notify all listeners about the errors in a file. Calls MessageDispatcher.fireErrors() with all logged errors and than clears errors' list.