当前位置: 首页>>代码示例>>Java>>正文


Java Condition类代码示例

本文整理汇总了Java中org.apache.tools.ant.taskdefs.condition.Condition的典型用法代码示例。如果您正苦于以下问题:Java Condition类的具体用法?Java Condition怎么用?Java Condition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Condition类属于org.apache.tools.ant.taskdefs.condition包,在下文中一共展示了Condition类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
/**
 * See whether our nested condition holds and set the property.
 *
 * @since Ant 1.4
 * @exception BuildException if an error occurs
 */
public void execute() throws BuildException {
    if (countConditions() > 1) {
        throw new BuildException(
            "You must not nest more than one condition into <%s>",
            getTaskName());
    }
    if (countConditions() < 1) {
        throw new BuildException("You must nest a condition into <%s>",
            getTaskName());
    }
    if (property == null) {
        throw new BuildException("The property attribute is required.");
    }
    Condition c = getConditions().nextElement();
    if (c.eval()) {
        log("Condition true; setting " + property + " to " + value, Project.MSG_DEBUG);
        PropertyHelper.getPropertyHelper(getProject()).setNewProperty(property, value);
    } else if (alternative != null) {
        log("Condition false; setting " + property + " to " + alternative, Project.MSG_DEBUG);
        PropertyHelper.getPropertyHelper(getProject()).setNewProperty(property, alternative);
    } else {
        log("Condition false; not setting " + property, Project.MSG_DEBUG);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:31,代码来源:ConditionTask.java

示例2: execute

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
public void execute() throws BuildException {

    // Ensure that exactly one condition was specified.
    int numConditions = countConditions();
    if (numConditions != 1) {
      throw new BuildException("An 'if' must have exactly one condition (e.g. equal, and, etc.) - this 'if' has " + numConditions);
    }

    // Ensure that either a 'then' or an 'else' was specified.  An 'if' without one or the other is useless and probably a mistake.
    if ((seqThen == null) && (seqElse == null)) {
      throw new BuildException("An 'if' must have a 'then' and/or 'else' - this 'if' has neither.");
    }

    // Evaluate the condition and either do the 'then' or the 'else'.
    Condition condition = (Condition) getConditions().nextElement();
    Sequential task = condition.eval() ? seqThen : seqElse;
    if (task != null) {
      task.execute();
    }
  }
 
开发者ID:ibm-datapower,项目名称:datapower-configuration-manager,代码行数:21,代码来源:taskIf.java

示例3: eval

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
/**
 * Evaluate condition
 *
 * @return true if the condition is true.
 * @throws BuildException if the condition is not configured correctly.
 */
public boolean eval() throws BuildException {
    if (countConditions() > 1) {
        throw new BuildException("You must not nest more than one "
            + "condition into <not>");
    }
    if (countConditions() < 1) {
        throw new BuildException("You must nest a condition into <not>");
    }
    return !((Condition) getConditions().nextElement()).eval();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:Not.java

示例4: eval

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
/**
 * @return true if any of the contained conditions evaluate to true
 * @exception BuildException if an error occurs
 */
public boolean eval() throws BuildException {
    Enumeration e = getConditions();
    while (e.hasMoreElements()) {
        Condition c = (Condition) e.nextElement();
        if (c.eval()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:Or.java

示例5: eval

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
/**
 * @return true if all the contained conditions evaluates to true
 * @exception BuildException if an error occurs
 */
public boolean eval() throws BuildException {
    Enumeration e = getConditions();
    while (e.hasMoreElements()) {
        Condition c = (Condition) e.nextElement();
        if (!c.eval()) {
            return false;
        }
    }
    return true;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:And.java

示例6: execute

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
public void execute() {
	String use_asserts = getProject().getProperty("ant.enable.asserts");
	boolean assertsEnabled = Project.toBoolean(use_asserts);

	if (assertsEnabled) {
		if (name != null) {
			if (value == null) {
				throw new BuildException("The 'value' attribute must accompany the 'name' attribute.");
			}
			String propVal = getProject().replaceProperties("${" + name + "}");
			Equals e = new Equals();
			e.setArg1(propVal);
			e.setArg2(value);
			addEquals(e);
		}

		if (countConditions() == 0) {
			throw new BuildException("There is no condition specified.");
		} else if (countConditions() > 1) {
			throw new BuildException("There must be exactly one condition specified.");
		}

		Condition c = (Condition) getConditions().nextElement();
		if (!c.eval()) {
			if (failOnError) {
				Exit fail = (Exit) getProject().createTask("fail");
				fail.setMessage(message);
				fail.execute();
			}
		} else {
			if (execute && sequential != null) {
				this.sequential.execute();
			}
		}
	} else {
		if (execute && sequential != null) {
			this.sequential.execute();
		}
	}
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:41,代码来源:Assert.java

示例7: eval

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
public boolean eval() throws BuildException {
	if (countConditions() > 1) {
		throw new BuildException("You must not nest more than one condition into <elseif>");
	}
	if (countConditions() < 1) {
		throw new BuildException("You must nest a condition into <elseif>");
	}
	Condition c = (Condition) getConditions().nextElement();

	return c.eval();
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:12,代码来源:IfTask.java

示例8: execute

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
public void execute() throws BuildException {
	if (countConditions() > 1) {
		throw new BuildException("You must not nest more than one condition into <if>");
	}
	if (countConditions() < 1) {
		throw new BuildException("You must nest a condition into <if>");
	}
	Condition c = (Condition) getConditions().nextElement();
	if (c.eval()) {
		if (thenTasks != null) {
			thenTasks.execute();
		}
	} else {
		boolean done = false;
		int sz = elseIfTasks.size();
		for (int i = 0; i < sz && !done; i++) {

			ElseIf ei = (ElseIf) (elseIfTasks.elementAt(i));
			if (ei.eval()) {
				done = true;
				ei.execute();
			}
		}

		if (!done && elseTasks != null) {
			elseTasks.execute();
		}
	}
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:30,代码来源:IfTask.java

示例9: setIf

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
/**
 * Same as {@link #setIf(String)} but requires a {@link Condition} instance
 *
 * @param condition Condition
 * @since 1.9
 */
public void setIf(Condition condition) {
    if (ifCondition == null) {
        ifCondition = condition;
    } else {
        And andCondition = new And();
        andCondition.setProject(getProject());
        andCondition.setLocation(getLocation());
        andCondition.add(ifCondition);
        andCondition.add(condition);
        ifCondition = andCondition;
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:19,代码来源:Target.java

示例10: setUnless

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
/**
 * Same as {@link #setUnless(String)} but requires a {@link Condition} instance
 *
 * @param condition Condition
 * @since 1.9
 */
public void setUnless(Condition condition) {
    if (unlessCondition == null) {
        unlessCondition = condition;
    } else {
        Or orCondition = new Or();
        orCondition.setProject(getProject());
        orCondition.setLocation(getLocation());
        orCondition.add(unlessCondition);
        orCondition.add(condition);
        unlessCondition = orCondition;
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:19,代码来源:Target.java

示例11: execute

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
/**
 * Check repeatedly for the specified conditions until they become
 * true or the timeout expires.
 * @throws BuildException on error
 */
public void execute() throws BuildException {
    if (countConditions() > 1) {
        throw new BuildException(
            "You must not nest more than one condition into %s",
            getTaskName());
    }
    if (countConditions() < 1) {
        throw new BuildException("You must nest a condition into %s",
            getTaskName());
    }
    Condition c = getConditions().nextElement();
    try {
        long maxWaitMillis = calculateMaxWaitMillis();
        long checkEveryMillis = calculateCheckEveryMillis();
        long start = System.currentTimeMillis();
        long end = start + maxWaitMillis;

        while (System.currentTimeMillis() < end) {
            if (c.eval()) {
                processSuccess();
                return;
            }
            Thread.sleep(checkEveryMillis);
        }
    } catch (InterruptedException e) {
        log("Task " + getTaskName()
                + " interrupted, treating as timed out.");
    }
    processTimeout();
}
 
开发者ID:apache,项目名称:ant,代码行数:36,代码来源:WaitFor.java

示例12: eval

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
/**
 * Evaluate the condition.
 */
public boolean eval() {
    // Evaluate the first condition in the list
    if (countConditions() == 1) {
        Condition c = (Condition) getConditions().nextElement();
        return c.eval();
    } else {
        return false;
    }
}
 
开发者ID:ModelN,项目名称:build-management,代码行数:13,代码来源:RepeatCondition.java

示例13: getCondition

import org.apache.tools.ant.taskdefs.condition.Condition; //导入依赖的package包/类
public Condition getCondition() { return (Condition) getConditions().nextElement(); } 
开发者ID:rmcilroy,项目名称:HeraJVM,代码行数:2,代码来源:IfTask.java


注:本文中的org.apache.tools.ant.taskdefs.condition.Condition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。