00001 00066 package com.arcle.rmt.superwaba.model.imp.rqml; 00067 00068 import superwaba.ext.xplat.io.Storable; 00069 import superwaba.ext.xplat.io.DataStream; 00070 00071 import com.arcle.rmt.rqml.*; 00072 import com.arcle.rmt.superwaba.model.imp.*; 00073 00080 public class ProductImpl extends RQMLSecondClassImpl implements Product { 00081 00082 public Name getName() { 00083 if (name == null) { 00084 name = createNameImpl(); 00085 } 00086 return name; 00087 } 00088 00089 00090 public Description getDescription() { 00091 if (description == null) { 00092 description = createDescriptionImpl(); 00093 } 00094 return description; 00095 } 00096 00097 //----------------------------------------------------------------------- 00098 // Factory Methods 00099 00100 public GenericMemento createMemento() { 00101 return new Memento(this); 00102 } 00103 00104 00105 //----------------------------------------------------------------------- 00106 // Member variables 00107 00108 private NameImpl name = null; 00109 00110 private DescriptionImpl description = null; 00111 00112 //----------------------------------------------------------------------- 00113 // Inner Classes 00114 00115 protected static class Memento extends RQMLSecondClassImpl.Memento { 00116 public Memento(ProductImpl originator) { 00117 super(originator); 00118 } 00119 00120 public Storable getInstance() { 00121 // This memento is not directly stored in the Catalog, 00122 // so this factory method is not required. 00123 return null; 00124 } 00125 00126 public byte getID() { 00127 return DocumentImpl.PRODUCT_ID; 00128 } 00129 00130 public void saveState(DataStream data) { 00131 final ProductImpl org = (ProductImpl) getOriginator(); 00132 super.saveState(data); 00133 saveMementoable(org.name, data); 00134 saveMementoable(org.description, data); 00135 } 00136 00137 public void loadState(DataStream data) { 00138 final ProductImpl org = (ProductImpl) getOriginator(); 00139 super.loadState(data); 00140 00141 org.name = (NameImpl) loadMementoable(data, new MementoableFactory() { 00142 public Mementoable createOriginator() { 00143 return org.createNameImpl(); 00144 } 00145 }); 00146 org.description = (DescriptionImpl) loadMementoable(data, new MementoableFactory() { 00147 public Mementoable createOriginator() { 00148 return org.createDescriptionImpl(); 00149 } 00150 }); 00151 } 00152 00153 } 00154 }