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

BuildEvent

public class BuildEvent extends EventObject
Class representing an event occurring during a build. An event is built by specifying either a project, a task or a target. A project level event will only have a project reference; a target level event will have project and target references; a task level event will have project, target and task references.

Fields Summary
private Project
project
Project which emitted the event.
private Target
target
Target which emitted the event, if specified.
private Task
task
Task which emitted the event, if specified.
private String
message
Message associated with the event. This is only used for "messageLogged" events.
private int
priority
The priority of the message, for "messageLogged" events.
private Throwable
exception
The exception associated with this event, if any. This is only used for "messageLogged", "taskFinished", "targetFinished", and "buildFinished" events.
Constructors Summary
public BuildEvent(Project project)
Construct a BuildEvent for a project level event.

param
project the project that emitted the event. Should not be null.


                                            
       
        super(project);
        this.project = project;
        this.target = null;
        this.task = null;
    
public BuildEvent(Target target)
Construct a BuildEvent for a target level event. The project associated with the event is derived from the given target.

param
target the target that emitted the event. Must not be null.

        super(target);
        this.project = target.getProject();
        this.target = target;
        this.task = null;
    
public BuildEvent(Task task)
Construct a BuildEvent for a task level event. The project and target associated with the event are derived from the given task.

param
task the task that emitted the event. Must not be null.

        super(task);
        this.project = task.getProject();
        this.target = task.getOwningTarget();
        this.task = task;
    
Methods Summary
public java.lang.ThrowablegetException()
Returns the exception that was thrown, if any. This field will only be set for "messageLogged", "taskFinished", "targetFinished", and "buildFinished" events.

return
the exception associated with this exception, or null if no exception has been set.
see
BuildListener#messageLogged(BuildEvent)
see
BuildListener#taskFinished(BuildEvent)
see
BuildListener#targetFinished(BuildEvent)
see
BuildListener#buildFinished(BuildEvent)

        return exception;
    
public java.lang.StringgetMessage()
Returns the logging message. This field will only be set for "messageLogged" events.

return
the message associated with this event, or null if no message has been set.
see
BuildListener#messageLogged(BuildEvent)

        return message;
    
public intgetPriority()
Returns the priority of the logging message. This field will only be set for "messageLogged" events. The meaning of this priority is as specified by the constants in the {@link Project Project} class.

return
the priority associated with this event.
see
BuildListener#messageLogged(BuildEvent)

        return priority;
    
public ProjectgetProject()
Returns the project that fired this event.

return
the project that fired this event

        return project;
    
public TargetgetTarget()
Returns the target that fired this event.

return
the project that fired this event, or null if this event is a project level event.

        return target;
    
public TaskgetTask()
Returns the task that fired this event.

return
the task that fired this event, or null if this event is a project or target level event.

        return task;
    
public voidsetException(java.lang.Throwable exception)
Sets the exception associated with this event. This is used for "messageLogged", "taskFinished", "targetFinished", and "buildFinished" events.

param
exception The exception to be associated with this event. May be null.
see
BuildListener#messageLogged(BuildEvent)
see
BuildListener#taskFinished(BuildEvent)
see
BuildListener#targetFinished(BuildEvent)
see
BuildListener#buildFinished(BuildEvent)

        this.exception = exception;
    
public voidsetMessage(java.lang.String message, int priority)
Sets the message and priority associated with this event. This is used for "messageLogged" events.

param
message the message to be associated with this event. Should not be null.
param
priority the priority to be associated with this event, as defined in the {@link Project Project} class.
see
BuildListener#messageLogged(BuildEvent)

        this.message = message;
        this.priority = priority;