home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch19 / registry / Entity.java < prev    next >
Encoding:
Java Source  |  1997-01-27  |  2.2 KB  |  131 lines

  1. // Simple Multiuser Server
  2. // (c) Copyright Justin Couch   justin@vlc.com.au
  3. // The Virtual Light Company 1996
  4. //
  5. // From Chapter 20: Late Night VRML 2.0 and java
  6. //
  7. // This is the entity class. Each instance of this class represents one entity in
  8. // the world.
  9.  
  10. package registry;
  11.  
  12. class Entity
  13. {
  14.     public    int ID;
  15.     private    String nickname;
  16.     private    String URL;
  17.     private    int flags = 0;
  18.     private  String[]    public_info;
  19.     private long registration_time = 0;
  20.     private long last_update_time = 0;
  21.     private boolean persistent;
  22.     private boolean is_avatar;
  23.     private    String owner;
  24.     private String cname;
  25.  
  26.     // create a new entity. For the start copy the cname as the nickname.
  27.     public Entity(String cn, int new_id, String ident_name)
  28.     {
  29.         cname = cn;
  30.         owner = ident_name;
  31.         nickname = cname;
  32.         ID = new_id;
  33.  
  34.         registration_time = System.currentTimeMillis();
  35.         last_update_time = registration_time;
  36.     }
  37.  
  38.     public long get_registrationTime()
  39.     {
  40.         return(registration_time);
  41.     }
  42.  
  43.     public long get_lastUpdateTime()
  44.     {
  45.         return(last_update_time);
  46.     }
  47.  
  48.     public boolean isPersistent()
  49.     {
  50.         return(persistent);
  51.     }
  52.  
  53.     public boolean isAvatar()
  54.     {
  55.         return(is_avatar);
  56.     }
  57.  
  58.     public void set_owner(String new_name)
  59.     {
  60.         owner = new_name;
  61.         last_update_time = System.currentTimeMillis();
  62.     }
  63.  
  64.     public String get_owner()
  65.     {
  66.         return(owner);
  67.     }
  68.  
  69.     public void set_persistent(boolean val)
  70.     {
  71.         persistent = val;
  72.         last_update_time = System.currentTimeMillis();
  73.     }
  74.  
  75.     public void set_avatar(boolean val)
  76.     {
  77.         is_avatar = val;
  78.         last_update_time = System.currentTimeMillis();
  79.     }
  80.  
  81.     public String get_cname()
  82.     {
  83.         return(cname);
  84.     }
  85.  
  86.     public void set_nickname(String name)
  87.     {
  88.         nickname = name;
  89.         last_update_time = System.currentTimeMillis();
  90.     }
  91.  
  92.     public String get_nickname()
  93.     {
  94.         return(nickname);
  95.     }
  96.  
  97.     public void set_URL(String new_url)
  98.     {
  99.         URL = new_url;
  100.         last_update_time = System.currentTimeMillis();
  101.     }
  102.  
  103.     public String get_URL()
  104.     {
  105.         return(URL);
  106.     }
  107.  
  108.     public void set_flags(int new_flags)
  109.     {
  110.         flags = new_flags;
  111.         last_update_time = System.currentTimeMillis();
  112.     }
  113.  
  114.     public int get_flags()
  115.     {
  116.         return(flags);
  117.     }
  118.  
  119.     public void set_publicInfo(String[] new_info)
  120.     {
  121.         public_info = new_info;
  122.         last_update_time = System.currentTimeMillis();
  123.     }
  124.  
  125.     public String[] get_publicInfo()
  126.     {
  127.         return(public_info);
  128.     }
  129. }
  130.  
  131.