All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.anarres.graphviz.parser.node.AComposite Maven / Gradle / Ivy

There is a newer version: 1.0.12
Show newest version
/* This file was generated by SableCC (http://www.sablecc.org/). */

package org.anarres.graphviz.parser.node;

import java.util.*;
import org.anarres.graphviz.parser.analysis.*;

@SuppressWarnings("nls")
public final class AComposite extends PComposite
{
    private final LinkedList _node_ = new LinkedList();
    private final LinkedList _attribute_ = new LinkedList();

    public AComposite()
    {
        // Constructor
    }

    public AComposite(
        @SuppressWarnings("hiding") List _node_,
        @SuppressWarnings("hiding") List _attribute_)
    {
        // Constructor
        setNode(_node_);

        setAttribute(_attribute_);

    }

    @Override
    public Object clone()
    {
        return new AComposite(
            cloneList(this._node_),
            cloneList(this._attribute_));
    }

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

    public LinkedList getNode()
    {
        return this._node_;
    }

    public void setNode(List list)
    {
        this._node_.clear();
        this._node_.addAll(list);
        for(PNode e : list)
        {
            if(e.parent() != null)
            {
                e.parent().removeChild(e);
            }

            e.parent(this);
        }
    }

    public LinkedList getAttribute()
    {
        return this._attribute_;
    }

    public void setAttribute(List list)
    {
        this._attribute_.clear();
        this._attribute_.addAll(list);
        for(PAttribute e : list)
        {
            if(e.parent() != null)
            {
                e.parent().removeChild(e);
            }

            e.parent(this);
        }
    }

    @Override
    public String toString()
    {
        return ""
            + toString(this._node_)
            + toString(this._attribute_);
    }

    @Override
    void removeChild(@SuppressWarnings("unused") Node child)
    {
        // Remove child
        if(this._node_.remove(child))
        {
            return;
        }

        if(this._attribute_.remove(child))
        {
            return;
        }

        throw new RuntimeException("Not a child.");
    }

    @Override
    void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
    {
        // Replace child
        for(ListIterator i = this._node_.listIterator(); i.hasNext();)
        {
            if(i.next() == oldChild)
            {
                if(newChild != null)
                {
                    i.set((PNode) newChild);
                    newChild.parent(this);
                    oldChild.parent(null);
                    return;
                }

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

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

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

        throw new RuntimeException("Not a child.");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy