Coverage Report - org.webslinger.ext.wiki.parser.SimpleNode
 
Classes in this File Line Coverage Branch Coverage Complexity
SimpleNode
66%
29/44
33%
1/3
0
 
 1  
 /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
 2  
 
 3  
 package org.webslinger.ext.wiki.parser;
 4  
 
 5  
 import java.util.ArrayList;
 6  
 import java.util.ListIterator;
 7  
 
 8  10
 public class SimpleNode implements Node {
 9  
     protected Node parent;
 10  217
     protected ArrayList<Node> children = new ArrayList<Node>();
 11  
     protected int id;
 12  
     protected Wiki parser;
 13  
     protected Token firstToken, lastToken;
 14  
 
 15  217
     public SimpleNode(int i) {
 16  217
         id = i;
 17  217
     }
 18  
 
 19  
     public SimpleNode(Wiki p, int i) {
 20  217
         this(i);
 21  217
         parser = p;
 22  217
     }
 23  
 
 24  
     public void jjtOpen() {
 25  207
     }
 26  
 
 27  
     public void jjtClose() {
 28  206
     }
 29  
 
 30  204
     public void jjtSetParent(Node n) { parent = n; }
 31  1
     public Node jjtGetParent() { return parent; }
 32  
 
 33  
     public void jjtAddChild(Node n, int i) {
 34  
         //System.err.println("SimpleNode.jjtAddChild(" + n + ", " + i + ")");
 35  408
         while (children.size() < i + 1) children.add(null);
 36  204
         children.set(i, n);
 37  
         /*
 38  
         if (!(n instanceof WikiText)) return;
 39  
         // try to merge
 40  
         System.err.println("CHECKING MERGE(" + i + ", " + jjtGetNumChildren() + ")");
 41  
         for (int j = i - 1; j < i + 1 && j + 1 < jjtGetNumChildren(); j++) {
 42  
             if (j < 0) continue;
 43  
             System.err.println("j=" + j);
 44  
             Node current = jjtGetChild(j);
 45  
             Node next = jjtGetChild(j + 1);
 46  
             System.err.println("current(" + current + ") next(" + next + ")");
 47  
             if (!(current instanceof WikiText)) continue;
 48  
             if (!(next instanceof WikiText)) continue;
 49  
             ((WikiText) current).addText(((WikiText) next).getText());
 50  
             jjtRemoveChild(j + 1);
 51  
         }
 52  
         */
 53  204
     }
 54  
 
 55  
     public void jjtRemoveChild(int i) {
 56  0
         children.remove(i);
 57  0
     }
 58  
 
 59  
     public Node jjtGetChild(int i) {
 60  38
         return children.get(i);
 61  
     }
 62  
 
 63  
     public int jjtGetNumChildren() {
 64  43
         return children.size();
 65  
     }
 66  
 
 67  
     /** Accept the visitor. **/
 68  
     public Object jjtAccept(WikiVisitor visitor, Object data) {
 69  0
         return visitor.visit(this, data);
 70  
     }
 71  
 
 72  
     /** Accept the visitor. **/
 73  
     public Object childrenAccept(WikiVisitor visitor, Object data) {
 74  0
         for (Node child: this) {
 75  0
             child.jjtAccept(visitor, data);
 76  
         }
 77  0
         return data;
 78  
     }
 79  
 
 80  
     public ListIterator<Node> getChildrenIterator() {
 81  396
         return children.listIterator();
 82  
     }
 83  
 
 84  
     public ListIterator<Node> iterator() {
 85  10
         return getChildrenIterator();
 86  
     }
 87  
 
 88  
     /* You can override these two methods in subclasses of SimpleNode to
 89  
          customize the way the node appears when the tree is dumped.    If
 90  
          your output uses more than one line you should override
 91  
          toString(String), otherwise overriding toString() is probably all
 92  
          you need to do. */
 93  
 
 94  0
     public String toString() { return WikiTreeConstants.jjtNodeName[id]; }
 95  0
     public String toString(String prefix) { return prefix + toString(); }
 96  
 
 97  
     /* Override this method if you want to customize how the node dumps
 98  
          out its children. */
 99  
 
 100  
     public void dump(String prefix) {
 101  0
         System.err.println(toString(prefix));
 102  0
         ListIterator<Node> it = getChildrenIterator();
 103  0
         while (it.hasNext()) {
 104  0
             SimpleNode child = (SimpleNode) it.next();
 105  0
             child.dump(prefix + " ");
 106  0
         }
 107  0
     }
 108  
 
 109  
     public Token getFirstToken() {
 110  2
         return firstToken;
 111  
     }
 112  
 
 113  
     public void setFirstToken(Token firstToken) {
 114  2
         this.firstToken = firstToken;
 115  2
     }
 116  
 
 117  
     public Token getLastToken() {
 118  24
         return lastToken;
 119  
     }
 120  
 
 121  
     public void setLastToken(Token lastToken) {
 122  230
         this.lastToken = lastToken;
 123  230
     }
 124  
 
 125  
     public WikiParagraph getEmptyParagraph() {
 126  2
         return new WikiParagraph(parser, WikiTreeConstants.JJTPARAGRAPH);
 127  
     }
 128  
 
 129  
     public WikiOrderedList getEmptyOrderedList() {
 130  1
         return new WikiOrderedList(parser, WikiTreeConstants.JJTORDEREDLIST);
 131  
     }
 132  
 
 133  
     public WikiUnorderedList getEmptyUnorderedList() {
 134  1
         return new WikiUnorderedList(parser, WikiTreeConstants.JJTUNORDEREDLIST);
 135  
     }
 136  
 
 137  
     public WikiListItem getEmptyListItem() {
 138  6
         return new WikiListItem(parser, WikiTreeConstants.JJTLISTITEM);
 139  
     }
 140  
 }