/* This file was generated with JastAdd2 (http://jastadd.org) version jenkins-JastAdd2-430 */
package AST;

/**
 * @production ParseName : {@link Name};
 * @ast node
 * @declaredat JavaDemoNames.ast:21
 */
public class ParseName extends Name implements Cloneable {
  /**
   * @apilevel internal
   */
  @SuppressWarnings({"unchecked", "cast"})
  public ParseName clone() throws CloneNotSupportedException {
    ParseName node = (ParseName) super.clone();
    node.in$Circle(false);
    node.is$Final(false);
    return node;
  }
  /**
   * @apilevel internal
   */
  @SuppressWarnings({"unchecked", "cast"})
  public ParseName copy() {
    try {
      ParseName node = (ParseName) clone();
      node.parent = null;
      if(children != null) {
        node.children = (ASTNode[]) children.clone();
      }
      return node;
    } catch (CloneNotSupportedException e) {
      throw new Error("Error: clone not supported for " + getClass().getName());
    }
  }
  /**
   * Create a deep copy of the AST subtree at this node.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   */
  @SuppressWarnings({"unchecked", "cast"})
  public ParseName fullCopy() {
    ParseName tree = (ParseName) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
        ASTNode child = (ASTNode) children[i];
        if(child != null) {
          child = child.fullCopy();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }
  /**
   * 
   * @ast method
   * 
   */

  public ParseName() {
    super();
  }
  /**
   * 
     * Initializes the child array to the correct size.
     * Initializes List and Opt nta children.
     * @apilevel internal
     * @ast method
     
   * @ast method
   * 
   */

  public void init$Children() {
  }
  /**
   * 
   * @ast method
   * 
   */

  public ParseName(String p0) {
    setname(p0);
  }
  /**
   * 
     * @apilevel low-level
     
   * @ast method
   * 
   */

  protected int numChildren() {
    return 0;
  }
  /**
   * 
     * @apilevel internal
     
   * @ast method
   * 
   */

  public boolean mayHaveRewrite() {
    return true;
  }
  /**
   * 
      * @apilevel low-level
      
   * @ast method
   * 
   */

  public void flushCache() {
    super.flushCache();
      }
  /**
   * 
      * @apilevel internal
      
   * @ast method
   * 
   */

  public void flushCollectionCache() {
    super.flushCollectionCache();
      }
  /**
   * 
     * Replaces the lexeme name.
     * @param value The new value for the lexeme name.
     * @apilevel high-level
     
   * @ast method
   * 
   */

  public void setname(String value) {
    tokenString_name = value;
  }
  /**
   * 
     * Retrieves the value for the lexeme name.
     * @return The value for the lexeme name.
     * @apilevel high-level
     
   * @ast method
   * 
   */

  public String getname() {
    return tokenString_name != null ? tokenString_name : "";
  }
  /**
   * @apilevel internal
   */
  public ASTNode rewriteTo() {    // Declared at @declaredat JavaDemoNames.jrag:131
    if (kind() == Kind.PACKAGE_NAME) {
      state().duringJavaDemoNames++;
      ASTNode result = rewriteRule0();
      state().duringJavaDemoNames--;
      return result;
    }    // Declared at @declaredat JavaDemoNames.jrag:133
    if (kind() == Kind.TYPE_NAME) {
      state().duringJavaDemoNames++;
      ASTNode result = rewriteRule1();
      state().duringJavaDemoNames--;
      return result;
    }    // Declared at @declaredat JavaDemoNames.jrag:135
    if (kind() == Kind.EXPRESSION_NAME) {
      state().duringJavaDemoNames++;
      ASTNode result = rewriteRule2();
      state().duringJavaDemoNames--;
      return result;
    }    // Declared at @declaredat JavaDemoNames.jrag:137
    if (kind() == Kind.PACKAGE_OR_TYPE_NAME) {
      state().duringJavaDemoNames++;
      ASTNode result = rewriteRule3();
      state().duringJavaDemoNames--;
      return result;
    }    // Declared at @declaredat JavaDemoNames.jrag:139
    if (kind() == Kind.AMBIGUOUS_NAME) {
      state().duringJavaDemoNames++;
      ASTNode result = rewriteRule4();
      state().duringJavaDemoNames--;
      return result;
    }    return super.rewriteTo();
  }  /**
   * @declaredat @declaredat JavaDemoNames.jrag:131
   * @apilevel internal
   */  private Name rewriteRule0() {
    return new PackageName(getname());
  }
  /**
   * @declaredat @declaredat JavaDemoNames.jrag:133
   * @apilevel internal
   */  private Name rewriteRule1() {
    return new TypeName(getname());
  }
  /**
   * @declaredat @declaredat JavaDemoNames.jrag:135
   * @apilevel internal
   */  private Name rewriteRule2() {
    return new ExpressionName(getname());
  }
  /**
   * @declaredat @declaredat JavaDemoNames.jrag:137
   * @apilevel internal
   */  private Name rewriteRule3() {
    return new PackageOrTypeName(getname());
  }
  /**
   * @declaredat @declaredat JavaDemoNames.jrag:139
   * @apilevel internal
   */  private Name rewriteRule4() {
    return new AmbiguousName(getname());
  }
}
