1 /* This file was generated by SableCC (http://www.sablecc.org/). */ 2 3 package com.google.clearsilver.jsilver.syntax.node; 4 5 import java.util.*; 6 7 @SuppressWarnings("nls") 8 public abstract class Node implements Switchable, Cloneable 9 { 10 private Node parent; 11 12 @Override 13 public abstract Object clone(); 14 15 public Node parent() 16 { 17 return this.parent; 18 } 19 20 void parent(@SuppressWarnings("hiding") Node parent) 21 { 22 this.parent = parent; 23 } 24 25 abstract void removeChild(Node child); 26 abstract void replaceChild(Node oldChild, Node newChild); 27 28 public void replaceBy(Node node) 29 { 30 this.parent.replaceChild(this, node); 31 } 32 33 protected String toString(Node node) 34 { 35 if(node != null) 36 { 37 return node.toString(); 38 } 39 40 return ""; 41 } 42 43 protected String toString(List list) 44 { 45 StringBuffer s = new StringBuffer(); 46 47 for(Iterator i = list.iterator(); i.hasNext();) 48 { 49 s.append(i.next()); 50 } 51 52 return s.toString(); 53 } 54 55 @SuppressWarnings("unchecked") 56 protected <T extends Node> T cloneNode(T node) 57 { 58 if(node != null) 59 { 60 return (T) node.clone(); 61 } 62 63 return null; 64 } 65 66 protected <T> List<T> cloneList(List<T> list) 67 { 68 List<T> clone = new LinkedList<T>(); 69 70 for(T n : list) 71 { 72 clone.add(n); 73 } 74 75 return clone; 76 } 77 } 78