org.acmsl.antmake
Class AntMakeUtils

java.lang.Object
  |
  +--org.acmsl.antmake.AntMakeUtils

public abstract class AntMakeUtils
extends java.lang.Object

Provides some methods useful for managing AntMake-related logic.

Version:
$Revision: 1.9 $
Author:
Jose San Leandro Armend?riz

Field Summary
static java.io.File[] EMPTY_FILE_ARRAY
          Empty file array.
static org.apache.tools.ant.types.FileSet[] EMPTY_FILESET_ARRAY
          Empty fileset array.
protected static java.lang.String[] EMPTY_STRING_ARRAY
          An empty String array.
 
Constructor Summary
protected AntMakeUtils()
          Protected constructor to avoid accidental instantiation.
 
Method Summary
protected  org.acmsl.commons.regexpplugin.Helper createHelper()
          Creates a helper instance.
 java.lang.String[] findIncludedFiles(org.apache.tools.ant.types.FileSet fileSet, org.apache.tools.ant.Project project)
          Retrieves the paths of the files included by given fileset.
static AntMakeUtils getInstance()
          Retrieves a AntMakeUtils instance.
 java.lang.String getLeafFolder(java.lang.String path)
          Retrieves the leaf folder of to given path.
protected static java.lang.ref.WeakReference getReference()
          Retrieves the weak reference.
 java.lang.String[] getSubfolders(java.lang.String path)
          Splits given path into its subfolders.
 void log(org.apache.tools.ant.Task task, java.lang.String message, int level)
          Logs a concrete message using given task.
 java.io.File[] mergeFiles(org.apache.tools.ant.types.FileSet[] fileSets, java.io.File folder, org.apache.tools.ant.Task task)
          Retrieves the files contained in given filesets, and copies them to given folder.
 java.lang.String replaceAll(java.lang.String input, java.lang.String pattern, java.lang.String replacement)
          Replaces all ocurrences of a pattern with an alternative text inside given input.
protected static void setReference(AntMakeUtils utils)
          Specifies a new weak reference.
 java.lang.String[] split(java.lang.String input, java.lang.String separator)
          Divides given input into tokens delimited by given separator.
 org.apache.tools.ant.types.FileSet toFileSet(java.lang.String location, org.apache.tools.ant.Project project, java.lang.String[] inFilters, java.lang.String[] outFilters)
          Builds a FileSet for given location, taking all specified file types.
 org.apache.tools.ant.types.FileSet[] toFileSets(org.apache.tools.ant.types.Path path, java.lang.String[] inFilters, java.lang.String[] outFilters)
          Translates given path to a collection of filesets.
 java.lang.String toPackage(java.lang.String folder)
          Retrieves the package name associated to given relative folder.
 java.lang.String toRelativeFolder(java.lang.String packageName)
          Retrieves the relative folder associated to given package name.
 java.lang.String toSpecificPackage(java.lang.String folder)
          Retrieves the specific package associated to given relative folder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_FILESET_ARRAY

public static final org.apache.tools.ant.types.FileSet[] EMPTY_FILESET_ARRAY
Empty fileset array.


EMPTY_FILE_ARRAY

public static final java.io.File[] EMPTY_FILE_ARRAY
Empty file array.


EMPTY_STRING_ARRAY

protected static final java.lang.String[] EMPTY_STRING_ARRAY
An empty String array.

Constructor Detail

AntMakeUtils

protected AntMakeUtils()
Protected constructor to avoid accidental instantiation.

Method Detail

setReference

protected static void setReference(AntMakeUtils utils)
Specifies a new weak reference.

Parameters:
utils - the utils instance to use.

getReference

protected static java.lang.ref.WeakReference getReference()
Retrieves the weak reference.

Returns:
such reference.

getInstance

public static AntMakeUtils getInstance()
Retrieves a AntMakeUtils instance.

Returns:
such instance.

toFileSets

public org.apache.tools.ant.types.FileSet[] toFileSets(org.apache.tools.ant.types.Path path,
                                                       java.lang.String[] inFilters,
                                                       java.lang.String[] outFilters)
Translates given path to a collection of filesets.

Parameters:
path - the path to translate.
inFilters - the included file filters, for retrieving files through descendent folders recursively.
outFilters - the excluded file filters.
Returns:
the filesets.

toFileSet

public org.apache.tools.ant.types.FileSet toFileSet(java.lang.String location,
                                                    org.apache.tools.ant.Project project,
                                                    java.lang.String[] inFilters,
                                                    java.lang.String[] outFilters)
Builds a FileSet for given location, taking all specified file types.

Parameters:
location - the location.
project - the project.
inFilters - the included file filters, for retrieving files through descendent folders recursively.
outFilters - the excluded file filters.
Returns:
the fileset.

findIncludedFiles

public java.lang.String[] findIncludedFiles(org.apache.tools.ant.types.FileSet fileSet,
                                            org.apache.tools.ant.Project project)
Retrieves the paths of the files included by given fileset.

Parameters:
fileSet - the fileset.
project - the project.
Returns:
the included files.

mergeFiles

public java.io.File[] mergeFiles(org.apache.tools.ant.types.FileSet[] fileSets,
                                 java.io.File folder,
                                 org.apache.tools.ant.Task task)
                          throws AntMakeException
Retrieves the files contained in given filesets, and copies them to given folder.

Parameters:
fileSets - such filesets.
folder - the destination folder.
task - the Ant task.
Returns:
the files.
Throws:
AntMakeException - if there's some problem merging the files

toPackage

public java.lang.String toPackage(java.lang.String folder)
Retrieves the package name associated to given relative folder.

Parameters:
folder - the folder.
Returns:
the associated package name.

getLeafFolder

public java.lang.String getLeafFolder(java.lang.String path)
Retrieves the leaf folder of to given path.

Parameters:
path - the path.
Returns:
the leaf folder.

toSpecificPackage

public java.lang.String toSpecificPackage(java.lang.String folder)
Retrieves the specific package associated to given relative folder.

Parameters:
folder - the folder.
Returns:
such package name.

toRelativeFolder

public java.lang.String toRelativeFolder(java.lang.String packageName)
Retrieves the relative folder associated to given package name.

Parameters:
packageName - the package name.
Returns:
the associated folder.

replaceAll

public java.lang.String replaceAll(java.lang.String input,
                                   java.lang.String pattern,
                                   java.lang.String replacement)
Replaces all ocurrences of a pattern with an alternative text inside given input.

Parameters:
input - the original text.
pattern - to identify what to replace.
replacement - the replacement.
Returns:
the text with replacements.

getSubfolders

public java.lang.String[] getSubfolders(java.lang.String path)
Splits given path into its subfolders.

Parameters:
path - the path to split.
Returns:
the subfolders.

split

public java.lang.String[] split(java.lang.String input,
                                java.lang.String separator)
Divides given input into tokens delimited by given separator.

Parameters:
input - the input.
Returns:
its tokens.

createHelper

protected org.acmsl.commons.regexpplugin.Helper createHelper()
Creates a helper instance.

Returns:
such instance.

log

public void log(org.apache.tools.ant.Task task,
                java.lang.String message,
                int level)
Logs a concrete message using given task.

Parameters:
task - the task to use to log the message.
message - the message to log.
level - the log level the message is associated to.


Copyright © 2004 ACM S.L.. All Rights Reserved.