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

AHelpers.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 AHelpers extends PHelpers
{
  private THelpers _helpers_;
  private final LinkedList _helperDefs_ = new TypedLinkedList(new HelperDefs_Cast());

  public AHelpers()
  {}

  public AHelpers(
    THelpers _helpers_,
    List _helperDefs_)
  {
    setHelpers(_helpers_);

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

  }

  public AHelpers(
    THelpers _helpers_,
    XPHelperDef _helperDefs_)
  {
    setHelpers(_helpers_);

    if(_helperDefs_ != null)
    {
      while(_helperDefs_ instanceof X1PHelperDef)
      {
        this._helperDefs_.addFirst(((X1PHelperDef) _helperDefs_).getPHelperDef());
        _helperDefs_ = ((X1PHelperDef) _helperDefs_).getXPHelperDef();
      }
      this._helperDefs_.addFirst(((X2PHelperDef) _helperDefs_).getPHelperDef());
    }

  }
  public Object clone()
  {
    return new AHelpers(
             (THelpers) cloneNode(_helpers_),
             cloneList(_helperDefs_));
  }

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

  public THelpers getHelpers()
  {
    return _helpers_;
  }

  public void setHelpers(THelpers node)
  {
    if(_helpers_ != null)
    {
      _helpers_.parent(null);
    }

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

      node.parent(this);
    }

    _helpers_ = node;
  }

  public LinkedList getHelperDefs()
  {
    return _helperDefs_;
  }

  public void setHelperDefs(List list)
  {
    _helperDefs_.clear();
    _helperDefs_.addAll(list);
  }

  public String toString()
  {
    return ""
           + toString(_helpers_)
           + toString(_helperDefs_);
  }

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

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

  }

  void replaceChild(Node oldChild, Node newChild)
  {
    if(_helpers_ == oldChild)
    {
      setHelpers((THelpers) newChild);
      return;
    }

    for(ListIterator i = _helperDefs_.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 HelperDefs_Cast implements Cast
  {
    public Object cast(Object o)
    {
      PHelperDef node = (PHelperDef) o;

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

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

      return node;
    }
  }
}

Generated by  Doxygen 1.6.0   Back to index