org.apache.avalon.tools.model
Class Context

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.Task
          extended byorg.apache.avalon.tools.model.Context

public class Context
extends org.apache.tools.ant.Task

A context contains infomation about a particular project build environment including the mapping of inital structure to the immutable magic structure.

Version:
$Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
Author:
Avalon Development Team

Field Summary
static String BUILD
          The value of the immutable target build directory name.
static String CLASSES
          The value of the immutable target classes directory name.
static String DELIVERABLES
          The value of the immutable target deliverables directory name.
static String DOCS
          The value of the immutable target docs directory name.
static String ETC_KEY
          The value of the immutable project.etc key.
static String ETC_VALUE
          The value of the default project.etc default value.
static String KEY
          The reference name of the context object withing the current ant project.
static String PROJECT_KEY
          The property name of the project key.
static String SRC_CONFIG
          The value of the default project.src.cofig property value.
static String SRC_CONFIG_KEY
          The value of the immutable project.src.config key.
static String SRC_KEY
          The value of the immutable project.src property key.
static String SRC_MAIN
          The value of the default project.src.main property value.
static String SRC_MAIN_KEY
          The value of the immutable project.src.main key.
static String SRC_TEST
          The value of the default project.src.test property value.
static String SRC_TEST_KEY
           
static String SRC_VALUE
          The value of the default project.src property value.
static String TARGET
          The value of the immutable target directory name.
static String TEMP
          The value of the immutable target temp directory name.
static String TEST
          The value of the immutable target test directory name.
static String TEST_CLASSES
          The value of the immutable target test classes directory name.
static String TEST_REPORTS
          The value of the immutable target test reports directory name.
 
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
Context()
           
 
Method Summary
 void execute()
          Creation of the context and association ofnthe context under the KEY key.
 File getBuildDirectory()
          Reuturn the project target build directory.
 File getBuildPath(String key)
          Return a build path matching a supplied key.
static File getCanonicalFile(File file)
          Return the concatonal variant of a file.
static File getCanonicalFile(File file, boolean create)
          Return the concatonal variant of a file and ensure that the parent directory path is created.
static String getCanonicalPath(File file)
          Return the concatonal path of a file.
 File getClassesDirectory()
          Reuturn the project classes directory.
static Context getContext(org.apache.tools.ant.Project project)
          Reuturn the context object for the project.
 File getDeliverablesDirectory()
          Reuturn the project deliverables directory.
 File getDocsDirectory()
          Reuturn the project docs directory.
 File getEtcDirectory()
          Reuturn the project etc directory.
static File getFile(File root, String path)
          Return a file using a supplied root and path.
static File getFile(File root, String path, boolean create)
          Return a file using a supplied root and path.
 String getKey()
          Return the unique key for this project.
static String getSignature()
          Return the UTC YYMMDD.HHMMSSS signature.
static String getSignature(Date date)
          Return the UTC YYMMDD.HHMMSSS signature of a date.
 File getSrcDirectory()
          Reuturn the project src directory.
 File getTargetDirectory()
          Reuturn the project target directory.
 File getTempDirectory()
          Reuturn the project temp directory.
 File getTestClassesDirectory()
          Reuturn the project test classes directory.
 File getTestDirectory()
          Reuturn the project test directory.
 File getTestReportsDirectory()
          Reuturn the project test reports directory.
 File setBuildPath(String path)
          Reserve a path under the target directory.
 File setBuildPath(String key, String path)
          Reserve a path under the target directory.
 
Methods inherited from class org.apache.tools.ant.Task
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, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY

public static final String KEY
The reference name of the context object withing the current ant project.

See Also:
Constant Field Values

PROJECT_KEY

public static final String PROJECT_KEY
The property name of the project key.

See Also:
Constant Field Values

TARGET

public static final String TARGET
The value of the immutable target directory name.

See Also:
Constant Field Values

BUILD

public static final String BUILD
The value of the immutable target build directory name.

See Also:
Constant Field Values

CLASSES

public static final String CLASSES
The value of the immutable target classes directory name.

See Also:
Constant Field Values

DELIVERABLES

public static final String DELIVERABLES
The value of the immutable target deliverables directory name.

See Also:
Constant Field Values

TEST_CLASSES

public static final String TEST_CLASSES
The value of the immutable target test classes directory name.

See Also:
Constant Field Values

TEST_REPORTS

public static final String TEST_REPORTS
The value of the immutable target test reports directory name.

See Also:
Constant Field Values

TEMP

public static final String TEMP
The value of the immutable target temp directory name.

See Also:
Constant Field Values

TEST

public static final String TEST
The value of the immutable target test directory name.

See Also:
Constant Field Values

DOCS

public static final String DOCS
The value of the immutable target docs directory name.

See Also:
Constant Field Values

SRC_KEY

public static final String SRC_KEY
The value of the immutable project.src property key.

See Also:
Constant Field Values

SRC_VALUE

public static final String SRC_VALUE
The value of the default project.src property value.

See Also:
Constant Field Values

SRC_MAIN

public static final String SRC_MAIN
The value of the default project.src.main property value.

See Also:
Constant Field Values

SRC_MAIN_KEY

public static final String SRC_MAIN_KEY
The value of the immutable project.src.main key.

See Also:
Constant Field Values

SRC_CONFIG_KEY

public static final String SRC_CONFIG_KEY
The value of the immutable project.src.config key.

See Also:
Constant Field Values

SRC_CONFIG

public static final String SRC_CONFIG
The value of the default project.src.cofig property value.

See Also:
Constant Field Values

SRC_TEST_KEY

public static final String SRC_TEST_KEY
See Also:
Constant Field Values

SRC_TEST

public static final String SRC_TEST
The value of the default project.src.test property value.

See Also:
Constant Field Values

ETC_KEY

public static final String ETC_KEY
The value of the immutable project.etc key.

See Also:
Constant Field Values

ETC_VALUE

public static final String ETC_VALUE
The value of the default project.etc default value.

See Also:
Constant Field Values
Constructor Detail

Context

public Context()
Method Detail

getContext

public static Context getContext(org.apache.tools.ant.Project project)
Reuturn the context object for the project. If the project does not have a reference assigned to the name 'project.context' then a new context is created and assigned.

Parameters:
project - the current project
Returns:
the bound context

getFile

public static File getFile(File root,
                           String path)
Return a file using a supplied root and path. If the path is absolute an absolute file is retured relative to the supplied path otherwise the path is resolved relative to the supplied root directory.

Parameters:
root - the root directory
path - the absolute or relative file path
Returns:
the file instance

getFile

public static File getFile(File root,
                           String path,
                           boolean create)
Return a file using a supplied root and path. If the path is absolute an absolute file is retured relative to the supplied path otherwise the path is resolved relative to the supplied root directory. If the create parameter is TRUE then the file will be created if it does not exist.

Parameters:
root - the root directory
path - the absolute or relative file path
create - flag to indicate creation policy if the file does not exists
Returns:
the file instance

getCanonicalFile

public static File getCanonicalFile(File file)
                             throws org.apache.tools.ant.BuildException
Return the concatonal variant of a file.

Parameters:
file - the file argument
Returns:
the concatonal variant
Throws:
org.apache.tools.ant.BuildException

getCanonicalFile

public static File getCanonicalFile(File file,
                                    boolean create)
                             throws org.apache.tools.ant.BuildException
Return the concatonal variant of a file and ensure that the parent directory path is created.

Parameters:
file - the file argument
Returns:
the concatonal variant
Throws:
org.apache.tools.ant.BuildException

getCanonicalPath

public static String getCanonicalPath(File file)
                               throws org.apache.tools.ant.BuildException
Return the concatonal path of a file.

Parameters:
file - the file argument
Returns:
the concatonal path
Throws:
org.apache.tools.ant.BuildException

getSignature

public static String getSignature()
Return the UTC YYMMDD.HHMMSSS signature.

Returns:
the UTC date-stamp

getSignature

public static String getSignature(Date date)
Return the UTC YYMMDD.HHMMSSS signature of a date.

Parameters:
date - the date
Returns:
the UTC date-stamp signature

execute

public void execute()
Creation of the context and association ofnthe context under the KEY key.


getKey

public String getKey()
Return the unique key for this project.

Returns:
the project key

getSrcDirectory

public File getSrcDirectory()
Reuturn the project src directory.

Returns:
the src directory

getEtcDirectory

public File getEtcDirectory()
Reuturn the project etc directory.

Returns:
the etc directory

getTargetDirectory

public File getTargetDirectory()
Reuturn the project target directory.

Returns:
the target directory

getBuildDirectory

public File getBuildDirectory()
Reuturn the project target build directory.

Returns:
the target build directory

getDeliverablesDirectory

public File getDeliverablesDirectory()
Reuturn the project deliverables directory.

Returns:
the target deliverables directory

getClassesDirectory

public File getClassesDirectory()
Reuturn the project classes directory.

Returns:
the target classes directory

getTestClassesDirectory

public File getTestClassesDirectory()
Reuturn the project test classes directory.

Returns:
the target test classes directory

getTestReportsDirectory

public File getTestReportsDirectory()
Reuturn the project test reports directory.

Returns:
the target test reports directory

getTempDirectory

public File getTempDirectory()
Reuturn the project temp directory.

Returns:
the target temp directory

getTestDirectory

public File getTestDirectory()
Reuturn the project test directory.

Returns:
the target test directory

getDocsDirectory

public File getDocsDirectory()
Reuturn the project docs directory.

Returns:
the target docs directory

setBuildPath

public File setBuildPath(String path)
Reserve a path under the target directory.

Parameters:
path - the path to reserve

setBuildPath

public File setBuildPath(String key,
                         String path)
Reserve a path under the target directory.

Parameters:
key - the logic path identifier
path - the path to reserve

getBuildPath

public File getBuildPath(String key)
Return a build path matching a supplied key.

Returns:
the target path