org.apache.tools.ant.taskdefs.optional.metamata
Class AbstractMetamataTask

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.Task
              |
              +--org.apache.tools.ant.taskdefs.optional.metamata.AbstractMetamataTask
Direct Known Subclasses:
MAudit, MMetrics

public abstract class AbstractMetamataTask
extends Task

Somewhat abstract framework to be used for other metama 2.0 tasks. This should include, audit, metrics, cover and mparse. For more information, visit the website at www.metamata.com

Author:
Stephane Bailliez

Field Summary
protected  Path classPath
          The user classpath to be provided.
protected  CommandlineJava cmdl
          the command line used to run MAudit
protected  java.util.Vector fileSets
          the set of files to be audited
protected  java.util.Hashtable includedFiles
           
protected  java.io.File metamataHome
          Metamata home directory.
protected  java.io.File optionsFile
          the options file where are stored the command line options
protected  Path sourcePath
          the path to the source file
 
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
  AbstractMetamataTask()
           
protected AbstractMetamataTask(java.lang.String className)
          initialize the task with the classname of the task to run
 
Method Summary
protected static void addAllVector(java.util.Vector dest, java.util.Enumeration files)
          convenient method for JDK 1.1.
 void addFileSet(FileSet fs)
          The java files or directory to audit.
protected  void checkOptions()
          validate options set
protected  void cleanUp()
          clean up all the mess that we did with temporary objects
 Path createClasspath()
          Sets the class path (also source path unless one explicitly set).
 Commandline.Argument createJvmarg()
          Additional optional parameters to pass to the JVM.
 Path createSourcepath()
          Sets the source path.
protected abstract  ExecuteStreamHandler createStreamHandler()
          create a stream handler that will be used to get the output since metamata tools do not report with convenient files such as XML.
protected  java.io.File createTmpFile()
           
 void execute()
          execute the command line
protected  void execute0(ExecuteStreamHandler handler)
          execute the process with a specific handler
protected  void generateOptionsFile(java.io.File tofile, java.util.Vector options)
           
protected  java.util.Hashtable getFileMapping()
           
protected  java.io.File getMetamataJar(java.io.File home)
          return the location of the jar file used to run
protected abstract  java.util.Vector getOptions()
          return all options of the command line as string elements
protected  java.util.Hashtable scanSources(java.util.Hashtable map)
           
protected  java.util.Hashtable scanSources(java.util.Hashtable mapping, java.lang.String[] entries)
           
 void setHome(java.io.File value)
          the metamata.home property to run all tasks.
 void setMaxmemory(java.lang.String max)
          Set the maximum memory for the JVM; optional.
 void setMetamatahome(java.io.File value)
          The home directory containing the Metamata distribution; required
protected  void setUp()
          check the options and build the command line
 
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

classPath

protected Path classPath
The user classpath to be provided. It matches the -classpath of the command line. The classpath must includes both the .class and the .java files for accurate audit.


sourcePath

protected Path sourcePath
the path to the source file


metamataHome

protected java.io.File metamataHome
Metamata home directory. It will be passed as a metamata.home property and should normally matches the environment property META_HOME set by the Metamata installer.


cmdl

protected CommandlineJava cmdl
the command line used to run MAudit


fileSets

protected java.util.Vector fileSets
the set of files to be audited


optionsFile

protected java.io.File optionsFile
the options file where are stored the command line options


includedFiles

protected java.util.Hashtable includedFiles
Constructor Detail

AbstractMetamataTask

public AbstractMetamataTask()

AbstractMetamataTask

protected AbstractMetamataTask(java.lang.String className)
initialize the task with the classname of the task to run

Method Detail

setHome

public void setHome(java.io.File value)
the metamata.home property to run all tasks.


setMetamatahome

public void setMetamatahome(java.io.File value)
The home directory containing the Metamata distribution; required


createClasspath

public Path createClasspath()
Sets the class path (also source path unless one explicitly set). Overrides METAPATH/CLASSPATH environment variables.


createSourcepath

public Path createSourcepath()
Sets the source path. Overrides the SOURCEPATH environment variable.


createJvmarg

public Commandline.Argument createJvmarg()
Additional optional parameters to pass to the JVM. You can avoid using the <jvmarg> by adding these empty entries to metamata.properties located at ${metamata.home}/bin
metamata.classpath=
 metamata.sourcepath=
 metamata.baseclasspath=
 


setMaxmemory

public void setMaxmemory(java.lang.String max)
Set the maximum memory for the JVM; optional. -mx or -Xmx depending on VM version


addFileSet

public void addFileSet(FileSet fs)
The java files or directory to audit. Whatever the filter is, only the files that end with .java will be included for processing. Note that the base directory used for the fileset MUST be the root of the source files otherwise package names deduced from the file path will be incorrect.


execute

public void execute()
             throws BuildException
execute the command line

Overrides:
execute in class Task
Throws:
BuildException - if something goes wrong with the build

setUp

protected void setUp()
              throws BuildException
check the options and build the command line

BuildException

createStreamHandler

protected abstract ExecuteStreamHandler createStreamHandler()
create a stream handler that will be used to get the output since metamata tools do not report with convenient files such as XML.


execute0

protected void execute0(ExecuteStreamHandler handler)
                 throws BuildException
execute the process with a specific handler

BuildException

cleanUp

protected void cleanUp()
clean up all the mess that we did with temporary objects


getMetamataJar

protected final java.io.File getMetamataJar(java.io.File home)
return the location of the jar file used to run


checkOptions

protected void checkOptions()
                     throws BuildException
validate options set

BuildException

getOptions

protected abstract java.util.Vector getOptions()
return all options of the command line as string elements


generateOptionsFile

protected void generateOptionsFile(java.io.File tofile,
                                   java.util.Vector options)
                            throws BuildException
BuildException

getFileMapping

protected java.util.Hashtable getFileMapping()

addAllVector

protected static final void addAllVector(java.util.Vector dest,
                                         java.util.Enumeration files)
convenient method for JDK 1.1. Will copy all elements from src to dest


createTmpFile

protected final java.io.File createTmpFile()

scanSources

protected java.util.Hashtable scanSources(java.util.Hashtable map)
Returns:
the list of .java files (as their absolute path) that should be audited.

scanSources

protected java.util.Hashtable scanSources(java.util.Hashtable mapping,
                                          java.lang.String[] entries)


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.