stefano     2003/03/01 07:18:04

  Added:       src/samples/org/apache/cocoon/samples/flow/prefs User.java
                        UserRegistry.java
  Removed:     src/samples/org/apache/cocoon/samples/flow User.java
                        UserRegistry.java
  Log:
  moved flow samples java classes in the right directory structure matching
  their packages so that ant doesn't recompile them everytime
  
  Revision  Changes    Path
  1.1                  
xml-cocoon2/src/samples/org/apache/cocoon/samples/flow/prefs/User.java
  
  Index: User.java
  ===================================================================
  /*
      User.java
  
      Representation of a user.
  
      Author: Ovidiu Predescu <[EMAIL PROTECTED]>
      Date: August 28, 2002
  
   */
  
  package org.apache.cocoon.samples.flow.prefs;
  
  public class User
  {
    String login;
    String password;
    String firstName;
    String lastName;
    String email;
  
    public User(String login, String password,
                String firstName, String lastName, String email)
    {
      this.login = login;
      this.password = password;
      this.firstName = firstName;
      this.lastName = lastName;
      this.email = email;
    }
  
    public int hashCode()
    {
      return login.hashCode();
    }
  
    public boolean equals(Object obj)
    {
      User anotherUser = (User)obj;
      return anotherUser.login.equals(login);
    }
    
    /**
     * Sets the value of login
     *
     * @param argLogin Value to assign to this.login
     */
    public void setLogin(String argLogin)
    {
      this.login = argLogin;
    }
    /**
     * Gets the value of login
     *
     * @return the value of login
     */
    public String getLogin() 
    {
      return this.login;
    }
  
    /**
     * Gets the value of password
     *
     * @return the value of password
     */
    public String getPassword() 
    {
      return this.password;
    }
  
    /**
     * Sets the value of password
     *
     * @param argPassword Value to assign to this.password
     */
    public void setPassword(String argPassword)
    {
      this.password = argPassword;
    }
  
    /**
     * Gets the value of firstName
     *
     * @return the value of firstName
     */
    public String getFirstName() 
    {
      return this.firstName;
    }
  
    /**
     * Sets the value of firstName
     *
     * @param argFirstName Value to assign to this.firstName
     */
    public void setFirstName(String argFirstName)
    {
      this.firstName = argFirstName;
    }
  
    /**
     * Gets the value of lastName
     *
     * @return the value of lastName
     */
    public String getLastName() 
    {
      return this.lastName;
    }
  
    /**
     * Sets the value of lastName
     *
     * @param argLastName Value to assign to this.lastName
     */
    public void setLastName(String argLastName)
    {
      this.lastName = argLastName;
    }
  
    /**
     * Gets the value of email
     *
     * @return the value of email
     */
    public String getEmail() 
    {
      return this.email;
    }
  
    /**
     * Sets the value of email
     *
     * @param argEmail Value to assign to this.email
     */
    public void setEmail(String argEmail)
    {
      this.email = argEmail;
    }
  }
  
  
  
  1.1                  
xml-cocoon2/src/samples/org/apache/cocoon/samples/flow/prefs/UserRegistry.java
  
  Index: UserRegistry.java
  ===================================================================
  /*
      UserRegistry.java
  
      Maintains a list of registered users.
  
      Author: Ovidiu Predescu <[EMAIL PROTECTED]>
      Date: August 28, 2002
  
   */
  
  package org.apache.cocoon.samples.flow.prefs;
  
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * Maintains a list of registered users. This is a very simple class,
   * there is no persistence of the users, but such thing should be easy
   * to add.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Ovidiu Predescu</a>
   * @since August 28, 2002
   */
  public class UserRegistry
  {
    static UserRegistry userRegistry = new UserRegistry();
  
    Map registeredUsers = new HashMap();
  
    public static UserRegistry getUserRegistry()
    {
      return userRegistry;
    }
  
    protected UserRegistry()
    {
    }
  
    public synchronized boolean addUser(User user)
    {
      if (registeredUsers.containsKey(user.getLogin()))
        return false;
  
      registeredUsers.put(user.getLogin(), user);
      return true;
    }
  
    public boolean removeUser(User user)
    {
      return registeredUsers.remove(user) != null;
    }
  
    /**
     * Checks is a particular login name is taken or not.
     *
     * @param loginName a <code>String</code> value
     * @return true if <code>loginName</code> is taken, false otherwise
     */
    public boolean isLoginNameTaken(String loginName)
    {
      return registeredUsers.get(loginName) != null;
    }
  
    /**
     * Returns the [EMAIL PROTECTED] User} object which represents an user. Note that
     * we require a password to be present, to avoid presenting private
     * information to anyone.
     *
     * @param loginName a <code>String</code> value
     * @param password a <code>String</code> value
     * @return an <code>User</code> value
     */
    public User getUserWithLogin(String loginName, String password)
    {
      User user = (User)registeredUsers.get(loginName);
  
      if (user == null)
        return null;
  
      return password.equals(user.getPassword()) ? user : null;
    }
  }
  
  
  

Reply via email to