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 be audited
protected  void checkOptions()
          validate options set
protected  void cleanUp()
          clean up all the mess that we did with temporary objects
 Path createClasspath()
          user classpath
 Commandline.Argument createJvmarg()
          Creates a nested jvmarg element.
 Path createSourcepath()
          create the source path for this task
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 static 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 scanFileSets()
           
 void setMaxmemory(java.lang.String max)
          -mx or -Xmx depending on VM version
 void setMetamatahome(java.io.File metamataHome)
          the metamata.home property to run all tasks.
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, 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

setMetamatahome

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

createClasspath

public Path createClasspath()
user classpath

createSourcepath

public Path createSourcepath()
create the source path for this task

createJvmarg

public Commandline.Argument createJvmarg()
Creates a nested jvmarg element.

setMaxmemory

public void setMaxmemory(java.lang.String max)
-mx or -Xmx depending on VM version

addFileSet

public void addFileSet(FileSet fs)
The java files or directory to be audited

execute

public void execute()
             throws BuildException
execute the command line
Overrides:
execute in class Task
Following copied from class: org.apache.tools.ant.Task
Throws:
BuildException - if someting goes wrong with the build

setUp

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

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

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

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

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 static final java.io.File createTmpFile()

scanFileSets

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


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.