00001 package ;
00002
00003
00011
00012
00013 import config.*;
00014
00015
00016
00017
00018 import .RodMUR;
00019 import .RodMUR_Helper;
00020 import .Slave;
00021 import .Slave_Helper;
00022
00023
00024 class Rod_Impl implements Rod {
00025
00026
00027
00028 private config.Configuration p_db;
00029 private config.ConfigObject p_obj;
00030 private boolean p_was_read;
00031 private boolean p_is_valid;
00032 private String p_uid;
00033 private String p_class_name;
00034
00035
00036
00037
00038 private short m_id;
00039 private short m_slot;
00040
00041
00042
00043
00044 private Slave[] m_slaves;
00045 private RodMUR[] m_rodMURs;
00046
00047
00048
00049
00050
00051 public Rod_Impl() {
00052 p_is_valid = false;
00053 }
00054
00055 public Rod_Impl(config.Configuration db, config.ConfigObject obj) {
00056 init_config_params(db, obj);
00057 }
00058
00059 public void init_config_params(config.Configuration db, config.ConfigObject obj) {
00060 p_db = db;
00061 p_obj = obj;
00062 p_was_read = false;
00063 p_is_valid = true;
00064 p_uid = p_obj.UID();
00065 p_class_name = p_obj.class_name();
00066 }
00067
00068 public String UID() {
00069 return p_uid;
00070 }
00071
00072 public String class_name() {
00073 return p_class_name;
00074 }
00075
00076 public void update(boolean set_non_valid) {
00077 if(set_non_valid == true) {
00078 p_is_valid = false;
00079 }
00080 else {
00081 p_was_read = false;
00082 p_obj.clean();
00083 init();
00084 }
00085 }
00086
00087 public void unread() {
00088 p_was_read = false;
00089 }
00090
00091 public boolean is_valid() {
00092 return p_is_valid;
00093 }
00094
00095
00096
00097 private void init() throws config.NotFoundException, config.NotValidException, config.SystemException {
00098 if(p_was_read == true) {return;}
00099
00100 if(p_is_valid == false) {
00101 String text = "ERROR [.Rod_Impl.init()]: object " + p_uid + "@" + p_class_name + " is not valid";
00102 System.err.println(text);
00103 throw new config.NotValidException(text);
00104 }
00105
00106 m_id = p_obj.get_short("id");
00107
00108 m_slot = p_obj.get_short("slot");
00109
00110 {
00111 ConfigObject[] objs = p_obj.get_objects("slaves");
00112 m_slaves = new Slave[objs.length];
00113 for( int i = 0; i < objs.length; i++ ) {
00114 m_slaves[i] = Slave_Helper.get(p_db, objs[i]);
00115 }
00116 }
00117
00118 {
00119 ConfigObject[] objs = p_obj.get_objects("rodMURs");
00120 m_rodMURs = new RodMUR[objs.length];
00121 for( int i = 0; i < objs.length; i++ ) {
00122 m_rodMURs[i] = RodMUR_Helper.get(p_db, objs[i]);
00123 }
00124 }
00125
00126
00127 p_was_read = true;
00128
00129 }
00130
00131 public short get_id() {
00132 if(p_was_read == false) {init();}
00133 return m_id;
00134 }
00135
00136 public void set_id(short value) {
00137 p_obj.clean();
00138 p_obj.set_short("id", value);
00139 }
00140
00141 public short get_slot() {
00142 if(p_was_read == false) {init();}
00143 return m_slot;
00144 }
00145
00146 public void set_slot(short value) {
00147 p_obj.clean();
00148 p_obj.set_short("slot", value);
00149 }
00150
00151 public Slave[] get_slaves() {
00152 if(p_was_read == false) {init();}
00153 return m_slaves;
00154 }
00155
00156 public void set_slaves(Slave[] value) {
00157 p_obj.clean();
00158 config.ConfigObject[] objs = new config.ConfigObject[value.length];
00159 for(int i = 0; i < value.length; i++) {
00160 objs[i] = value[i].config_object();
00161 }
00162 p_obj.set_objects("slaves", objs);
00163 }
00164
00165 public RodMUR[] get_rodMURs() {
00166 if(p_was_read == false) {init();}
00167 return m_rodMURs;
00168 }
00169
00170 public void set_rodMURs(RodMUR[] value) {
00171 p_obj.clean();
00172 config.ConfigObject[] objs = new config.ConfigObject[value.length];
00173 for(int i = 0; i < value.length; i++) {
00174 objs[i] = value[i].config_object();
00175 }
00176 p_obj.set_objects("rodMURs", objs);
00177 }
00178
00179 public config.ConfigObject config_object() {
00180 return p_obj;
00181 }
00182
00183 public void print(String dx) {
00184 System.out.println(dx + "Rod object:" );
00185 System.out.println(dx + " id: \'" + UID() + "\', class name: \'" + class_name() + "\'");
00186
00187
00188
00189
00190 System.out.println(dx + " id: " + get_id());
00191 System.out.println(dx + " slot: " + get_slot());
00192
00193
00194
00195
00196 if(get_slaves().length > 0) {
00197 System.out.print(dx + " " + get_slaves().length + " object(s) in slaves :\n");
00198
00199 for(int i = 0; i < get_slaves().length; i++) {
00200 get_slaves()[i].print(dx.concat(" "));
00201 }
00202 }
00203 else {
00204 System.out.println(dx + " slaves value is empty");
00205 }
00206
00207 if(get_rodMURs().length > 0) {
00208 System.out.print(dx + " " + get_rodMURs().length + " object(s) in rodMURs :\n");
00209
00210 for(int i = 0; i < get_rodMURs().length; i++) {
00211 get_rodMURs()[i].print(dx.concat(" "));
00212 }
00213 }
00214 else {
00215 System.out.println(dx + " rodMURs value is empty");
00216 }
00217
00218 }
00219
00225 public void destroy(config.Configuration db) {
00226 db.destroy(config_object());
00227 }
00228 }