| 1 | |
package org.webslinger.ext.wiki.parser; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.ListIterator; |
| 5 | |
|
| 6 | |
public class WikiControlCase extends SimpleNode implements ControlNode, InlineContainer { |
| 7 | 0 | protected ArrayList<Node> choices = new ArrayList<Node>(); |
| 8 | |
|
| 9 | |
public WikiControlCase(int id) { |
| 10 | 0 | super(id); |
| 11 | 0 | } |
| 12 | |
|
| 13 | |
public WikiControlCase(Wiki p, int id) { |
| 14 | 0 | super(p, id); |
| 15 | 0 | } |
| 16 | |
|
| 17 | |
public Object jjtAccept(WikiVisitor visitor, Object data) { |
| 18 | 0 | return visitor.visit(this, data); |
| 19 | |
} |
| 20 | |
|
| 21 | |
public void moveChildren() { |
| 22 | 0 | if (children.isEmpty()) return; |
| 23 | 0 | Node last = children.get(children.size() - 1); |
| 24 | |
|
| 25 | 0 | choices.addAll(children); |
| 26 | 0 | children.clear(); |
| 27 | 0 | } |
| 28 | |
|
| 29 | |
public ListIterator<Node> getChoicesIterator() { |
| 30 | 0 | return choices.listIterator(); |
| 31 | |
} |
| 32 | |
|
| 33 | |
public String toString() { |
| 34 | 0 | StringBuilder sb = new StringBuilder(super.toString()).append('('); |
| 35 | 0 | ListIterator<Node> it = getChoicesIterator(); |
| 36 | 0 | while (it.hasNext()) { |
| 37 | 0 | sb.append(it.next()); |
| 38 | 0 | if (it.hasNext()) sb.append(" or "); |
| 39 | |
} |
| 40 | 0 | return sb.append(')').toString() + '<' + firstToken + ">|<" + lastToken + '>'; |
| 41 | |
} |
| 42 | |
} |