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

APkgName.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 APkgName extends PPkgName
{
  private TPkgId _pkgId_;
  private final LinkedList _pkgIds_ = new TypedLinkedList(new PkgIds_Cast());
  private TSemicolon _semicolon_;

  public APkgName()
  {}

  public APkgName(
    TPkgId _pkgId_,
    List _pkgIds_,
    TSemicolon _semicolon_)
  {
    setPkgId(_pkgId_);

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

    setSemicolon(_semicolon_);

  }

  public APkgName(
    TPkgId _pkgId_,
    XPPkgNameTail _pkgIds_,
    TSemicolon _semicolon_)
  {
    setPkgId(_pkgId_);

    if(_pkgIds_ != null)
    {
      while(_pkgIds_ instanceof X1PPkgNameTail)
      {
        this._pkgIds_.addFirst(((X1PPkgNameTail) _pkgIds_).getPPkgNameTail());
        _pkgIds_ = ((X1PPkgNameTail) _pkgIds_).getXPPkgNameTail();
      }
      this._pkgIds_.addFirst(((X2PPkgNameTail) _pkgIds_).getPPkgNameTail());
    }

    setSemicolon(_semicolon_);

  }
  public Object clone()
  {
    return new APkgName(
             (TPkgId) cloneNode(_pkgId_),
             cloneList(_pkgIds_),
             (TSemicolon) cloneNode(_semicolon_));
  }

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

  public TPkgId getPkgId()
  {
    return _pkgId_;
  }

  public void setPkgId(TPkgId node)
  {
    if(_pkgId_ != null)
    {
      _pkgId_.parent(null);
    }

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

      node.parent(this);
    }

    _pkgId_ = node;
  }

  public LinkedList getPkgIds()
  {
    return _pkgIds_;
  }

  public void setPkgIds(List list)
  {
    _pkgIds_.clear();
    _pkgIds_.addAll(list);
  }

  public TSemicolon getSemicolon()
  {
    return _semicolon_;
  }

  public void setSemicolon(TSemicolon node)
  {
    if(_semicolon_ != null)
    {
      _semicolon_.parent(null);
    }

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

      node.parent(this);
    }

    _semicolon_ = node;
  }

  public String toString()
  {
    return ""
           + toString(_pkgId_)
           + toString(_pkgIds_)
           + toString(_semicolon_);
  }

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

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

    if(_semicolon_ == child)
    {
      _semicolon_ = null;
      return;
    }

  }

  void replaceChild(Node oldChild, Node newChild)
  {
    if(_pkgId_ == oldChild)
    {
      setPkgId((TPkgId) newChild);
      return;
    }

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

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

    if(_semicolon_ == oldChild)
    {
      setSemicolon((TSemicolon) newChild);
      return;
    }

  }

  private class PkgIds_Cast implements Cast
  {
    public Object cast(Object o)
    {
      PPkgNameTail node = (PPkgNameTail) o;

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

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

      return node;
    }
  }
}

Generated by  Doxygen 1.6.0   Back to index