org.acmsl.contractchecker
Class ContractCheckerDoclet

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.Task
              |
              +--com.thoughtworks.qdox.ant.AbstractQdoxTask
                    |
                    +--org.acmsl.contractchecker.ContractCheckerDoclet

public class ContractCheckerDoclet
extends com.thoughtworks.qdox.ant.AbstractQdoxTask

QDox doclet for retrieving methods' pre- and post-conditions.

Version:
$Revision: 1.8 $
Author:
Jose San Leandro

Field Summary
static java.lang.String DEFAULT_VIOLATION_EXCEPTION
          The default exception.
protected static ContractCheckerAspectTemplate[] EMPTY_ASPECTTEMPLATE_ARRAY
          Cached empty contractcheckeraspecttemplate array.
protected static com.thoughtworks.qdox.model.JavaClass[] EMPTY_JAVACLASS_ARRAY
          Cached empty javaclass array.
protected static com.thoughtworks.qdox.model.JavaMethod[] EMPTY_JAVAMETHOD_ARRAY
          Cached empty javamethod array.
static java.lang.String PRECONDITION_TAG
          The precondition tag.
 
Fields inherited from class com.thoughtworks.qdox.ant.AbstractQdoxTask
allClasses, allSources, fileMap
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
ContractCheckerDoclet()
           
 
Method Summary
protected  void buildFileSets()
          Builds the file sets.
protected  ContractCheckerAspectTemplate buildTemplate(com.thoughtworks.qdox.model.JavaClass javaClass, ContractCheckerAspectTemplateFactory factory, java.lang.String defaultException)
          Builds a ContractCheckerAspectTemplate from information provided by given class.
protected  ContractCheckerAspectTemplate buildTemplate(java.lang.String name, java.lang.String qualifiedName, ContractCheckerAspectTemplateFactory factory, java.lang.String defaultException, ContractCheckerUtils contractCheckerUtils)
          Builds a ContractCheckerAspectTemplate from information provided by given class.
protected  ContractCheckerAspectTemplate[] buildTemplates(java.util.Collection classes, ContractCheckerAspectTemplateFactory factory, java.lang.String defaultException)
          Builds the templates for given classes.
 void execute()
          Tag information retrieval starting point.
protected  java.util.Collection findGuardedClasses(java.util.Collection classes)
          Finds the guarded classes from given collection.
protected static com.thoughtworks.qdox.model.JavaMethod[] findGuardedMethods(com.thoughtworks.qdox.model.JavaMethod[] methods, boolean stopOnFirst)
          Finds the guarded method from given collection.
 org.apache.tools.ant.types.Path getInput()
          Retrieves the input path.
 java.io.File getOutputfolder()
          Retrieves the output folder.
 java.lang.String getTemplatefactoryclass()
          Retrieves the template factory class.
 java.lang.String getViolationexception()
          Retrieves the contract violation exception.
protected  ContractCheckerAspectTemplateFactory instantiateFactory(java.lang.String className)
          Creates the factory instance.
protected  void processClass(com.thoughtworks.qdox.model.JavaClass javaClass)
          Processes given class.
protected  void processClasses(com.thoughtworks.qdox.model.JavaClass[] classes)
          Processes given classes.
protected  void processSource(com.thoughtworks.qdox.model.JavaSource source)
          Processes given source.
protected  void processSources(com.thoughtworks.qdox.model.JavaSource[] sources)
          Processes given sources.
 void setInput(org.apache.tools.ant.types.Path input)
          Specifies the input path.
 void setOutputfolder(java.io.File folder)
          Specifies the output folder.
 void setTemplatefactoryclass(java.lang.String factoryClass)
          Specifies the template factory class.
 void setViolationexception(java.lang.String exception)
          Specifies the contract violation exception.
protected  boolean writeTemplates(ContractCheckerAspectTemplate[] templates, java.io.File outputFolder)
          Writes given templates.
 
Methods inherited from class com.thoughtworks.qdox.ant.AbstractQdoxTask
addFileset, buildFileMap, buildFileMap, createDocletTagFactory, validateAttributes
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRECONDITION_TAG

public static final java.lang.String PRECONDITION_TAG
The precondition tag.

See Also:
Constant Field Values

DEFAULT_VIOLATION_EXCEPTION

public static final java.lang.String DEFAULT_VIOLATION_EXCEPTION
The default exception.


EMPTY_JAVACLASS_ARRAY

protected static final com.thoughtworks.qdox.model.JavaClass[] EMPTY_JAVACLASS_ARRAY
Cached empty javaclass array.


EMPTY_JAVAMETHOD_ARRAY

protected static final com.thoughtworks.qdox.model.JavaMethod[] EMPTY_JAVAMETHOD_ARRAY
Cached empty javamethod array.


EMPTY_ASPECTTEMPLATE_ARRAY

protected static final ContractCheckerAspectTemplate[] EMPTY_ASPECTTEMPLATE_ARRAY
Cached empty contractcheckeraspecttemplate array.

Constructor Detail

ContractCheckerDoclet

public ContractCheckerDoclet()
Method Detail

setOutputfolder

public void setOutputfolder(java.io.File folder)
Specifies the output folder.

Parameters:
folder - the output folder.

getOutputfolder

public java.io.File getOutputfolder()
Retrieves the output folder.

Returns:
such folder.

setTemplatefactoryclass

public void setTemplatefactoryclass(java.lang.String factoryClass)
Specifies the template factory class.

Parameters:
factoryClass - the factory class.

getTemplatefactoryclass

public java.lang.String getTemplatefactoryclass()
Retrieves the template factory class.

Returns:
such class.

setInput

public void setInput(org.apache.tools.ant.types.Path input)
Specifies the input path.

Parameters:
input - the input.

getInput

public org.apache.tools.ant.types.Path getInput()
Retrieves the input path.

Returns:
such path.

setViolationexception

public void setViolationexception(java.lang.String exception)
Specifies the contract violation exception.

Parameters:
exception - such exception.

getViolationexception

public java.lang.String getViolationexception()
Retrieves the contract violation exception.

Returns:
such exception.

buildFileSets

protected void buildFileSets()
Builds the file sets.


processSources

protected void processSources(com.thoughtworks.qdox.model.JavaSource[] sources)
Processes given sources.

Overrides:
processSources in class com.thoughtworks.qdox.ant.AbstractQdoxTask
Parameters:
sources - the source code to process.

processSource

protected void processSource(com.thoughtworks.qdox.model.JavaSource source)
Processes given source.

Parameters:
source - the source to process.

processClasses

protected void processClasses(com.thoughtworks.qdox.model.JavaClass[] classes)
Processes given classes.

Overrides:
processClasses in class com.thoughtworks.qdox.ant.AbstractQdoxTask
Parameters:
classes - the classes to process.

processClass

protected void processClass(com.thoughtworks.qdox.model.JavaClass javaClass)
Processes given class.

Parameters:
javaClass - the class to process.

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Tag information retrieval starting point.

Overrides:
execute in class com.thoughtworks.qdox.ant.AbstractQdoxTask
Throws:
org.apache.tools.ant.BuildException - if the source code cannot be processed.

instantiateFactory

protected ContractCheckerAspectTemplateFactory instantiateFactory(java.lang.String className)
                                                           throws ContractCheckerException
Creates the factory instance.

Parameters:
className - the factory class name.
Returns:
the factory instance.
Throws:
ContractCheckerException - if the factory cannot be instantiated.

findGuardedClasses

protected java.util.Collection findGuardedClasses(java.util.Collection classes)
Finds the guarded classes from given collection.

Parameters:
classes - the complete class set.
Returns:
the subset consisting only in guarded classes.

findGuardedMethods

protected static com.thoughtworks.qdox.model.JavaMethod[] findGuardedMethods(com.thoughtworks.qdox.model.JavaMethod[] methods,
                                                                             boolean stopOnFirst)
Finds the guarded method from given collection.

Parameters:
methods - the complete method set.
stopOnFirst - whether to stop on first guarded method. Therefore, if it's set to true the resulting array will contain 0 or 1 element.
Returns:
the subset consisting only in guarded methods.

buildTemplates

protected ContractCheckerAspectTemplate[] buildTemplates(java.util.Collection classes,
                                                         ContractCheckerAspectTemplateFactory factory,
                                                         java.lang.String defaultException)
Builds the templates for given classes.

Parameters:
classes - the classes.
factory - the template factory.
defaultException - the default exception.
Returns:
the associated contract-checker templates.

buildTemplate

protected ContractCheckerAspectTemplate buildTemplate(com.thoughtworks.qdox.model.JavaClass javaClass,
                                                      ContractCheckerAspectTemplateFactory factory,
                                                      java.lang.String defaultException)
Builds a ContractCheckerAspectTemplate from information provided by given class.

Parameters:
javaClass - the Java class.
factory - the template factory.
defaultException - the default exception.
Returns:
such kind of template.

buildTemplate

protected ContractCheckerAspectTemplate buildTemplate(java.lang.String name,
                                                      java.lang.String qualifiedName,
                                                      ContractCheckerAspectTemplateFactory factory,
                                                      java.lang.String defaultException,
                                                      ContractCheckerUtils contractCheckerUtils)
Builds a ContractCheckerAspectTemplate from information provided by given class.

Parameters:
name - the Java class' name.
qualifiedName - the Java class' qualified name.
factory - the template factory.
defaultException - the default exception.
contractCheckerUtils - the helper instance.
Returns:
such kind of template.

writeTemplates

protected boolean writeTemplates(ContractCheckerAspectTemplate[] templates,
                                 java.io.File outputFolder)
                          throws ContractCheckerException
Writes given templates.

Parameters:
templates - the templates to write.
outputFolder - the output folder.
Returns:
true if the templates are written successfully.
Throws:
ContractCheckerException - if the template cannot be written for any reason.


Copyright © 2003-2004 ACM S.L.. All Rights Reserved.