Logo Search packages:      
Sourcecode: sablecc version File versions  Download package

AParsedAlt.java

/* This file was generated by SableCC (http://www.sablecc.org/). */

package org.sablecc.sablecc.node;

import java.util.*;
import org.sablecc.sablecc.analysis.*;

public final class AParsedAlt extends PAlt
{
  private PAltName _altName_;
  private final LinkedList _elems_ = new TypedLinkedList(new Elems_Cast());

  public AParsedAlt()
  {}

  public AParsedAlt(
    PAltName _altName_,
    List _elems_)
  {
    setAltName(_altName_);

    {
      this._elems_.clear();
      this._elems_.addAll(_elems_);
    }

  }

  public AParsedAlt(
    PAltName _altName_,
    XPElem _elems_)
  {
    setAltName(_altName_);

    if(_elems_ != null)
    {
      while(_elems_ instanceof X1PElem)
      {
        this._elems_.addFirst(((X1PElem) _elems_).getPElem());
        _elems_ = ((X1PElem) _elems_).getXPElem();
      }
      this._elems_.addFirst(((X2PElem) _elems_).getPElem());
    }

  }
  public Object clone()
  {
    return new AParsedAlt(
             (PAltName) cloneNode(_altName_),
             cloneList(_elems_));
  }

  public void apply(Switch sw)
  {
    ((Analysis) sw).caseAParsedAlt(this);
  }

  public PAltName getAltName()
  {
    return _altName_;
  }

  public void setAltName(PAltName node)
  {
    if(_altName_ != null)
    {
      _altName_.parent(null);
    }

    if(node != null)
    {
      if(node.parent() != null)
      {
        node.parent().removeChild(node);
      }

      node.parent(this);
    }

    _altName_ = node;
  }

  public LinkedList getElems()
  {
    return _elems_;
  }

  public void setElems(List list)
  {
    _elems_.clear();
    _elems_.addAll(list);
  }

  public String toString()
  {
    return ""
           + toString(_altName_)
           + toString(_elems_);
  }

  void removeChild(Node child)
  {
    if(_altName_ == child)
    {
      _altName_ = null;
      return;
    }

    if(_elems_.remove(child))
    {
      return;
    }

  }

  void replaceChild(Node oldChild, Node newChild)
  {
    if(_altName_ == oldChild)
    {
      setAltName((PAltName) newChild);
      return;
    }

    for(ListIterator i = _elems_.listIterator(); i.hasNext();)
    {
      if(i.next() == oldChild)
      {
        if(newChild != null)
        {
          i.set(newChild);
          oldChild.parent(null);
          return;
        }

        i.remove();
        oldChild.parent(null);
        return;
      }
    }

  }

  private class Elems_Cast implements Cast
  {
    public Object cast(Object o)
    {
      PElem node = (PElem) o;

      if((node.parent() != null) &&
          (node.parent() != AParsedAlt.this))
      {
        node.parent().removeChild(node);
      }

      if((node.parent() == null) ||
          (node.parent() != AParsedAlt.this))
      {
        node.parent(AParsedAlt.this);
      }

      return node;
    }
  }
}

Generated by  Doxygen 1.6.0   Back to index