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

org.anarres.graphviz.parser.node.AGraph 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 AGraph extends PGraph
{
    private PGraphType _graphType_;
    private PAtom _name_;
    private final LinkedList _statement_ = new LinkedList();

    public AGraph()
    {
        // Constructor
    }

    public AGraph(
        @SuppressWarnings("hiding") PGraphType _graphType_,
        @SuppressWarnings("hiding") PAtom _name_,
        @SuppressWarnings("hiding") List _statement_)
    {
        // Constructor
        setGraphType(_graphType_);

        setName(_name_);

        setStatement(_statement_);

    }

    @Override
    public Object clone()
    {
        return new AGraph(
            cloneNode(this._graphType_),
            cloneNode(this._name_),
            cloneList(this._statement_));
    }

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

    public PGraphType getGraphType()
    {
        return this._graphType_;
    }

    public void setGraphType(PGraphType node)
    {
        if(this._graphType_ != null)
        {
            this._graphType_.parent(null);
        }

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

            node.parent(this);
        }

        this._graphType_ = node;
    }

    public PAtom getName()
    {
        return this._name_;
    }

    public void setName(PAtom node)
    {
        if(this._name_ != null)
        {
            this._name_.parent(null);
        }

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

            node.parent(this);
        }

        this._name_ = node;
    }

    public LinkedList getStatement()
    {
        return this._statement_;
    }

    public void setStatement(List list)
    {
        this._statement_.clear();
        this._statement_.addAll(list);
        for(PStatement e : list)
        {
            if(e.parent() != null)
            {
                e.parent().removeChild(e);
            }

            e.parent(this);
        }
    }

    @Override
    public String toString()
    {
        return ""
            + toString(this._graphType_)
            + toString(this._name_)
            + toString(this._statement_);
    }

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

        if(this._name_ == child)
        {
            this._name_ = null;
            return;
        }

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

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

    @Override
    void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
    {
        // Replace child
        if(this._graphType_ == oldChild)
        {
            setGraphType((PGraphType) newChild);
            return;
        }

        if(this._name_ == oldChild)
        {
            setName((PAtom) newChild);
            return;
        }

        for(ListIterator i = this._statement_.listIterator(); i.hasNext();)
        {
            if(i.next() == oldChild)
            {
                if(newChild != null)
                {
                    i.set((PStatement) 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