org.acmsl.antmake
Class FolderStructureHelper

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

public abstract class FolderStructureHelper
extends java.lang.Object

Provides some useful methods for managing the folder structure of a typical GNU Autotools-based Java project.

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

Constructor Summary
protected FolderStructureHelper()
          Protected constructor to avoid accidental instantiation.
 
Method Summary
 void copy(java.lang.String fileName, java.io.File destination, org.apache.tools.ant.Task task, java.lang.ClassLoader classLoader)
          Copies a file from the classpath to given location.
 void createFolderStructure(java.io.File newBaseFolder, java.io.File oldBaseFolder, java.io.File[] files, org.apache.tools.ant.Task task)
          Creates the basic folder structure starting from given folder.
protected  void createFolderStructure(java.io.File baseFolder, java.lang.String[] packageNames)
          Creates the basic folder structure starting from given folder and packages.
 java.io.File createTempFolder()
          Creates a temporary folder.
 java.io.InputStream findResource(java.lang.String resource, java.lang.ClassLoader classLoader)
          Retrieves the input stream to read a resource from the classpath visible to given class loader.
static FolderStructureHelper getInstance()
          Retrieves a FolderStructureHelper instance.
protected static java.lang.ref.WeakReference getReference()
          Retrieves the weak reference.
protected static void setReference(FolderStructureHelper helper)
          Specifies a new weak reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FolderStructureHelper

protected FolderStructureHelper()
Protected constructor to avoid accidental instantiation.

Method Detail

setReference

protected static void setReference(FolderStructureHelper helper)
Specifies a new weak reference.

Parameters:
helper - the helper instance to use.

getReference

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

Returns:
such reference.

getInstance

public static FolderStructureHelper getInstance()
Retrieves a FolderStructureHelper instance.

Returns:
such instance.

createFolderStructure

public void createFolderStructure(java.io.File newBaseFolder,
                                  java.io.File oldBaseFolder,
                                  java.io.File[] files,
                                  org.apache.tools.ant.Task task)
                           throws AntMakeException
Creates the basic folder structure starting from given folder.

Parameters:
newBaseFolder - the new base folder.
oldBaseFolder - the old base folder.
files - the files to include, which have to be relative to oldBaseFolder.
task - to be able to log messages.
Throws:
AntMakeException - if the structure cannot be created for some reason.

createFolderStructure

protected void createFolderStructure(java.io.File baseFolder,
                                     java.lang.String[] packageNames)
Creates the basic folder structure starting from given folder and packages.

Parameters:
baseFolder - the base folder.
packageNames - the package names.

createTempFolder

public java.io.File createTempFolder()
                              throws java.io.IOException
Creates a temporary folder.

Returns:
such folder.
Throws:
java.io.IOException - if the folder cannot be created.

copy

public void copy(java.lang.String fileName,
                 java.io.File destination,
                 org.apache.tools.ant.Task task,
                 java.lang.ClassLoader classLoader)
          throws java.io.IOException
Copies a file from the classpath to given location.

Parameters:
fileName - the file name.
destination - the destination folder.
task - the Ant task to print error messages.
classLoader - the optional class loader.
Throws:
java.io.IOException - if an abnormal situation takes place.

findResource

public java.io.InputStream findResource(java.lang.String resource,
                                        java.lang.ClassLoader classLoader)
Retrieves the input stream to read a resource from the classpath visible to given class loader.

Parameters:
resource - the resource to find.
classLoader - (optional) the class loader.
Returns:
such input stream, or null if the resource cannot be found.


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