com.samskivert.servlet.user
Class Username

java.lang.Object
  extended by com.samskivert.servlet.user.Username

public class Username
extends Object

Allows us to require a valid username as a parameter without having to do the checking ourselves.


Field Summary
protected  String _username
           
static int MAXIMUM_USERNAME_LENGTH
          The maximum allowable length of a username.
static int MINIMUM_USERNAME_LENGTH
          The minimum allowable length of a username.
static String NAME_REGEX
          The regular expression defining valid names.
 
Constructor Summary
Username(String username)
          Creates a username instance.
 
Method Summary
 String getUsername()
          Returns the text of this username.
 String toString()
           
protected  void validateName(String username)
          Validates our username.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MINIMUM_USERNAME_LENGTH

public static final int MINIMUM_USERNAME_LENGTH
The minimum allowable length of a username.

See Also:
Constant Field Values

MAXIMUM_USERNAME_LENGTH

public static final int MAXIMUM_USERNAME_LENGTH
The maximum allowable length of a username.

See Also:
Constant Field Values

NAME_REGEX

public static final String NAME_REGEX
The regular expression defining valid names.

See Also:
Constant Field Values

_username

protected String _username
Constructor Detail

Username

public Username(String username)
         throws InvalidUsernameException
Creates a username instance.

Throws:
InvalidUsernameException
Method Detail

getUsername

public String getUsername()
Returns the text of this username.


toString

public String toString()
Overrides:
toString in class Object

validateName

protected void validateName(String username)
                     throws InvalidUsernameException
Validates our username. The default implementation requires that usernames consist only of characters that match the NAME_REGEX regular expression and be between MINIMUM_USERNAME_LENGTH and MAXIMUM_USERNAME_LENGTH characters.

Throws:
InvalidUsernameException


Copyright © 2000-2008 Michael Bayne. All Rights Reserved.