/** * iterates all child expressions. * * Since expressions are binarized, expressions like A|B|C is modeled as * A|(B|C). This is may not be preferable for some applications. * * <P> * This method returns an iterator that iterates all children * (A,B, and C in this example) */ public Iterator children() { final Expression[] items = getChildren(); return new Iterator() { private int idx =0; public Object next() { return items[idx++]; } public boolean hasNext() { return idx!=items.length; } public void remove() { throw new UnsupportedOperationException(); } }; }
/** enumerates children of BinaryExp into a vector. */ private Vector getChildren( BinaryExp exp ) { final Vector vec = new Vector(); Iterator itr = exp.children(); while( itr.hasNext() ) vec.add( itr.next() ); return vec; }
/** * iterates all child expressions. * * Since expressions are binarized, expressions like A|B|C is modeled as * A|(B|C). This is may not be preferable for some applications. * * <P> * This method returns an iterator that iterates all children * (A,B, and C in this example) */ public Iterator children() { final Expression[] items = getChildren(); return new Iterator() { private int idx =0; public Object next() { return items[idx++]; } public boolean hasNext() { return idx!=items.length; } public void remove() { throw new UnsupportedOperationException(); } }; }
/** * iterates all child expressions. * * Since expressions are binarized, expressions like A|B|C is modeled as * A|(B|C). This is may not be preferable for some applications. * * <P> * This method returns an iterator that iterates all children * (A,B, and C in this example) */ public Iterator children() { final Expression[] items = getChildren(); return new Iterator() { private int idx =0; public Object next() { return items[idx++]; } public boolean hasNext() { return idx!=items.length; } public void remove() { throw new UnsupportedOperationException(); } }; }
/** * iterates all child expressions. * * Since expressions are binarized, expressions like A|B|C is modeled as * A|(B|C). This is may not be preferable for some applications. * * <P> * This method returns an iterator that iterates all children * (A,B, and C in this example) */ public Iterator<Expression> children() { final Expression[] items = getChildren(); return new Iterator<Expression>() { private int idx =0; public Expression next() { return items[idx++]; } public boolean hasNext() { return idx!=items.length; } public void remove() { throw new UnsupportedOperationException(); } }; } }
public static ValueExp[] getValues(Expression exp) { if (!(exp instanceof ChoiceExp)) { if (!(exp instanceof ValueExp)) { // System.out.println(ExpressionPrinter.printContentModel(exp)); // it must be a choice or value exps. throw new InternalError("assertion failed"); } return new ValueExp[]{ (ValueExp) exp }; } else { Expression[] children = ((ChoiceExp) exp).getChildren(); ValueExp[] values = new ValueExp[children.length]; System.arraycopy(children, 0, values, 0, children.length); return values; } } }
public void visitBinExp(String elementName, BinaryExp exp, Class type) { // since AGM is binarized, // <choice> a b c </choice> is represented as // <choice> a <choice> b c </choice></choice> // this method print them as <choice> a b c </choice> writer.start(elementName); Expression[] children = exp.getChildren(); for (int i = 0; i < children.length; i++) children[i].visit(this); writer.end(elementName); }
public void visitBinExp(String elementName, BinaryExp exp, Class type) { // since AGM is binarized, // <choice> a b c </choice> is represented as // <choice> a <choice> b c </choice></choice> // this method print them as <choice> a b c </choice> writer.start(elementName); Expression[] children = exp.getChildren(); for (int i = 0; i < children.length; i++) children[i].visit(this); writer.end(elementName); }
public void visitBinExp(String elementName, BinaryExp exp, Class type) { // since AGM is binarized, // <choice> a b c </choice> is represented as // <choice> a <choice> b c </choice></choice> // this method print them as <choice> a b c </choice> writer.start(elementName); Expression[] children = exp.getChildren(); for (int i = 0; i < children.length; i++) children[i].visit(this); writer.end(elementName); }
public void visitBinExp(String elementName, BinaryExp exp, Class<?> type) { // since AGM is binarized, // <choice> a b c </choice> is represented as // <choice> a <choice> b c </choice></choice> // this method print them as <choice> a b c </choice> writer.start(elementName); Expression[] children = exp.getChildren(); for (int i = 0; i < children.length; i++) children[i].visit(this); writer.end(elementName); }