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


Java Condition.eval方法代码示例

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


在下文中一共展示了Condition.eval方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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包/类
/**
 * @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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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


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