001    /* This file was generated by SableCC (http://www.sablecc.org/). */
002    
003    package org.jdmp.core.script.jdmp.node;
004    
005    import java.util.*;
006    import org.jdmp.core.script.jdmp.analysis.*;
007    
008    @SuppressWarnings("nls")
009    public final class AScript extends PScript
010    {
011        private final LinkedList<PCommand> _commands_ = new LinkedList<PCommand>();
012    
013        public AScript()
014        {
015            // Constructor
016        }
017    
018        public AScript(
019            @SuppressWarnings("hiding") List<PCommand> _commands_)
020        {
021            // Constructor
022            setCommands(_commands_);
023    
024        }
025    
026        @Override
027        public Object clone()
028        {
029            return new AScript(
030                cloneList(this._commands_));
031        }
032    
033        public void apply(Switch sw)
034        {
035            ((Analysis) sw).caseAScript(this);
036        }
037    
038        public LinkedList<PCommand> getCommands()
039        {
040            return this._commands_;
041        }
042    
043        public void setCommands(List<PCommand> list)
044        {
045            this._commands_.clear();
046            this._commands_.addAll(list);
047            for(PCommand e : list)
048            {
049                if(e.parent() != null)
050                {
051                    e.parent().removeChild(e);
052                }
053    
054                e.parent(this);
055            }
056        }
057    
058        @Override
059        public String toString()
060        {
061            return ""
062                + toString(this._commands_);
063        }
064    
065        @Override
066        void removeChild(@SuppressWarnings("unused") Node child)
067        {
068            // Remove child
069            if(this._commands_.remove(child))
070            {
071                return;
072            }
073    
074            throw new RuntimeException("Not a child.");
075        }
076    
077        @Override
078        void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
079        {
080            // Replace child
081            for(ListIterator<PCommand> i = this._commands_.listIterator(); i.hasNext();)
082            {
083                if(i.next() == oldChild)
084                {
085                    if(newChild != null)
086                    {
087                        i.set((PCommand) newChild);
088                        newChild.parent(this);
089                        oldChild.parent(null);
090                        return;
091                    }
092    
093                    i.remove();
094                    oldChild.parent(null);
095                    return;
096                }
097            }
098    
099            throw new RuntimeException("Not a child.");
100        }
101    }