use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.
the class WorkflowsInterpreterVisitorTest method testTask.
@Test
public void testTask() {
IEntity taskTest = WorkflowsTestTemplateManager.instance().create("taskTest");
IBindingManager args = BindingManagerFactory.instance.createArguments();
args.wDefValue("reader", new StringReader("yep!\n"));
try {
InterpreterOperation.interpret(taskTest, args, (Reader) null, (Writer) null);
} catch (VisitException e) {
Assert.fail();
}
args.wDefValue("reader", new StringReader("NO\n"));
try {
InterpreterOperation.interpret(taskTest, args, (Reader) null, (Writer) null);
Assert.fail();
} catch (VisitException e) {
}
}
use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.
the class CheckPaternityVisitor method visit.
@Override
public void visit(IEntity entity) {
bm.wDef("parent", entity.wGetParent());
GenericTraversalFactory.instance.downUp(new GenericIdentityVisitor() {
public void visit(IEntity entity) {
bm.wEnterScope();
bm.wDef("parent", entity);
}
}, new GenericIdentityVisitor() {
public void visit(IEntity entity) {
bm.wExitScope();
if (bm.wGet("parent") != entity.wGetParent())
throw new VisitException();
}
}, false).visit(entity);
}
use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.
the class Matcher method indexOf.
public static int indexOf(IVisitor matcherVisitor, IEntity model) {
GenericTraversalFactory tf = GenericTraversalFactory.instance;
try {
Set<IEntity> c = new HashSet<IEntity>();
tf.traverseOne(tf.collect(matcherVisitor, c), true).visit(model);
return model.wIndexOf(c.iterator().next());
} catch (VisitException e) {
return -1;
}
}
use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.
the class GenericMatcherFactory method rewrite.
public IVisitor rewrite(final IEntity oldPattern, final IEntity newPattern, final boolean includeAdjacents) {
return new AbstractVisitor() {
public void visit(IEntity entity) {
IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
if (!Matcher.match(oldPattern, entity, bindings))
throw new VisitException();
IEntity rewritePattern = EntityUtils.clone(newPattern);
if (!entity.wGetParent().wSet(entity, rewritePattern))
throw new VisitException();
Matcher.substitute(rewritePattern, bindings, includeAdjacents);
}
};
}
use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.
the class GenericMatcherFactory method match.
public IVisitor match(final IEntity pattern) {
return new AbstractVisitor() {
public void visit(IEntity entity) {
if (!Matcher.match(pattern, entity))
throw new VisitException();
}
public void toString(StringBuilder sb) {
sb.append("match(");
// TODO startOf
sb.append(pattern);
sb.append(")");
}
};
}
Aggregations