KickJava   Java API By Example, From Geeks To Geeks.

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


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 ASubsetTokenCollection extends PTokenCollection
10 {
11     private final LinkedList<TIdentifier> _identifiers_ = new LinkedList<TIdentifier>();
12     private final LinkedList<TIdentifier> _excludedIdentifiers_ = new LinkedList<TIdentifier>();
13
14     public ASubsetTokenCollection()
15     {
16         // Constructor
17
}
18
19     public ASubsetTokenCollection(
20         @SuppressWarnings JavaDoc("hiding") List<TIdentifier> _identifiers_,
21         @SuppressWarnings JavaDoc("hiding") List<TIdentifier> _excludedIdentifiers_)
22     {
23         // Constructor
24
setIdentifiers(_identifiers_);
25
26         setExcludedIdentifiers(_excludedIdentifiers_);
27
28     }
29
30     @Override JavaDoc
31     public Object JavaDoc clone()
32     {
33         return new ASubsetTokenCollection(
34             cloneList(this._identifiers_),
35             cloneList(this._excludedIdentifiers_));
36     }
37
38     public void apply(Switch sw)
39     {
40         ((Analysis) sw).caseASubsetTokenCollection(this);
41     }
42
43     public LinkedList<TIdentifier> getIdentifiers()
44     {
45         return this._identifiers_;
46     }
47
48     public void setIdentifiers(List<TIdentifier> list)
49     {
50         this._identifiers_.clear();
51         this._identifiers_.addAll(list);
52         for(TIdentifier e : list)
53         {
54             if(e.parent() != null)
55             {
56                 e.parent().removeChild(e);
57             }
58
59             e.parent(this);
60         }
61     }
62
63     public LinkedList<TIdentifier> getExcludedIdentifiers()
64     {
65         return this._excludedIdentifiers_;
66     }
67
68     public void setExcludedIdentifiers(List<TIdentifier> list)
69     {
70         this._excludedIdentifiers_.clear();
71         this._excludedIdentifiers_.addAll(list);
72         for(TIdentifier e : list)
73         {
74             if(e.parent() != null)
75             {
76                 e.parent().removeChild(e);
77             }
78
79             e.parent(this);
80         }
81     }
82
83     @Override JavaDoc
84     public String JavaDoc toString()
85     {
86         return ""
87             + toString(this._identifiers_)
88             + toString(this._excludedIdentifiers_);
89     }
90
91     @Override JavaDoc
92     void removeChild(@SuppressWarnings JavaDoc("unused") Node child)
93     {
94         // Remove child
95
if(this._identifiers_.remove(child))
96         {
97             return;
98         }
99
100         if(this._excludedIdentifiers_.remove(child))
101         {
102             return;
103         }
104
105         throw new RuntimeException JavaDoc("Not a child.");
106     }
107
108     @Override JavaDoc
109     void replaceChild(@SuppressWarnings JavaDoc("unused") Node oldChild, @SuppressWarnings JavaDoc("unused") Node newChild)
110     {
111         // Replace child
112
for(ListIterator<TIdentifier> i = this._identifiers_.listIterator(); i.hasNext();)
113         {
114             if(i.next() == oldChild)
115             {
116                 if(newChild != null)
117                 {
118                     i.set((TIdentifier) newChild);
119                     newChild.parent(this);
120                     oldChild.parent(null);
121                     return;
122                 }
123
124                 i.remove();
125                 oldChild.parent(null);
126                 return;
127             }
128         }
129
130         for(ListIterator<TIdentifier> i = this._excludedIdentifiers_.listIterator(); i.hasNext();)
131         {
132             if(i.next() == oldChild)
133             {
134                 if(newChild != null)
135                 {
136                     i.set((TIdentifier) newChild);
137                     newChild.parent(this);
138                     oldChild.parent(null);
139                     return;
140                 }
141
142                 i.remove();
143                 oldChild.parent(null);
144                 return;
145             }
146         }
147
148         throw new RuntimeException JavaDoc("Not a child.");
149     }
150 }
151
Popular Tags