com.guiseframework.demo
Class DemoUser

java.lang.Object
  extended by com.guiseframework.demo.DemoUser
All Implemented Interfaces:
java.lang.Comparable<DemoUser>, java.security.Principal

public class DemoUser
extends java.lang.Object
implements java.security.Principal, java.lang.Comparable<DemoUser>

A user class for the Guise demo.

Author:
Garret Wilson

Field Summary
protected static java.text.Collator COLLATOR
          The collator for comparing user names.
 
Constructor Summary
DemoUser(java.lang.String id, java.lang.String firstName, java.lang.String middleName, java.lang.String lastName, char[] password, java.lang.String email)
          Constructor.
 
Method Summary
 int compareTo(DemoUser user)
          Compares users based upon lastName+firstName+middleName+ID.
 boolean equals(java.lang.Object object)
           
 java.lang.String getEmail()
           
 java.lang.String getFirstName()
           
 java.lang.String getID()
           
 java.lang.String getLastName()
           
 java.lang.String getMiddleName()
           
 java.lang.String getName()
           
 char[] getPassword()
           
 int hashCode()
           
 boolean isAuthorized()
           
 void setAuthorized(boolean authorized)
          Sets whether the user is authorized.
 void setEmail(java.lang.String email)
          Sets the email address of the user.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COLLATOR

protected static final java.text.Collator COLLATOR
The collator for comparing user names.

Constructor Detail

DemoUser

public DemoUser(java.lang.String id,
                java.lang.String firstName,
                java.lang.String middleName,
                java.lang.String lastName,
                char[] password,
                java.lang.String email)
Constructor.

Parameters:
id - The user ID.
firstName - The first name of the user.
middleName - The middle name of the user, or null if there is no middle name.
lastName - The last name of the user.
password - The password of the user.
email - The email address of the user.
Throws:
java.lang.NullPointerException - if the ID, first name, last name, and/or email address is null.
Method Detail

getID

public java.lang.String getID()
Returns:
The user ID.

getName

public java.lang.String getName()
Specified by:
getName in interface java.security.Principal
Returns:
the name of this principal. This implementation returns the user ID. This method is provided to implement the Principal interface.
See Also:
getID()

getFirstName

public java.lang.String getFirstName()
Returns:
The first name of the user.

getMiddleName

public java.lang.String getMiddleName()
Returns:
The middle name of the user, or null if there is no middle name.

getLastName

public java.lang.String getLastName()
Returns:
The last name of the user.

getPassword

public char[] getPassword()
Returns:
The password of the user.

getEmail

public java.lang.String getEmail()
Returns:
The email address of the user.

setEmail

public void setEmail(java.lang.String email)
Sets the email address of the user.

Parameters:
email - The new email address of the user.
Throws:
java.lang.NullPointerException - if the email is null.

isAuthorized

public boolean isAuthorized()
Returns:
Whether the user is authorized.

setAuthorized

public void setAuthorized(boolean authorized)
Sets whether the user is authorized.

Parameters:
authorized - Whether the user is authorized.

compareTo

public int compareTo(DemoUser user)
Compares users based upon lastName+firstName+middleName+ID. A more internationalized

Specified by:
compareTo in interface java.lang.Comparable<DemoUser>
Parameters:
user - The user with which to compare.
Returns:
A value indicating whether the first user is alphabetically less than, equal to, or greater than the second.

equals

public boolean equals(java.lang.Object object)
Specified by:
equals in interface java.security.Principal
Overrides:
equals in class java.lang.Object
Returns:
true if the given object is another user with the same ID.
See Also:
getID()

hashCode

public int hashCode()
Specified by:
hashCode in interface java.security.Principal
Overrides:
hashCode in class java.lang.Object
Returns:
The hash code for this user. This implementation returns the hash code of the ID.
See Also:
getID()

toString

public java.lang.String toString()
Specified by:
toString in interface java.security.Principal
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this user in the form "(id) lastName, firstName middleName"


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.