ProjectComponent (Apache Ant API)
Description: declaration: package: org.apache.tools.ant, class: ProjectComponent

Package org.apache.tools.ant

# Class ProjectComponent

java.lang.Object
org.apache.tools.ant.ProjectComponent

All Implemented Interfaces:
  `java.lang.Cloneable`

Direct Known Subclasses:
  `AbstractScriptComponent`, `BaseIfAttribute`, `Commandline.Argument`, `Concat.TextElement`, `ConditionBase`, `DataType`, `FailureRecorder`, `FileTokenizer`, `HasMethod`, `Http`, `IsFalse`, `IsLastModified`, `IsReachable`, `IsReference`, `IsSet`, `IsTrue`, `Javadoc.ExtensionInfo`, `LineTokenizer`, `Matches`, `Message`, `ParserSupports`, `Provider`, `ResourceExists`, `Service`, `Socket`, `StringTokenizer`, `Task`, `TokenFilter.ChainableReaderFilter`, `TokenFilter.ContainsString`, `TokenFilter.DeleteCharacters`, `TypeFound`, `XMLFragment`, `XSLTProcess.Factory.Attribute`

    public abstract class ProjectComponent
    extends java.lang.Object
    implements java.lang.Cloneable

Base class for components of a project, including tasks and data types. Provides common facilities.

- ## Field Summary

  Fields
  Modifier and Type | Field | Description
  --- | --- | ---
  `protected java.lang.String` | `description` | Deprecated. since 1.6.x.
  `protected Location` | `location` | Deprecated. since 1.6.x.
  `protected Project` | `project` | Deprecated. since 1.6.x.

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `ProjectComponent()` | Sole constructor.

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `java.lang.Object` | `clone()` |
  `java.lang.String` | `getDescription()` | Returns the description of the current action.
  `Location` | `getLocation()` | Returns the file/location where this task was defined.
  `Project` | `getProject()` | Returns the project to which this component belongs.
  `void` | `log​(java.lang.String msg)` | Logs a message with the default (INFO) priority.
  `void` | `log​(java.lang.String msg, int msgLevel)` | Logs a message with the given priority.
  `void` | `setDescription​(java.lang.String desc)` | Sets a description of the current action.
  `void` | `setLocation​(Location location)` | Sets the file/location where this task was defined.
  `void` | `setProject​(Project project)` | Sets the project object of this component.

  ### Methods inherited from class java.lang.Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### project

    @Deprecated protected Project project
    Deprecated.
    since 1.6.x. You should not be directly accessing this variable directly. You should access project object via the getProject() or setProject() accessor/mutators.
    Project object of this component.

  - ### location

    @Deprecated protected Location location
    Deprecated.
    since 1.6.x. You should not be accessing this variable directly. Please use the `getLocation()` method.
    Location within the build file of this task definition.

  - ### description

    @Deprecated protected java.lang.String description
    Deprecated.
    since 1.6.x. You should not be accessing this variable directly.
    Description of this component, if any.

- ## Constructor Details

  - ### ProjectComponent

    public ProjectComponent()
    Sole constructor.

- ## Method Details

  - ### setProject

    public void setProject​(Project project)
    Sets the project object of this component. This method is used by Project when a component is added to it so that the component has access to the functions of the project. It should not be used for any other purpose.
    Parameters:
      `project` - Project in whose scope this component belongs. Must not be `null`.

  - ### getProject

    public Project getProject()
    Returns the project to which this component belongs.
    Returns:
      the components's project.

  - ### getLocation

    public Location getLocation()
    Returns the file/location where this task was defined.
    Returns:
      the file/location where this task was defined. Should not return `null`. Location.UNKNOWN_LOCATION is used for unknown locations.
    See Also:
      `Location.UNKNOWN_LOCATION`

  - ### setLocation

    public void setLocation​(Location location)
    Sets the file/location where this task was defined.
    Parameters:
      `location` - The file/location where this task was defined. Should not be `null`--use Location.UNKNOWN_LOCATION if the location isn't known.
    See Also:
      `Location.UNKNOWN_LOCATION`

  - ### setDescription

    public void setDescription​(java.lang.String desc)
    Sets a description of the current action. This may be used for logging purposes.
    Parameters:
      `desc` - Description of the current action. May be `null`, indicating that no description is available.

  - ### getDescription

    public java.lang.String getDescription()
    Returns the description of the current action.
    Returns:
      the description of the current action, or `null` if no description is available.

  - ### log

    public void log​(java.lang.String msg)
    Logs a message with the default (INFO) priority.
    Parameters:
      `msg` - The message to be logged. Should not be `null`.

  - ### log

    public void log​(java.lang.String msg, int msgLevel)
    Logs a message with the given priority.
    Parameters:
      `msg` - The message to be logged. Should not be `null`.
      `msgLevel` - the message priority at which this message is to be logged.

  - ### clone

    public java.lang.Object clone() throws java.lang.CloneNotSupportedException
    Overrides:
      `clone` in class `java.lang.Object`
    Returns:
      a shallow copy of this projectcomponent.
    Throws:
      `java.lang.CloneNotSupportedException` - does not happen, but is declared to allow subclasses to do so.
    Since:
      Ant 1.7