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

📄 task.java

📁 java ant的源码!非常值得看的源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * @param length the amount of data to read.     *     * @return the number of bytes read.     *     * @exception IOException if the data cannot be read.     * @since Ant 1.6     */    protected int handleInput(byte[] buffer, int offset, int length)        throws IOException {        return getProject().defaultInput(buffer, offset, length);    }    /**     * Handles an error output by logging it with the WARN priority.     *     * @param output The error output to log. Should not be <code>null</code>.     */    protected void handleErrorOutput(String output) {        log(output, Project.MSG_WARN);    }    /**     * Handles an error line by logging it with the WARN priority.     *     * @param output The error output to log. Should not be <code>null</code>.     *     * @since Ant 1.5.2     */    protected void handleErrorFlush(String output) {        handleErrorOutput(output);    }    /**     * Logs a message with the default (INFO) priority.     *     * @param msg The message to be logged. Should not be <code>null</code>.     */    public void log(String msg) {        log(msg, Project.MSG_INFO);    }    /**     * Logs a message with the given priority. This delegates     * the actual logging to the project.     *     * @param msg The message to be logged. Should not be <code>null</code>.     * @param msgLevel The message priority at which this message is to     *                 be logged.     */    public void log(String msg, int msgLevel) {        if (getProject() != null) {            getProject().log(this, msg, msgLevel);        } else {            super.log(msg, msgLevel);        }    }    /**     * Logs a message with the given priority. This delegates     * the actual logging to the project.     *     * @param t The exception to be logged. Should not be <code>null</code>.     * @param msgLevel The message priority at which this message is to     *                 be logged.     * @since 1.7     */    public void log(Throwable t, int msgLevel) {        if (t != null) {            log(t.getMessage(), t, msgLevel);        }    }    /**     * Logs a message with the given priority. This delegates     * the actual logging to the project.     *     * @param msg The message to be logged. Should not be <code>null</code>.     * @param t The exception to be logged. May be <code>null</code>.     * @param msgLevel The message priority at which this message is to     *                 be logged.     * @since 1.7     */    public void log(String msg, Throwable t, int msgLevel) {        if (getProject() != null) {            getProject().log(this, msg, t, msgLevel);        } else {            super.log(msg, msgLevel);        }    }    /**     * Performs this task if it's still valid, or gets a replacement     * version and performs that otherwise.     *     * Performing a task consists of firing a task started event,     * configuring the task, executing it, and then firing task finished     * event. If a runtime exception is thrown, the task finished event     * is still fired, but with the exception as the cause.     */    public final void perform() {        if (!invalid) {            getProject().fireTaskStarted(this);            Throwable reason = null;            try {                maybeConfigure();                DispatchUtils.execute(this);            } catch (BuildException ex) {                if (ex.getLocation() == Location.UNKNOWN_LOCATION) {                    ex.setLocation(getLocation());                }                reason = ex;                throw ex;            } catch (Exception ex) {                reason = ex;                BuildException be = new BuildException(ex);                be.setLocation(getLocation());                throw be;            } catch (Error ex) {                reason = ex;                throw ex;            } finally {                getProject().fireTaskFinished(this, reason);            }        } else {            UnknownElement ue = getReplacement();            Task task = ue.getTask();            task.perform();        }    }    /**     * Marks this task as invalid. Any further use of this task     * will go through a replacement with the updated definition.     */    final void markInvalid() {        invalid = true;    }    /**     * Has this task been marked invalid?     *     * @return true if this task is no longer valid. A new task should be     * configured in this case.     *     * @since Ant 1.5     */    protected final boolean isInvalid() {        return invalid;    }    /**     * Replacement element used if this task is invalidated.     */    private UnknownElement replacement;    /**     * Creates an UnknownElement that can be used to replace this task.     * Once this has been created once, it is cached and returned by     * future calls.     *     * @return the UnknownElement instance for the new definition of this task.     */    private UnknownElement getReplacement() {        if (replacement == null) {            replacement = new UnknownElement(taskType);            replacement.setProject(getProject());            replacement.setTaskType(taskType);            replacement.setTaskName(taskName);            replacement.setLocation(location);            replacement.setOwningTarget(target);            replacement.setRuntimeConfigurableWrapper(wrapper);            wrapper.setProxy(replacement);            replaceChildren(wrapper, replacement);            target.replaceChild(this, replacement);            replacement.maybeConfigure();        }        return replacement;    }    /**     * Recursively adds an UnknownElement instance for each child     * element of replacement.     *     * @since Ant 1.5.1     */    private void replaceChildren(RuntimeConfigurable wrapper,                                 UnknownElement parentElement) {        Enumeration e = wrapper.getChildren();        while (e.hasMoreElements()) {            RuntimeConfigurable childWrapper =                (RuntimeConfigurable) e.nextElement();            UnknownElement childElement =                new UnknownElement(childWrapper.getElementTag());            parentElement.addChild(childElement);            childElement.setProject(getProject());            childElement.setRuntimeConfigurableWrapper(childWrapper);            childWrapper.setProxy(childElement);            replaceChildren(childWrapper, childElement);        }    }    /**     * Return the type of task.     *     * @return the type of task.     */    public String getTaskType() {        return taskType;    }    /**     * Return the runtime configurable structure for this task.     *     * @return the runtime structure for this task.     */    protected RuntimeConfigurable getWrapper() {        return wrapper;    }    /**     * Bind a task to another; use this when configuring a newly created     * task to do work on behalf of another.     * Project, OwningTarget, TaskName, Location and Description are all copied     *     * Important: this method does not call {@link Task#init()}.     * If you are creating a task to delegate work to, call {@link Task#init()}     * to initialize it.     *     * @param owner owning target     * @since Ant1.7     */    public final void bindToOwner(Task owner) {        setProject(owner.getProject());        setOwningTarget(owner.getOwningTarget());        setTaskName(owner.getTaskName());        setDescription(owner.getDescription());        setLocation(owner.getLocation());        setTaskType(owner.getTaskType());    }}

⌨️ 快捷键说明

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