00001 package edu.ksu.cis.bandera.specification.node;
00002
00003
00004
00005 import java.util.*;
00006 import edu.ksu.cis.bandera.specification.analysis.*;
00007
00008 public abstract class Node implements Switchable, Cloneable
00009 {
00010 private Node parent;
00011
00012 public abstract Object clone();
00013 protected List cloneList(List list)
00014 {
00015 List clone = new LinkedList();
00016
00017 for(Iterator i = list.iterator(); i.hasNext();)
00018 {
00019 clone.add(((Node) i.next()).clone());
00020 }
00021
00022 return clone;
00023 }
00024 protected Node cloneNode(Node node)
00025 {
00026 if(node != null)
00027 {
00028 return (Node) node.clone();
00029 }
00030
00031 return null;
00032 }
00033 public Node parent()
00034 {
00035 return parent;
00036 }
00037 void parent(Node parent)
00038 {
00039 this.parent = parent;
00040 }
00041 abstract void removeChild(Node child);
00042 public void replaceBy(Node node)
00043 {
00044 if(parent != null)
00045 {
00046 parent.replaceChild(this, node);
00047 }
00048 }
00049 abstract void replaceChild(Node oldChild, Node newChild);
00050 protected String toString(Node node)
00051 {
00052 if(node != null)
00053 {
00054 return node.toString();
00055 }
00056
00057 return "";
00058 }
00059 protected String toString(List list)
00060 {
00061 StringBuffer s = new StringBuffer();
00062
00063 for(Iterator i = list.iterator(); i.hasNext();)
00064 {
00065 s.append(i.next());
00066 }
00067
00068 return s.toString();
00069 }
00070 }