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

Class AbstractMetamataTask

Known Direct Subclasses:
MAudit, MMetrics, MParse

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

Field Summary

protected Path
classPath
The user classpath to be provided.
protected CommandlineJava
cmdl
the command line used to run MAudit
protected Vector
fileSets
the set of files to be audited
protected Hashtable
includedFiles
protected File
metamataHome
Metamata home directory.
protected 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()
Sole constructor.
AbstractMetamataTask(String className)
initialize the task with the classname of the task to run

Method Summary

protected static void
addAllVector(Vector dest, 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 File
createTmpFile()
void
execute()
execute the command line
protected void
execute0(ExecuteStreamHandler handler)
execute the process with a specific handler
protected void
generateOptionsFile(File tofile, Vector options)
protected Hashtable
getFileMapping()
protected File
getMetamataJar(File home)
return the location of the jar file used to run
protected abstract Vector
getOptions()
return all options of the command line as string elements
protected Hashtable
scanSources(Hashtable map)
protected Hashtable
scanSources(Hashtable mapping, String[] entries)
void
setHome(File value)
the metamata.home property to run all tasks.
void
setMaxmemory(String max)
Set the maximum memory for the JVM; optional.
void
setMetamatahome(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

execute, getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType

Methods inherited from class org.apache.tools.ant.ProjectComponent

getProject, log, log, setProject

Field Details

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.

cmdl

protected CommandlineJava cmdl
the command line used to run MAudit

fileSets

protected Vector fileSets
the set of files to be audited

includedFiles

protected Hashtable includedFiles

metamataHome

protected 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.

optionsFile

protected File optionsFile
the options file where are stored the command line options

sourcePath

protected Path sourcePath
the path to the source file

Constructor Details

AbstractMetamataTask

public AbstractMetamataTask()
Sole constructor.

AbstractMetamataTask

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

Method Details

addAllVector

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

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.

checkOptions

protected void checkOptions()
            throws BuildException
validate options set

cleanUp

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

createClasspath

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

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=
 

createSourcepath

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

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.

createTmpFile

protected final File createTmpFile()

execute

public void execute()
            throws BuildException
execute the command line
Overrides:
execute in interface Task

execute0

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

generateOptionsFile

protected void generateOptionsFile(File tofile,
                                   Vector options)
            throws BuildException

getFileMapping

protected Hashtable getFileMapping()

getMetamataJar

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

getOptions

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

scanSources

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

scanSources

protected Hashtable scanSources(Hashtable mapping,
                                String[] entries)

setHome

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

setMaxmemory

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

setMetamatahome

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

setUp

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

Copyright B) 2000-2006 Apache Software Foundation. All Rights Reserved.