00001 00066 package com.arcle.rmt.superwaba.model.imp.rqml; 00067 00068 import superwaba.ext.xplat.io.DataStream; 00069 import superwaba.ext.xplat.io.Storable; 00070 00071 import com.arcle.rmt.superwaba.framework.Model; 00072 import com.arcle.rmt.superwaba.util.VectorListAdapter; 00073 import com.arcle.rmt.xplat.util.List; 00074 00075 import com.arcle.rmt.rqml.*; 00076 import com.arcle.rmt.superwaba.model.imp.*; 00077 00084 public abstract class RQMLSecondClassImpl 00085 implements RQMLSecondClass, Mementoable, Model { 00086 00087 //----------------------------------------------------------------------- 00088 // RQMLSecondClass Implementation 00089 00090 public String getURI() { 00091 return uri; 00092 } 00093 00094 public void setURI(String URI) { 00095 uri = URI; 00096 } 00097 00098 00099 public String getID() { 00100 return id; 00101 } 00102 00103 00104 public void setID(String ID) { 00105 id = ID; 00106 } 00107 00108 //----------------------------------------------------------------------- 00109 // Still-Abstract methods. 00110 00111 public abstract GenericMemento createMemento(); 00112 00113 //----------------------------------------------------------------------- 00114 // Mementoable Implementation 00115 00119 public GenericMemento getMemento() { 00120 if(memento == null) { 00121 memento = (Memento) createMemento(); 00122 } 00123 return memento; 00124 } 00125 00126 public void setMemento(GenericMemento m) { 00127 // Since Mementos are given a live reference, this method 00128 // is not required. 00129 } 00130 00131 //----------------------------------------------------------------------- 00132 // Factory Methods 00133 00134 public List createList(int initialCapacity) { 00135 return new VectorListAdapter(initialCapacity); 00136 } 00137 00138 public List createList() { 00139 return createList(8); 00140 } 00141 00142 protected DescriptionImpl createDescriptionImpl() { 00143 return new DescriptionImpl(); 00144 } 00145 00146 protected NameImpl createNameImpl() { 00147 return new NameImpl(); 00148 } 00149 00150 00151 //----------------------------------------------------------------------- 00152 // Member Variables 00153 00154 private Memento memento = null; 00155 00156 public String uri = ""; 00157 public String id = ""; 00158 00159 00160 //----------------------------------------------------------------------- 00161 // Inner Classes 00162 00170 protected static abstract class Memento extends GenericMemento { 00171 00172 public Memento(RQMLSecondClassImpl originator) { 00173 super(originator); 00174 } 00175 00176 00177 //------------------------------------------------------------------- 00178 // Still-Abstract methods 00179 00180 public abstract byte getID(); 00181 00182 public abstract Storable getInstance(); 00183 00184 //------------------------------------------------------------------- 00185 // GenericMemento implementation 00186 00187 00188 public void saveState(DataStream data) { 00189 final RQMLSecondClassImpl org = (RQMLSecondClassImpl) getOriginator(); 00190 data.writeString(org.id); 00191 data.writeString(org.uri); 00192 } 00193 00194 00195 public void loadState(DataStream data) { 00196 final RQMLSecondClassImpl org = (RQMLSecondClassImpl) getOriginator(); 00197 org.id = data.readString(); 00198 org.uri = data.readString(); 00199 } 00200 } 00201 }