Geography_Impl.java

00001 package ;
00002 
00003 
00011   // import configuration classes
00012 
00013 import config.*;
00014 
00015 
00016   // import used generated classes
00017 
00018 import .Barrel;
00019 import .Barrel_Helper;
00020 
00021 
00022 class Geography_Impl implements Geography {
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 
00037 
00038     // database class relationships
00039 
00040   private Barrel[] m_barrels;
00041 
00042 
00043 
00044     // constructor
00045 
00046   public Geography_Impl() {
00047     p_is_valid = false;
00048   }
00049 
00050   public Geography_Impl(config.Configuration db, config.ConfigObject obj) {
00051     init_config_params(db, obj);
00052   }
00053 
00054   public void init_config_params(config.Configuration db, config.ConfigObject obj) {
00055     p_db = db;
00056     p_obj = obj;
00057     p_was_read = false;
00058     p_is_valid = true;
00059     p_uid = p_obj.UID();
00060     p_class_name = p_obj.class_name();
00061   }
00062 
00063   public String UID() {
00064     return p_uid;
00065   }
00066 
00067   public String class_name() {
00068     return p_class_name;
00069   }
00070 
00071   public void update(boolean set_non_valid) {
00072     if(set_non_valid == true) {
00073       p_is_valid = false;
00074     }
00075     else {
00076       p_was_read = false;
00077       p_obj.clean();
00078       init();
00079     }
00080   }
00081 
00082   public void unread() {
00083     p_was_read = false;
00084   }
00085 
00086   public boolean is_valid() {
00087     return p_is_valid;
00088   }
00089 
00090 
00091 
00092   private void init() throws config.NotFoundException, config.NotValidException, config.SystemException {
00093     if(p_was_read == true) {return;}
00094 
00095     if(p_is_valid == false) {
00096       String text = "ERROR [.Geography_Impl.init()]: object " + p_uid + "@" + p_class_name + " is not valid";
00097       System.err.println(text);
00098       throw new config.NotValidException(text);
00099     }
00100 
00101     {
00102       ConfigObject[] objs = p_obj.get_objects("barrels");
00103       m_barrels = new Barrel[objs.length];
00104       for( int i = 0; i < objs.length; i++ ) {
00105         m_barrels[i] = Barrel_Helper.get(p_db, objs[i]);
00106       }
00107     }
00108     
00109 
00110     p_was_read = true;
00111 
00112   }
00113 
00114   public Barrel[] get_barrels() {
00115     if(p_was_read == false) {init();}
00116     return m_barrels;
00117   }
00118 
00119   public void set_barrels(Barrel[] value) {
00120     p_obj.clean();
00121     config.ConfigObject[] objs = new config.ConfigObject[value.length];
00122     for(int i = 0; i < value.length; i++) {
00123       objs[i] = value[i].config_object();
00124     }
00125     p_obj.set_objects("barrels", objs);
00126   }
00127 
00128   public config.ConfigObject config_object() {
00129     return p_obj;
00130   }
00131 
00132   public void print(String dx) {
00133     System.out.println(dx + "Geography object:" );
00134     System.out.println(dx + "  id: \'" + UID() + "\', class name: \'" + class_name() + "\'");
00135 
00136 
00137       // print attributes
00138 
00139 
00140 
00141       // print relationships
00142 
00143     if(get_barrels().length > 0) {
00144       System.out.print(dx + "  " + get_barrels().length + " object(s) in barrels :\n");
00145       
00146       for(int i = 0; i < get_barrels().length; i++) {
00147         get_barrels()[i].print(dx.concat("    "));
00148       }
00149     }
00150     else {
00151       System.out.println(dx + "  barrels value is empty");
00152     }
00153 
00154   }
00155 
00161   public void destroy(config.Configuration db) {
00162     db.destroy(config_object());
00163   }
00164 }

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