home *** CD-ROM | disk | FTP | other *** search
/ ftp.disi.unige.it / 2015-02-11.ftp.disi.unige.it.tar / ftp.disi.unige.it / pub / .person / GuerriniG / dispense / corso-oodb / progetti-01 / progetto2 / titolostudio.java < prev    next >
Text File  |  2001-03-01  |  2KB  |  102 lines

  1. package progetto2;
  2.  
  3.  
  4.  
  5. import com.odi.*;
  6. import com.odi.util.*;
  7. import java.util.*;
  8.  
  9.  
  10.  
  11. public class TitoloStudio{
  12.  
  13. //Extents
  14.     public static Ext_OSTreeSet Ext = new Ext_OSTreeSet("TitoliStudio");
  15.  
  16.     public boolean showSlotName=false; // look at toString method ...
  17.  
  18.     // Attributes
  19.     public String in;
  20.     public int anno;
  21.     public int voto;
  22.     public Universita univers;
  23.     public boolean laurea;
  24.  
  25.  
  26.  
  27.  
  28.     ////////////////////////////////////////////////////////
  29.     // Constructor
  30.     public TitoloStudio()
  31.     {
  32.  
  33.     }
  34.  
  35.     public TitoloStudio(String _in, int _anno, int _voto, Universita _univers, boolean _laurea)
  36.     {
  37.  
  38.         in=_in;
  39.         anno=_anno;
  40.         voto=_voto;
  41.         univers=_univers;
  42.         laurea=_laurea;
  43.  
  44.     }
  45.  
  46.  
  47.  
  48.     ////////////////////////////////////////////////////////
  49.     // The Extents
  50.     void updateExtents(Database db, boolean add)
  51.     {
  52.  
  53.  
  54.  
  55.         Ext.update(this, db, add);
  56.  
  57.     }
  58.  
  59.     ////////////////////////////////////////////////////////
  60.     // Hook the IPersistent method
  61.  
  62.     public void preFlushContents()
  63.     {
  64.         Segment theSegment= Session.getCurrent().segmentOfpreFlushContentsObject();
  65.         Database db = theSegment.getDatabase();
  66.         Collection theExtent = (Collection) Ext.getExtents(db);
  67.         if (!theExtent.contains(this))
  68.             updateExtents(db, true);
  69.     }
  70.  
  71.     ////////////////////////////////////////////////////////
  72.     // Override toString method
  73.  
  74.     public String toString()
  75.     {
  76.         String ret;
  77.         ret = super.toString();
  78.  
  79.         if (showSlotName)
  80.             ret = ret + " in";
  81.         ret = ret + " " + in;
  82.         if (showSlotName)
  83.             ret = ret + " anno";
  84.         ret = ret + " " + anno;
  85.         if (showSlotName)
  86.             ret = ret + " voto";
  87.         ret = ret + " " + voto;
  88.         if (showSlotName)
  89.             ret = ret + " univers";
  90.         ret = ret + " " + univers;
  91.         if (showSlotName)
  92.             ret = ret + " laurea";
  93.         ret = ret + " " + laurea;
  94.         return ret;
  95.     }
  96.  
  97. // Operations
  98.  
  99.  
  100.  
  101. }
  102.