FileDocCategorySizeDatePackage
ProjectComponent.javaAPI DocApache Ant 1.705545Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant

ProjectComponent

public abstract class ProjectComponent extends Object implements Cloneable
Base class for components of a project, including tasks and data types. Provides common facilities.

Fields Summary
protected Project
project
Project object of this component.
protected Location
location
Location within the build file of this task definition.
protected String
description
Description of this component, if any.
Constructors Summary
public ProjectComponent()
Sole constructor.

    // CheckStyle:VisibilityModifier ON

       
      
    
Methods Summary
public java.lang.Objectclone()

since
Ant 1.7
return
a shallow copy of this projectcomponent.
throws
CloneNotSupportedException does not happen, but is declared to allow subclasses to do so.

        ProjectComponent pc = (ProjectComponent) super.clone();
        pc.setLocation(getLocation());
        pc.setProject(getProject());
        return pc;
    
public java.lang.StringgetDescription()
Returns the description of the current action.

return
the description of the current action, or null if no description is available.

        return description;
    
public LocationgetLocation()
Returns the file/location where this task was defined.

return
the file/location where this task was defined. Should not return null. Location.UNKNOWN_LOCATION is used for unknown locations.
see
Location#UNKNOWN_LOCATION

        return location;
    
public ProjectgetProject()
Returns the project to which this component belongs.

return
the components's project.

        return project;
    
public voidlog(java.lang.String msg)
Logs a message with the default (INFO) priority.

param
msg The message to be logged. Should not be null.

        log(msg, Project.MSG_INFO);
    
public voidlog(java.lang.String msg, int msgLevel)
Logs a message with the given priority.

param
msg The message to be logged. Should not be null.
param
msgLevel the message priority at which this message is to be logged.

        if (getProject() != null) {
            getProject().log(msg, msgLevel);
        } else {
            // 'reasonable' default, if the component is used without
            // a Project ( for example as a standalone Bean ).
            // Most ant components can be used this way.
            if (msgLevel <= Project.MSG_INFO) {
                System.err.println(msg);
            }
        }
    
public voidsetDescription(java.lang.String desc)
Sets a description of the current action. This may be used for logging purposes.

param
desc Description of the current action. May be null, indicating that no description is available.

        description = desc;
    
public voidsetLocation(Location location)
Sets the file/location where this task was defined.

param
location The file/location where this task was defined. Should not be null--use Location.UNKNOWN_LOCATION if the location isn't known.
see
Location#UNKNOWN_LOCATION

        this.location = location;
    
public voidsetProject(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.

param
project Project in whose scope this component belongs. Must not be null.

        this.project = project;