001/* This file was generated by SableCC (http://www.sablecc.org/). */ 002 003package org.anarres.graphviz.parser.node; 004 005import java.util.*; 006import org.anarres.graphviz.parser.analysis.*; 007 008@SuppressWarnings("nls") 009public final class AComposite extends PComposite 010{ 011 private final LinkedList<PNode> _node_ = new LinkedList<PNode>(); 012 private final LinkedList<PAttribute> _attribute_ = new LinkedList<PAttribute>(); 013 014 public AComposite() 015 { 016 // Constructor 017 } 018 019 public AComposite( 020 @SuppressWarnings("hiding") List<PNode> _node_, 021 @SuppressWarnings("hiding") List<PAttribute> _attribute_) 022 { 023 // Constructor 024 setNode(_node_); 025 026 setAttribute(_attribute_); 027 028 } 029 030 @Override 031 public Object clone() 032 { 033 return new AComposite( 034 cloneList(this._node_), 035 cloneList(this._attribute_)); 036 } 037 038 public void apply(Switch sw) 039 { 040 ((Analysis) sw).caseAComposite(this); 041 } 042 043 public LinkedList<PNode> getNode() 044 { 045 return this._node_; 046 } 047 048 public void setNode(List<PNode> list) 049 { 050 this._node_.clear(); 051 this._node_.addAll(list); 052 for(PNode e : list) 053 { 054 if(e.parent() != null) 055 { 056 e.parent().removeChild(e); 057 } 058 059 e.parent(this); 060 } 061 } 062 063 public LinkedList<PAttribute> getAttribute() 064 { 065 return this._attribute_; 066 } 067 068 public void setAttribute(List<PAttribute> list) 069 { 070 this._attribute_.clear(); 071 this._attribute_.addAll(list); 072 for(PAttribute e : list) 073 { 074 if(e.parent() != null) 075 { 076 e.parent().removeChild(e); 077 } 078 079 e.parent(this); 080 } 081 } 082 083 @Override 084 public String toString() 085 { 086 return "" 087 + toString(this._node_) 088 + toString(this._attribute_); 089 } 090 091 @Override 092 void removeChild(@SuppressWarnings("unused") Node child) 093 { 094 // Remove child 095 if(this._node_.remove(child)) 096 { 097 return; 098 } 099 100 if(this._attribute_.remove(child)) 101 { 102 return; 103 } 104 105 throw new RuntimeException("Not a child."); 106 } 107 108 @Override 109 void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild) 110 { 111 // Replace child 112 for(ListIterator<PNode> i = this._node_.listIterator(); i.hasNext();) 113 { 114 if(i.next() == oldChild) 115 { 116 if(newChild != null) 117 { 118 i.set((PNode) newChild); 119 newChild.parent(this); 120 oldChild.parent(null); 121 return; 122 } 123 124 i.remove(); 125 oldChild.parent(null); 126 return; 127 } 128 } 129 130 for(ListIterator<PAttribute> i = this._attribute_.listIterator(); i.hasNext();) 131 { 132 if(i.next() == oldChild) 133 { 134 if(newChild != null) 135 { 136 i.set((PAttribute) newChild); 137 newChild.parent(this); 138 oldChild.parent(null); 139 return; 140 } 141 142 i.remove(); 143 oldChild.parent(null); 144 return; 145 } 146 } 147 148 throw new RuntimeException("Not a child."); 149 } 150}