home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / JDPJaggUser.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-09  |  3.1 KB  |  147 lines

  1. import java.net.InetAddress;
  2. import java.util.Date;
  3. import java.util.Hashtable;
  4. import java.util.Vector;
  5.  
  6. public class JDPJaggUser {
  7.    Hashtable info = new Hashtable();
  8.    Vector requests = new Vector();
  9.    int totalRequests;
  10.    long totalReceived;
  11.    long totalTransmitted;
  12.    public static final int ACTIVE = 0;
  13.    public static final int IDLE = 1;
  14.    public static final int DISCONNECTED = 2;
  15.    public static final int SUCCESS = 10;
  16.    public static final int FAIL = 11;
  17.    public static final int UNKNOWN = 12;
  18.  
  19.    public InetAddress getInetAddress() {
  20.       return this.info.get("InetAddress") == null ? null : (InetAddress)this.info.get("InetAddress");
  21.    }
  22.  
  23.    public void setInetAddress(InetAddress var1) {
  24.       if (var1 != null) {
  25.          this.info.put("InetAddress", var1);
  26.       }
  27.  
  28.    }
  29.  
  30.    public void addActiveRequest(JaggServerCxn var1) {
  31.       this.setUserStatus(0);
  32.       this.requests.addElement(var1);
  33.    }
  34.  
  35.    public int getUserStatus() {
  36.       return (Integer)this.info.get("UserStatus");
  37.    }
  38.  
  39.    public void setUserStatus(int var1) {
  40.       if (var1 >= 0 && var1 <= 2) {
  41.          this.info.put("UserStatus", new Integer(var1));
  42.       }
  43.  
  44.    }
  45.  
  46.    public long getLastConnectionDuration() {
  47.       return (Long)this.info.get("lastConnectionDuration");
  48.    }
  49.  
  50.    public void setLastConnectionDuration(long var1) {
  51.       this.info.put("lastConnectionDuration", new Long(var1));
  52.    }
  53.  
  54.    public synchronized void incrementTotalRequest() {
  55.       ++this.totalRequests;
  56.    }
  57.  
  58.    public long getBytesReceived() {
  59.       return this.totalReceived;
  60.    }
  61.  
  62.    public synchronized void incrementBytesTransmitted(long var1) {
  63.       this.totalTransmitted += var1;
  64.    }
  65.  
  66.    public Date getLastConnectionEnd() {
  67.       return (Date)this.info.get("lastConnectionEnd");
  68.    }
  69.  
  70.    public void setLastConnectionEnd(Date var1) {
  71.       if (var1 == null) {
  72.          this.info.remove("lastConnectionEnd");
  73.       } else {
  74.          this.setUserStatus(1);
  75.          this.info.put("lastConnectionEnd", var1);
  76.       }
  77.    }
  78.  
  79.    public String getJDPSystem() {
  80.       return (String)this.info.get("JDPSystem");
  81.    }
  82.  
  83.    public void setJDPSystem(String var1) {
  84.       this.info.put("JDPSystem", var1);
  85.    }
  86.  
  87.    public long getIdleFor() {
  88.       Date var1 = this.getLastConnectionStart();
  89.       Date var2 = this.getLastConnectionEnd();
  90.       if (var1 != null && var2 != null) {
  91.          return var1.getTime() > var2.getTime() ? (new Date()).getTime() - var1.getTime() : (new Date()).getTime() - var2.getTime();
  92.       } else if (var2 != null) {
  93.          return (new Date()).getTime() - var2.getTime();
  94.       } else {
  95.          return var1 != null ? (new Date()).getTime() - var1.getTime() : 0L;
  96.       }
  97.    }
  98.  
  99.    public Date getLastConnectionStart() {
  100.       return (Date)this.info.get("lastConnectionStart");
  101.    }
  102.  
  103.    public void setLastConnectionStart(Date var1) {
  104.       if (var1 == null) {
  105.          this.info.remove("lastConnectionStart");
  106.       } else {
  107.          this.info.put("lastConnectionStart", var1);
  108.       }
  109.    }
  110.  
  111.    public JDPJaggUser(InetAddress var1, int var2, String var3) {
  112.       this.setInetAddress(var1);
  113.       this.setJDPUser(var2);
  114.       this.setJDPSystem(var3);
  115.       this.setLastConnectionDuration(0L);
  116.    }
  117.  
  118.    public int getJDPUser() {
  119.       return (Integer)this.info.get("JDPUser");
  120.    }
  121.  
  122.    public void setJDPUser(int var1) {
  123.       this.info.put("JDPUser", new Integer(var1));
  124.    }
  125.  
  126.    public synchronized void incrementBytesReceived(long var1) {
  127.       this.totalReceived += var1;
  128.    }
  129.  
  130.    public Vector getActiveRequests() {
  131.       return this.requests;
  132.    }
  133.  
  134.    public void removeActiveRequest(JaggServerCxn var1) {
  135.       this.setUserStatus(2);
  136.       this.requests.removeElement(var1);
  137.    }
  138.  
  139.    public int getTotalRequests() {
  140.       return this.totalRequests;
  141.    }
  142.  
  143.    public long getBytesTransmitted() {
  144.       return this.totalTransmitted;
  145.    }
  146. }
  147.