Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/port80/graph/dot/parser/SimpleNode.java


1   /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
2   
3   //
4   // Copyright(c) 2002, Chris Leung
5   //
6   
7   package com.port80.graph.dot.parser;
8   
9   public class SimpleNode implements Node {
10      protected Node parent;
11      protected Node[] children;
12      protected int id;
13      protected DotParser parser;
14  
15      public SimpleNode(int i) {
16          id = i;
17      }
18  
19      public SimpleNode(DotParser p, int i) {
20          this(i);
21          parser = p;
22      }
23  
24      public void jjtOpen() {}
25  
26      public void jjtClose() {}
27  
28      public void jjtSetParent(Node n) {
29          parent = n;
30      }
31      public Node jjtGetParent() {
32          return parent;
33      }
34  
35      public void jjtAddChild(Node n, int i) {
36          if (children == null) {
37              children = new Node[i + 1];
38          } else if (i >= children.length) {
39              Node c[] = new Node[i + 1];
40              System.arraycopy(children, 0, c, 0, children.length);
41              children = c;
42          }
43          children[i] = n;
44      }
45  
46      public Node jjtGetChild(int i) {
47          return children[i];
48      }
49  
50      public int jjtGetNumChildren() {
51          return (children == null) ? 0 : children.length;
52      }
53  
54      /** Accept the visitor. **/
55      public Object jjtAccept(DotParserVisitor visitor, Object data) {
56          return visitor.visit(this, data);
57      }
58  
59      /** Accept the visitor. **/
60      public Object childrenAccept(DotParserVisitor visitor, Object data) {
61          if (children != null) {
62              for (int i = 0; i < children.length; ++i) {
63                  children[i].jjtAccept(visitor, data);
64              }
65          }
66          return data;
67      }
68  
69      /* You can override these two methods in subclasses of SimpleNode to
70         customize the way the node appears when the tree is dumped.  If
71         your output uses more than one line you should override
72         toString(String), otherwise overriding toString() is probably all
73         you need to do. */
74  
75      public String toString() {
76          return DotParserTreeConstants.jjtNodeName[id];
77      }
78      public String toString(String prefix) {
79          return prefix + toString();
80      }
81  
82      /* Override this method if you want to customize how the node dumps
83         out its children. */
84  
85      public void dump(String prefix) {
86          System.out.println(toString(prefix));
87          if (children != null) {
88              for (int i = 0; i < children.length; ++i) {
89                  SimpleNode n = (SimpleNode)children[i];
90                  if (n != null) {
91                      n.dump(prefix + " ");
92                  }
93              }
94          }
95      }
96  
97      // End of generated code. //////////////////////////////////////////////
98  
99      protected String name = null;
100 
101     ////////////////////////////////////////////////////////////////////////
102 
103     public String getName() {
104         return name;
105     }
106     public void setName(String name) {
107         this.name = name;
108     }
109 
110     ////////////////////////////////////////////////////////////////////////
111 
112 
113 }
114