package com.jarticles; /** * We use this class as a fake class that can be used to extract * User information from the database via JDBC or EJB. */ public class User { private static User users[] = new User[3]; static { users[0] = new User("Paul", "Clare", "Male", "Director of R&D"); users[1] = new User("Jean-Luc", "Picard", "Male", "Captain of the Starship U.S.S. Enterprise"); users[2] = new User("DefaultFirstName", "DefalutLastName", "DefaultSex", "DefaultPosition"); } private String firstName = null; private String lastName = null; private String sex = null; private String position = null; public User(String firstName, String lastName, String sex, String position) { this.firstName = firstName; this.lastName = lastName; this.sex = sex; this.position = position; } public static User findUserById(long i) { int j = new Long(i).intValue(); // in real life, we use long not int return ( (j!=0) && (j!=1) ) ? users[2] : users[j]; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public String getSex() { return sex; } public String getPosition() { return position; } }