SCT_Module_Impl.java

00001 package ;
00002 
00003 
00011   // import configuration classes
00012 
00013 import config.*;
00014 
00015 
00016   // import used generated classes
00017 
00018 import .SCT_Chip;
00019 import .SCT_Chip_Helper;
00020 
00021 
00022 class SCT_Module_Impl implements SCT_Module {
00023 
00024     // base attributes
00025 
00026   private config.Configuration p_db;
00027   private config.ConfigObject p_obj;
00028   private boolean p_was_read;
00029   private boolean p_is_valid;
00030   private String p_uid;
00031   private String p_class_name;
00032 
00033 
00034     // database class attributes
00035 
00036   private String m_sn;
00037   private String m_source;
00038   private String m_location;
00039   private boolean m_active;
00040   private short m_select;
00041 
00042 
00043     // database class relationships
00044 
00045   private SCT_Chip[] m_Chips;
00046 
00047 
00048 
00049     // constructor
00050 
00051   public SCT_Module_Impl() {
00052     p_is_valid = false;
00053   }
00054 
00055   public SCT_Module_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 [.SCT_Module_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_sn = p_obj.get_string("sn");
00107     m_sn = (String)p_db.convert((Object)m_sn, p_obj, "sn");
00108 
00109     m_source = p_obj.get_string("source");
00110     m_source = (String)p_db.convert((Object)m_source, p_obj, "source");
00111 
00112     m_location = p_obj.get_string("location");
00113     m_location = (String)p_db.convert((Object)m_location, p_obj, "location");
00114 
00115     m_active = p_obj.get_bool("active");
00116 
00117     m_select = p_obj.get_short("select");
00118 
00119     {
00120       ConfigObject[] objs = p_obj.get_objects("Chips");
00121       m_Chips = new SCT_Chip[objs.length];
00122       for( int i = 0; i < objs.length; i++ ) {
00123         m_Chips[i] = SCT_Chip_Helper.get(p_db, objs[i]);
00124       }
00125     }
00126     
00127 
00128     p_was_read = true;
00129 
00130   }
00131 
00132   public String get_sn() {
00133     if(p_was_read == false) {init();}
00134     return m_sn;
00135   }
00136 
00137   public void set_sn(String value) {
00138     p_obj.clean();
00139     p_obj.set_string("sn", value);
00140   }
00141 
00142   public String get_source() {
00143     if(p_was_read == false) {init();}
00144     return m_source;
00145   }
00146 
00147   public void set_source(String value) {
00148     p_obj.clean();
00149     p_obj.set_string("source", value);
00150   }
00151 
00152   public String get_location() {
00153     if(p_was_read == false) {init();}
00154     return m_location;
00155   }
00156 
00157   public void set_location(String value) {
00158     p_obj.clean();
00159     p_obj.set_string("location", value);
00160   }
00161 
00162   public boolean get_active() {
00163     if(p_was_read == false) {init();}
00164     return m_active;
00165   }
00166 
00167   public void set_active(boolean value) {
00168     p_obj.clean();
00169     p_obj.set_bool("active", value);
00170   }
00171 
00172   public short get_select() {
00173     if(p_was_read == false) {init();}
00174     return m_select;
00175   }
00176 
00177   public void set_select(short value) {
00178     p_obj.clean();
00179     p_obj.set_short("select", value);
00180   }
00181 
00182   public SCT_Chip[] get_Chips() {
00183     if(p_was_read == false) {init();}
00184     return m_Chips;
00185   }
00186 
00187   public void set_Chips(SCT_Chip[] value) {
00188     p_obj.clean();
00189     config.ConfigObject[] objs = new config.ConfigObject[value.length];
00190     for(int i = 0; i < value.length; i++) {
00191       objs[i] = value[i].config_object();
00192     }
00193     p_obj.set_objects("Chips", objs);
00194   }
00195 
00196   public config.ConfigObject config_object() {
00197     return p_obj;
00198   }
00199 
00200   public void print(String dx) {
00201     System.out.println(dx + "SCT_Module object:" );
00202     System.out.println(dx + "  id: \'" + UID() + "\', class name: \'" + class_name() + "\'");
00203 
00204 
00205       // print attributes
00206 
00207     System.out.println(dx + "  sn: " + get_sn());
00208     System.out.println(dx + "  source: " + get_source());
00209     System.out.println(dx + "  location: " + get_location());
00210     System.out.println(dx + "  active: " + get_active());
00211     System.out.println(dx + "  select: " + get_select());
00212 
00213 
00214       // print relationships
00215 
00216     if(get_Chips().length > 0) {
00217       System.out.print(dx + "  " + get_Chips().length + " object(s) in Chips :\n");
00218       
00219       for(int i = 0; i < get_Chips().length; i++) {
00220         get_Chips()[i].print(dx.concat("    "));
00221       }
00222     }
00223     else {
00224       System.out.println(dx + "  Chips value is empty");
00225     }
00226 
00227   }
00228 
00234   public void destroy(config.Configuration db) {
00235     db.destroy(config_object());
00236   }
00237 }

Generated on Mon Feb 6 14:12:18 2006 for SCT DAQ/DCS Software - Java by  doxygen 1.4.6