⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 task.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *  Licensed to the Apache Software Foundation (ASF) under one or more *  contributor license agreements.  See the NOTICE file distributed with *  this work for additional information regarding copyright ownership. *  The ASF licenses this file to You under the Apache License, Version 2.0 *  (the "License"); you may not use this file except in compliance with *  the License.  You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * *  Unless required by applicable law or agreed to in writing, software *  distributed under the License is distributed on an "AS IS" BASIS, *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *  See the License for the specific language governing permissions and *  limitations under the License. * */package org.apache.tools.ant;import org.apache.tools.ant.dispatch.DispatchUtils;import java.util.Enumeration;import java.io.IOException;/** * Base class for all tasks. * * Use Project.createTask to create a new task instance rather than * using this class directly for construction. * * @see Project#createTask */public abstract class Task extends ProjectComponent {    // CheckStyle:VisibilityModifier OFF - bc    /**     * Target this task belongs to, if any.     * @deprecated since 1.6.x.     *             You should not be accessing this variable directly.     *             Please use the {@link #getOwningTarget()} method.     */    protected Target target;    /**     * Name of this task to be used for logging purposes.     * This defaults to the same as the type, but may be     * overridden by the user. For instance, the name "java"     * isn't terribly descriptive for a task used within     * another task - the outer task code can probably     * provide a better one.     * @deprecated since 1.6.x.     *             You should not be accessing this variable directly.     *             Please use the {@link #getTaskName()} method.     */    protected String taskName;    /**     * Type of this task.     *     * @deprecated since 1.6.x.     *             You should not be accessing this variable directly.     *             Please use the {@link #getTaskType()} method.     */    protected String taskType;    /**     * Wrapper for this object, used to configure it at runtime.     *     * @deprecated since 1.6.x.     *             You should not be accessing this variable directly.     *             Please use the {@link #getWrapper()} method.     */    protected RuntimeConfigurable wrapper;    // CheckStyle:VisibilityModifier ON    /**     * Whether or not this task is invalid. A task becomes invalid     * if a conflicting class is specified as the implementation for     * its type.     */    private boolean invalid;    /** Sole constructor. */    public Task() {    }    /**     * Sets the target container of this task.     *     * @param target Target in whose scope this task belongs.     *               May be <code>null</code>, indicating a top-level task.     */    public void setOwningTarget(Target target) {        this.target = target;    }    /**     * Returns the container target of this task.     *     * @return The target containing this task, or <code>null</code> if     *         this task is a top-level task.     */    public Target getOwningTarget() {        return target;    }    /**     * Sets the name to use in logging messages.     *     * @param name The name to use in logging messages.     *             Should not be <code>null</code>.     */    public void setTaskName(String name) {        this.taskName = name;    }    /**     * Returns the name to use in logging messages.     *     * @return the name to use in logging messages.     */    public String getTaskName() {        return taskName;    }    /**     * Sets the name with which the task has been invoked.     *     * @param type The name the task has been invoked as.     *             Should not be <code>null</code>.     */    public void setTaskType(String type) {        this.taskType = type;    }    /**     * Called by the project to let the task initialize properly.     * The default implementation is a no-op.     *     * @exception BuildException if something goes wrong with the build     */    public void init() throws BuildException {    }    /**     * Called by the project to let the task do its work. This method may be     * called more than once, if the task is invoked more than once.     * For example,     * if target1 and target2 both depend on target3, then running     * "ant target1 target2" will run all tasks in target3 twice.     *     * @exception BuildException if something goes wrong with the build.     */    public void execute() throws BuildException {    }    /**     * Returns the wrapper used for runtime configuration.     *     * @return the wrapper used for runtime configuration. This     *         method will generate a new wrapper (and cache it)     *         if one isn't set already.     */    public RuntimeConfigurable getRuntimeConfigurableWrapper() {        if (wrapper == null) {            wrapper = new RuntimeConfigurable(this, getTaskName());        }        return wrapper;    }    /**     * Sets the wrapper to be used for runtime configuration.     *     * This method should be used only by the ProjectHelper and Ant internals.     * It is public to allow helper plugins to operate on tasks, normal tasks     * should never use it.     *     * @param wrapper The wrapper to be used for runtime configuration.     *                May be <code>null</code>, in which case the next call     *                to getRuntimeConfigurableWrapper will generate a new     *                wrapper.     */    public void setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper) {        this.wrapper = wrapper;    }    // XXX: (Jon Skeet) The comment "if it hasn't been done already" may    // not be strictly true. wrapper.maybeConfigure() won't configure the same    // attributes/text more than once, but it may well add the children again,    // unless I've missed something.    /**     * Configures this task - if it hasn't been done already.     * If the task has been invalidated, it is replaced with an     * UnknownElement task which uses the new definition in the project.     *     * @exception BuildException if the task cannot be configured.     */    public void maybeConfigure() throws BuildException {        if (!invalid) {            if (wrapper != null) {                wrapper.maybeConfigure(getProject());            }        } else {            getReplacement();        }    }    /**     * Force the task to be reconfigured from its RuntimeConfigurable.     */    public void reconfigure() {        if (wrapper != null) {            wrapper.reconfigure(getProject());        }    }    /**     * Handles output by logging it with the INFO priority.     *     * @param output The output to log. Should not be <code>null</code>.     */    protected void handleOutput(String output) {        log(output, Project.MSG_INFO);    }    /**     * Handles output by logging it with the INFO priority.     *     * @param output The output to log. Should not be <code>null</code>.     *     * @since Ant 1.5.2     */    protected void handleFlush(String output) {        handleOutput(output);    }    /**     * Handle an input request by this task.     *     * @param buffer the buffer into which data is to be read.     * @param offset the offset into the buffer at which data is stored.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -