001    /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */
002    package org.extendj.ast;
003    
004    import java.util.HashSet;
005    import java.io.File;
006    import java.util.Set;
007    import java.util.Collections;
008    import java.util.Collection;
009    import java.util.ArrayList;
010    import beaver.*;
011    import java.util.*;
012    import java.io.ByteArrayOutputStream;
013    import java.io.PrintStream;
014    import java.lang.reflect.InvocationTargetException;
015    import java.lang.reflect.Method;
016    import org.jastadd.util.*;
017    import java.util.zip.*;
018    import java.io.*;
019    import org.jastadd.util.PrettyPrintable;
020    import org.jastadd.util.PrettyPrinter;
021    import java.io.FileNotFoundException;
022    import java.io.BufferedInputStream;
023    import java.io.DataInputStream;
024    /**
025     * @ast node
026     * @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:99
027     * @production IdUse : {@link ASTNode} ::= <span class="component">&lt;ID:String&gt;</span>;
028    
029     */
030    public class IdUse extends ASTNode<ASTNode> implements Cloneable {
031      /**
032       * @declaredat ASTNode:1
033       */
034      public IdUse() {
035        super();
036        is$Final(true);
037      }
038      /**
039       * Initializes the child array to the correct size.
040       * Initializes List and Opt nta children.
041       * @apilevel internal
042       * @ast method
043       * @declaredat ASTNode:11
044       */
045      public void init$Children() {
046      }
047      /**
048       * @declaredat ASTNode:13
049       */
050      public IdUse(String p0) {
051        setID(p0);
052        is$Final(true);
053      }
054      /**
055       * @declaredat ASTNode:17
056       */
057      public IdUse(beaver.Symbol p0) {
058        setID(p0);
059        is$Final(true);
060      }
061      /**
062       * @apilevel low-level
063       * @declaredat ASTNode:24
064       */
065      protected int numChildren() {
066        return 0;
067      }
068      /**
069       * @apilevel internal
070       * @declaredat ASTNode:30
071       */
072      public boolean mayHaveRewrite() {
073        return false;
074      }
075      /**
076       * @apilevel internal
077       * @declaredat ASTNode:36
078       */
079      public void flushAttrCache() {
080        super.flushAttrCache();
081      }
082      /**
083       * @apilevel internal
084       * @declaredat ASTNode:42
085       */
086      public void flushCollectionCache() {
087        super.flushCollectionCache();
088      }
089      /**
090       * @apilevel internal
091       * @declaredat ASTNode:48
092       */
093      public void flushRewriteCache() {
094        super.flushRewriteCache();
095      }
096      /**
097       * @apilevel internal
098       * @declaredat ASTNode:54
099       */
100      public IdUse clone() throws CloneNotSupportedException {
101        IdUse node = (IdUse) super.clone();
102        return node;
103      }
104      /**
105       * @apilevel internal
106       * @declaredat ASTNode:61
107       */
108      public IdUse copy() {
109        try {
110          IdUse node = (IdUse) clone();
111          node.parent = null;
112          if (children != null) {
113            node.children = (ASTNode[]) children.clone();
114          }
115          return node;
116        } catch (CloneNotSupportedException e) {
117          throw new Error("Error: clone not supported for " + getClass().getName());
118        }
119      }
120      /**
121       * Create a deep copy of the AST subtree at this node.
122       * The copy is dangling, i.e. has no parent.
123       * @return dangling copy of the subtree at this node
124       * @apilevel low-level
125       * @deprecated Please use treeCopy or treeCopyNoTransform instead
126       * @declaredat ASTNode:80
127       */
128      @Deprecated
129      public IdUse fullCopy() {
130        return treeCopyNoTransform();
131      }
132      /**
133       * Create a deep copy of the AST subtree at this node.
134       * The copy is dangling, i.e. has no parent.
135       * @return dangling copy of the subtree at this node
136       * @apilevel low-level
137       * @declaredat ASTNode:90
138       */
139      public IdUse treeCopyNoTransform() {
140        IdUse tree = (IdUse) copy();
141        if (children != null) {
142          for (int i = 0; i < children.length; ++i) {
143            ASTNode child = (ASTNode) children[i];
144            if (child != null) {
145              child = child.treeCopyNoTransform();
146              tree.setChild(child, i);
147            }
148          }
149        }
150        return tree;
151      }
152      /**
153       * Create a deep copy of the AST subtree at this node.
154       * The subtree of this node is traversed to trigger rewrites before copy.
155       * The copy is dangling, i.e. has no parent.
156       * @return dangling copy of the subtree at this node
157       * @apilevel low-level
158       * @declaredat ASTNode:110
159       */
160      public IdUse treeCopy() {
161        doFullTraversal();
162        return treeCopyNoTransform();
163      }
164      /**
165       * @apilevel internal
166       * @declaredat ASTNode:117
167       */
168      protected boolean is$Equal(ASTNode node) {
169        return super.is$Equal(node) && (tokenString_ID == ((IdUse)node).tokenString_ID);    
170      }
171      /**
172       * Replaces the lexeme ID.
173       * @param value The new value for the lexeme ID.
174       * @apilevel high-level
175       */
176      public void setID(String value) {
177        tokenString_ID = value;
178      }
179      /**
180       * @apilevel internal
181       */
182      protected String tokenString_ID;
183      /**
184       */
185      public int IDstart;
186      /**
187       */
188      public int IDend;
189      /**
190       * JastAdd-internal setter for lexeme ID using the Beaver parser.
191       * @param symbol Symbol containing the new value for the lexeme ID
192       * @apilevel internal
193       */
194      public void setID(beaver.Symbol symbol) {
195        if (symbol.value != null && !(symbol.value instanceof String))
196        throw new UnsupportedOperationException("setID is only valid for String lexemes");
197        tokenString_ID = (String)symbol.value;
198        IDstart = symbol.getStart();
199        IDend = symbol.getEnd();
200      }
201      /**
202       * Retrieves the value for the lexeme ID.
203       * @return The value for the lexeme ID.
204       * @apilevel high-level
205       */
206      @ASTNodeAnnotation.Token(name="ID")
207      public String getID() {
208        return tokenString_ID != null ? tokenString_ID : "";
209      }
210      /**
211       * @apilevel internal
212       */
213      public ASTNode rewriteTo() {
214        return super.rewriteTo();
215      }
216    }