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 ARow extends PRow
010    {
011        private PExpression _expression_;
012        private final LinkedList<PCommaValue> _additionalValues_ = new LinkedList<PCommaValue>();
013    
014        public ARow()
015        {
016            // Constructor
017        }
018    
019        public ARow(
020            @SuppressWarnings("hiding") PExpression _expression_,
021            @SuppressWarnings("hiding") List<PCommaValue> _additionalValues_)
022        {
023            // Constructor
024            setExpression(_expression_);
025    
026            setAdditionalValues(_additionalValues_);
027    
028        }
029    
030        @Override
031        public Object clone()
032        {
033            return new ARow(
034                cloneNode(this._expression_),
035                cloneList(this._additionalValues_));
036        }
037    
038        public void apply(Switch sw)
039        {
040            ((Analysis) sw).caseARow(this);
041        }
042    
043        public PExpression getExpression()
044        {
045            return this._expression_;
046        }
047    
048        public void setExpression(PExpression node)
049        {
050            if(this._expression_ != null)
051            {
052                this._expression_.parent(null);
053            }
054    
055            if(node != null)
056            {
057                if(node.parent() != null)
058                {
059                    node.parent().removeChild(node);
060                }
061    
062                node.parent(this);
063            }
064    
065            this._expression_ = node;
066        }
067    
068        public LinkedList<PCommaValue> getAdditionalValues()
069        {
070            return this._additionalValues_;
071        }
072    
073        public void setAdditionalValues(List<PCommaValue> list)
074        {
075            this._additionalValues_.clear();
076            this._additionalValues_.addAll(list);
077            for(PCommaValue e : list)
078            {
079                if(e.parent() != null)
080                {
081                    e.parent().removeChild(e);
082                }
083    
084                e.parent(this);
085            }
086        }
087    
088        @Override
089        public String toString()
090        {
091            return ""
092                + toString(this._expression_)
093                + toString(this._additionalValues_);
094        }
095    
096        @Override
097        void removeChild(@SuppressWarnings("unused") Node child)
098        {
099            // Remove child
100            if(this._expression_ == child)
101            {
102                this._expression_ = null;
103                return;
104            }
105    
106            if(this._additionalValues_.remove(child))
107            {
108                return;
109            }
110    
111            throw new RuntimeException("Not a child.");
112        }
113    
114        @Override
115        void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
116        {
117            // Replace child
118            if(this._expression_ == oldChild)
119            {
120                setExpression((PExpression) newChild);
121                return;
122            }
123    
124            for(ListIterator<PCommaValue> i = this._additionalValues_.listIterator(); i.hasNext();)
125            {
126                if(i.next() == oldChild)
127                {
128                    if(newChild != null)
129                    {
130                        i.set((PCommaValue) newChild);
131                        newChild.parent(this);
132                        oldChild.parent(null);
133                        return;
134                    }
135    
136                    i.remove();
137                    oldChild.parent(null);
138                    return;
139                }
140            }
141    
142            throw new RuntimeException("Not a child.");
143        }
144    }