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

Class AbstractMetamataTask

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 PathclassPath
The user classpath to be provided.
protected CommandlineJavacmdl
the command line used to run MAudit
protected VectorfileSets
the set of files to be audited
protected HashtableincludedFiles
protected FilemetamataHome
Metamata home directory.
protected FileoptionsFile
the options file where are stored the command line options
protected PathsourcePath
the path to the source file
Constructor Summary
AbstractMetamataTask()
protected AbstractMetamataTask(String className)
initialize the task with the classname of the task to run
Method Summary
protected static voidaddAllVector(Vector dest, Enumeration files)
convenient method for JDK 1.1.
voidaddFileSet(FileSet fs)
The java files or directory to audit.
protected voidcheckOptions()
validate options set
protected voidcleanUp()
clean up all the mess that we did with temporary objects
PathcreateClasspath()
Sets the class path (also source path unless one explicitly set).
Commandline.ArgumentcreateJvmarg()
Additional optional parameters to pass to the JVM.
PathcreateSourcepath()
Sets the source path.
protected abstract ExecuteStreamHandlercreateStreamHandler()
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 FilecreateTmpFile()
voidexecute()
execute the command line
protected voidexecute0(ExecuteStreamHandler handler)
execute the process with a specific handler
protected voidgenerateOptionsFile(File tofile, Vector options)
protected HashtablegetFileMapping()
protected FilegetMetamataJar(File home)
return the location of the jar file used to run
protected abstract VectorgetOptions()
return all options of the command line as string elements
protected HashtablescanSources(Hashtable map)
protected HashtablescanSources(Hashtable mapping, String[] entries)
voidsetHome(File value)
the metamata.home property to run all tasks.
voidsetMaxmemory(String max)
Set the maximum memory for the JVM; optional.
voidsetMetamatahome(File value)
The home directory containing the Metamata distribution; required
protected voidsetUp()
check the options and build the command line

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.

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 Detail

AbstractMetamataTask

public AbstractMetamataTask()

AbstractMetamataTask

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

Method Detail

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()
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()
execute the command line

execute0

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

generateOptionsFile

protected void generateOptionsFile(File tofile, Vector options)

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.

UNKNOWN: ignore="true"

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()
check the options and build the command line
Copyright