KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sablecc > sablecc > syntax3 > node > AGroup


1 /* This file was generated by SableCC (http://www.sablecc.org/). */
2
3 package org.sablecc.sablecc.syntax3.node;
4
5 import java.util.*;
6 import org.sablecc.sablecc.syntax3.analysis.*;
7
8 @SuppressWarnings JavaDoc("nls")
9 public final class AGroup extends PGroup
10 {
11     private TIdentifier _name_;
12     private final LinkedList<PToken> _tokens_ = new LinkedList<PToken>();
13
14     public AGroup()
15     {
16         // Constructor
17
}
18
19     public AGroup(
20         @SuppressWarnings JavaDoc("hiding") TIdentifier _name_,
21         @SuppressWarnings JavaDoc("hiding") List<PToken> _tokens_)
22     {
23         // Constructor
24
setName(_name_);
25
26         setTokens(_tokens_);
27
28     }
29
30     @Override JavaDoc
31     public Object JavaDoc clone()
32     {
33         return new AGroup(
34             cloneNode(this._name_),
35             cloneList(this._tokens_));
36     }
37
38     public void apply(Switch sw)
39     {
40         ((Analysis) sw).caseAGroup(this);
41     }
42
43     public TIdentifier getName()
44     {
45         return this._name_;
46     }
47
48     public void setName(TIdentifier node)
49     {
50         if(this._name_ != null)
51         {
52             this._name_.parent(null);
53         }
54
55         if(node != null)
56         {
57             if(node.parent() != null)
58             {
59                 node.parent().removeChild(node);
60             }
61
62             node.parent(this);
63         }
64
65         this._name_ = node;
66     }
67
68     public LinkedList<PToken> getTokens()
69     {
70         return this._tokens_;
71     }
72
73     public void setTokens(List<PToken> list)
74     {
75         this._tokens_.clear();
76         this._tokens_.addAll(list);
77         for(PToken e : list)
78         {
79             if(e.parent() != null)
80             {
81                 e.parent().removeChild(e);
82             }
83
84             e.parent(this);
85         }
86     }
87
88     @Override JavaDoc
89     public String JavaDoc toString()
90     {
91         return ""
92             + toString(this._name_)
93             + toString(this._tokens_);
94     }
95
96     @Override JavaDoc
97     void removeChild(@SuppressWarnings JavaDoc("unused") Node child)
98     {
99         // Remove child
100
if(this._name_ == child)
101         {
102             this._name_ = null;
103             return;
104         }
105
106         if(this._tokens_.remove(child))
107         {
108             return;
109         }
110
111         throw new RuntimeException JavaDoc("Not a child.");
112     }
113
114     @Override JavaDoc
115     void replaceChild(@SuppressWarnings JavaDoc("unused") Node oldChild, @SuppressWarnings JavaDoc("unused") Node newChild)
116     {
117         // Replace child
118
if(this._name_ == oldChild)
119         {
120             setName((TIdentifier) newChild);
121             return;
122         }
123
124         for(ListIterator<PToken> i = this._tokens_.listIterator(); i.hasNext();)
125         {
126             if(i.next() == oldChild)
127             {
128                 if(newChild != null)
129                 {
130                     i.set((PToken) newChild);
131                     newChild.parent(this);
132                     oldChild.parent(null);
133                     return;
134                 }
135
136                 i.remove();
137                 oldChild.parent(null);
138                 return;
139             }
140         }
141
142         throw new RuntimeException JavaDoc("Not a child.");
143     }
144 }
145
Popular Tags