Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/jabber/jabberbeans/User.java


1   package org.jabber.jabberbeans;
2   
3   import java.net.InetAddress;
4   
5   /**
6    * User is the generic 'user' class. It holds all the unique information for
7    * identifying a user. It also provides resources to compare user objects and
8    * to get a URI quickly (toString)
9    *
10   * @author  David Waite <a href="mailto:mass@ufl.edu"><i>&lt;mass@ufl.edu&gt;
11   *      </i></a>
12   * @author  $Author: mass $
13   * @version $Revision: 1.1 $
14   */
15  public class User
16  {
17      protected String username;
18      protected InetAddress server;
19  
20      public User(String username,InetAddress server)
21      {
22    this.username=username;
23    this.server=server;
24      }
25  
26      public String getUsername()
27      {
28    return username;
29      }
30      public InetAddress getServer()
31      {
32    return server;
33      }
34  
35      public String toString()
36      {
37    return "jabber:" + username + "@" + server;
38      }
39  
40      public boolean equals(User u)
41      {  
42    //we use toString because otherwise we will not
43    //have a equals function that works against
44    //subclasses in a symmetric manner.
45    //e.g. User.equals(UserURI)!=UserURI.equals(User);
46    return toString().equals(u.toString());
47      }
48  }