FileDocCategorySizeDatePackage
UserOld.javaAPI DocExample4094Thu Mar 15 11:08:24 GMT 2001jabadot

User

public class User extends Object implements Serializable
Represents one logged in user

Fields Summary
protected String
name
protected String
password
protected String
fullName
protected String
email
protected String
city
protected String
prov
protected String
country
protected Date
creationDate
protected Date
lastLoginDate
protected boolean
editPrivs
protected boolean
adminPrivs
static final int
P_ADMIN
static final int
P_EDIT
Constructors Summary
public User()
Construct a user with no data -- must be a no-argument constructor for use in jsp:useBean.


	                	 
	  
		creationDate = new Date();
	
public User(String n)
Construct a user with just the name

		this();			// set credt
		name = n;
	
public User(String nick, String pw, String nam, String em, String cy, String pr, String co)
Construct a user with all text fields.

		this();			// set credt
		name = nick;
		password = pw;
		fullName = nam;
		email = em;
		city = cy;
		prov = pr;
		country = co;
	
public User(String nick, String pw, String nam, String em, String cy, String pr, String co, int privs)
Construct a user with all text fields and privs as an int.

		this(nick, pw, nam, em, cy, pr, co);
		if ((privs & P_ADMIN) != 0)
			adminPrivs = true;
		if ((privs & P_EDIT) != 0)
			editPrivs = true;
	
Methods Summary
public booleancheckPassword(java.lang.String userInput)
Validate a given password against the user's.

		return password.equals(userInput);
	
public java.lang.StringgetCity()
Get city

		return city;
	
public java.lang.StringgetCountry()
Get country

		return country;
	
public java.util.DategetCreationDate()
Get the Creation Date (read only field)

		return creationDate;
	
public java.lang.StringgetEmail()
Get email

		return email;
	
public java.lang.StringgetFullName()
Get fullName

		return fullName;
	
public java.util.DategetLastLoginDate()
Get the LastLog Date (read only field)

		return lastLoginDate;
	
public java.lang.StringgetName()
Return the nickname.

		return name;
	
public java.lang.StringgetPassword()

		return password;
	
public intgetPrivs()
Get all privs, as an int, for use in the database

		int i = 0;
		if (adminPrivs)
			i |= P_ADMIN;
		if (editPrivs)
			i |= P_EDIT;
		return i;
	
public java.lang.StringgetProv()
Get prov

		return prov;
	
public booleanisAdminPrivileged()
Get adminPrivs

		return adminPrivs;
	
public booleanisComplete()
Check if all required fields have been set

		if (name == null || name.length()==0 ||
		    email == null || email.length()==0 ||
		    fullName == null || fullName.length()==0 )
			return false;
		return true;
	
public booleanisEditPrivileged()
Get EditPrivs

		return editPrivs;
	
public voidsetAdminPrivileged(boolean adminPrivs)
Set adminPrivs

		this.adminPrivs = adminPrivs;
	
public voidsetCity(java.lang.String city)
Set city

		this.city = city;
	
public voidsetCountry(java.lang.String country)
Set country

		this.country = country;
	
public voidsetEditPrivileged(boolean editPrivs)
Set EditPrivs

		this.editPrivs = editPrivs;
	
public voidsetEmail(java.lang.String email)
Set email

		this.email = email;
	
public voidsetFullName(java.lang.String fullName)
Set fullName

		this.fullName = fullName;
	
public voidsetLastLoginDate(java.util.Date d)
Get the LastLog Date (read only field)

		lastLoginDate = d;
	
public voidsetName(java.lang.String nick)
The name should not be changeable, but we want to be able to say and get it all...

		name = nick;
	
public voidsetPassword(java.lang.String password)
Set password

		this.password = password;
	
public voidsetProv(java.lang.String prov)
Set prov

		this.prov = prov;
	
public java.lang.StringtoString()
Return a String representation.

		return new StringBuffer("User[").append(name).append(',").append(fullName).append(']").toString();