本文整理汇总了Java中org.prop4j.Node.clone方法的典型用法代码示例。如果您正苦于以下问题:Java Node.clone方法的具体用法?Java Node.clone怎么用?Java Node.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.prop4j.Node
的用法示例。
在下文中一共展示了Node.clone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nextExample
import org.prop4j.Node; //导入方法依赖的package包/类
public Configuration nextExample() throws TimeoutException {
if (exampleSolver == null) {
if (bSatisfiable.isEmpty() && !findSatisfiable(true))
return null;
Node child = bChildren[bSatisfiable.removeFirst()];
exampleSolver = new SatSolver(new And(a, new Not(child.clone())), 1000);
}
String solution = exampleSolver.getSolution();
if (solution.equals(lastSolution)) {
exampleSolver = null;
return nextExample();
}
Configuration configuration = new Configuration(fm, false);
ConfigurationReader reader = new ConfigurationReader(configuration);
reader.readFromString(solution);
lastSolution = solution;
return configuration;
}
示例2: findSatisfiable
import org.prop4j.Node; //导入方法依赖的package包/类
public boolean findSatisfiable(boolean stopEarly) throws TimeoutException {
boolean sat = false;
while (hasNextChild()) {
Node child = nextChild();
if (!(child instanceof Or))
child = new Or(child);
Node[] list = Node.clone(child.getChildren());
for (Node node : list)
((Literal) node).positive ^= true;
if (solver.isSatisfiable(list)) {
childIsSatisfiable();
if (stopEarly)
return true;
sat = true;
}
}
return sat;
}
示例3: replaceAbstractVariables
import org.prop4j.Node; //导入方法依赖的package包/类
public static Node replaceAbstractVariables(Node node,
HashMap<Object, Node> map, boolean replaceNull) {
if (node == null)
return null;
if (node instanceof Literal) {
Literal literal = (Literal) node;
if (map.containsKey(literal.var)) {
Node replacing = map.get(literal.var);
if (replacing == null)
return replaceNull ? null : node;
replacing = replacing.clone();
node = literal.positive ? replacing : new Not(replacing);
}
} else {
Node[] children = node.getChildren();
for (int i = 0; i < children.length; i++) {
children[i] = replaceAbstractVariables(children[i], map,
replaceNull);
if (replaceNull && children[i] == null)
return null;
}
}
return node;
}
示例4: implies
import org.prop4j.Node; //导入方法依赖的package包/类
private boolean implies(Node a, Node b, ExampleCalculator example)
throws TimeoutException {
if (b == null)
return true;
if (!strategy.contains(Strategy.SingleTesting)) {
Node node = new And(a.clone(), new Not(b.clone()));
SatSolver solver = new SatSolver(node, timeout);
boolean valid = !solver.isSatisfiable();
return valid;
}
example.setLeft(a);
example.setRight(b);
return !example.findSatisfiable(strategy
.contains(Strategy.SingleTestingAborted));
}
示例5: checkCondition
import org.prop4j.Node; //导入方法依赖的package包/类
/**
* checks some condition against the feature model. use only if you know
* what you are doing!
*
* @return
* @throws TimeoutException
*/
public boolean checkCondition(Node condition) {
Node featureModel = NodeCreator.createNodes(this);
// FM => (condition)
Implies finalFormula = new Implies(featureModel, condition.clone());
try {
return !new SatSolver(new Not(finalFormula), 1000).isSatisfiable();
} catch (TimeoutException e) {
FMCorePlugin.getDefault().logError(e);
return false;
}
}
示例6: isTautology
import org.prop4j.Node; //导入方法依赖的package包/类
/**
* returns true if the constraint is always true
*
* @param constraint
* the constraint to be evaluated
* @param timeout
* timeout in ms
*
*/
private boolean isTautology(String constraint, int timeout) {
NodeReader nodeReader = new NodeReader();
Node node = nodeReader.stringToNode(constraint);
SatSolver satsolver = new SatSolver(new Not(node.clone()), timeout);
try {
return !satsolver.isSatisfiable();
} catch (TimeoutException e) {
return true;
}
}