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 / telefono.java < prev    next >
Text File  |  2001-03-01  |  2KB  |  87 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 Telefono{
  12.  
  13. //Extents
  14.     public static Ext_OSTreeSet Ext = new Ext_OSTreeSet("Telefoni");
  15.  
  16.     public boolean showSlotName=false; // look at toString method ...
  17.  
  18.     // Attributes
  19.     public String numero;
  20.     public String tipo;
  21.  
  22.  
  23.  
  24.  
  25.     ////////////////////////////////////////////////////////
  26.     // Constructor
  27.     public Telefono()
  28.     {
  29.  
  30.     }
  31.  
  32.     public Telefono(String _numero, String _tipo)
  33.     {
  34.  
  35.         numero=_numero;
  36.         tipo=_tipo;
  37.  
  38.     }
  39.  
  40.  
  41.  
  42.     ////////////////////////////////////////////////////////
  43.     // The Extents
  44.     void updateExtents(Database db, boolean add)
  45.     {
  46.  
  47.  
  48.  
  49.         Ext.update(this, db, add);
  50.  
  51.     }
  52.  
  53.     ////////////////////////////////////////////////////////
  54.     // Hook the IPersistent method
  55.  
  56.     public void preFlushContents()
  57.     {
  58.         Segment theSegment= Session.getCurrent().segmentOfpreFlushContentsObject();
  59.         Database db = theSegment.getDatabase();
  60.         Collection theExtent = (Collection) Ext.getExtents(db);
  61.         if (!theExtent.contains(this))
  62.             updateExtents(db, true);
  63.     }
  64.  
  65.     ////////////////////////////////////////////////////////
  66.     // Override toString method
  67.  
  68.     public String toString()
  69.     {
  70.         String ret;
  71.         ret = super.toString();
  72.  
  73.         if (showSlotName)
  74.             ret = ret + " numero";
  75.         ret = ret + " " + numero;
  76.         if (showSlotName)
  77.             ret = ret + " tipo";
  78.         ret = ret + " " + tipo;
  79.         return ret;
  80.     }
  81.  
  82. // Operations
  83.  
  84.  
  85.  
  86. }
  87.