net.sf.ant4eclipse.ant.task.project
Class AbstractProjectBasedTask

java.lang.Object
  extended by Task
      extended by net.sf.ant4eclipse.ant.task.project.AbstractProjectBasedTask
Direct Known Subclasses:
AbstractGetProjectPathTask, AbstractPdeBuildTask, BuildPluginTask, ExecuteBuildersTask, GetReferencedProjectsTask

public abstract class AbstractProjectBasedTask
extends Task

Abstract base class for all project based tasks.


Constructor Summary
AbstractProjectBasedTask()
           Creates a new instance of type AbstractProjectBasedTask.
 
Method Summary
 void ensureJavaProject()
           Ensures that the set project is a java project.
 EclipseProject getEclipseProject()
           Returns the EclipseProject instance associated with this task.
 Workspace getWorkspace()
           Returns the currently associated workspace .
static boolean hasText(java.lang.String str)
           Check if a String has text.
 boolean isProjectNameSet()
           Returns true if the project name has been set.
 boolean isProjectSet()
           Returns true if the project has been set.
 boolean isWorkspaceSet()
           Returns whether a workspace has been set to this task.
 void requireWorkspaceAndProjectNameOrProjectSet()
           Requires that either the workspace and a project name or a project directory has been set.
 void requireWorkspaceSet()
           Requires that the workspace has been set.
 void setInitialiseWorkspace(boolean enable)
           Enables/disables the initial workspace initialisation.
 void setProject(java.io.File projectDirectory)
           Sets the project.
 void setProjectName(java.lang.String projectName)
           Sets the name of the project.
 void setWorkspace(java.io.File workspace)
          Sets the workspace for this task
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractProjectBasedTask

public AbstractProjectBasedTask()

Creates a new instance of type AbstractProjectBasedTask.

Method Detail

ensureJavaProject

public void ensureJavaProject()

Ensures that the set project is a java project. That means that the project must have the java project role. If the projet is not a java project, a BuildException will be thrown.


getEclipseProject

public EclipseProject getEclipseProject()

Returns the EclipseProject instance associated with this task.

Returns:
The EclipseProject instance associated with this task.
See Also:
ProjectBase.getEclipseProject()

setProjectName

public final void setProjectName(java.lang.String projectName)

Sets the name of the project.

Parameters:
projectName - the name of the project.
See Also:
ProjectBase.getEclipseProject()

isProjectNameSet

public final boolean isProjectNameSet()

Returns true if the project name has been set.

Returns:
true if the project name has been set.
See Also:
ProjectBase.getEclipseProject()

setProject

public final void setProject(java.io.File projectDirectory)

Sets the project.

Parameters:
projectDirectory - the project
See Also:
ProjectBase.getEclipseProject()

isProjectSet

public final boolean isProjectSet()

Returns true if the project has been set.

Returns:
true if the project has been set.
See Also:
ProjectBase.getEclipseProject()

getWorkspace

public final Workspace getWorkspace()

Returns the currently associated workspace .

Returns:
currently associated workspace with this task.
See Also:
ProjectBase.getEclipseProject()

isWorkspaceSet

public final boolean isWorkspaceSet()

Returns whether a workspace has been set to this task.

Returns:
whether a workspace has been set.
See Also:
ProjectBase.getEclipseProject()

requireWorkspaceAndProjectNameOrProjectSet

public final void requireWorkspaceAndProjectNameOrProjectSet()

Requires that either the workspace and a project name or a project directory has been set.

See Also:
ProjectBase.getEclipseProject()

requireWorkspaceSet

public final void requireWorkspaceSet()

Requires that the workspace has been set.


setWorkspace

public final void setWorkspace(java.io.File workspace)
Sets the workspace for this task

Parameters:
workspace - Path to workspace that should be associated with this Task
See Also:
ProjectBase.getEclipseProject()

setInitialiseWorkspace

public void setInitialiseWorkspace(boolean enable)

Enables/disables the initial workspace initialisation.

Parameters:
enable - true if the workspace should be initialised.
See Also:
ProjectBase.getEclipseProject()

hasText

public static boolean hasText(java.lang.String str)

Check if a String has text. More specifically, returns true if the string not null, it's length is > 0, and it has at least one non-whitespace character.

      StringUtils.hasText(null) = false
      StringUtils.hasText("") = false
      StringUtils.hasText(" ") = false
      StringUtils.hasText("12345") = true
      StringUtils.hasText(" 12345 ") = true
 

Parameters:
str - the String to check, may be null
Returns:
true if the String is not null, length > 0, and not whitespace only
See Also:
Character.isWhitespace(char)