org.apache.struts.examples.mailreader.memory
Class MemoryUser

java.lang.Object
  |
  +--org.apache.struts.examples.mailreader.memory.MemoryUser
All Implemented Interfaces:
User

public final class MemoryUser
extends java.lang.Object
implements User

Concrete implementation of User for an in-memory database backed by an XML data file.

Since:
Struts 1.1
Version:
$Rev: 54929 $ $Date: 2004-10-16 09:38:42 -0700 (Sat, 16 Oct 2004) $

Field Summary
private  MemoryUserDatabase database
          The UserDatabase with which we are associated.
private  java.lang.String fromAddress
          The email address from which messages are sent.
private  java.lang.String fullName
          The full name of this user, included in from addresses.
private  java.lang.String password
          The password (in clear text).
private  java.lang.String replyToAddress
          The EMAIL address to which replies should be sent.
private  java.util.HashMap subscriptions
          The Subscriptions for this User, keyed by hostname.
private  java.lang.String username
          The username for this user.
 
Constructor Summary
MemoryUser(MemoryUserDatabase database, java.lang.String username)
          Construct a new User associated with the specified UserDatabase.
 
Method Summary
 Subscription createSubscription(java.lang.String host)
          Create and return a new Subscription associated with this User, for the specified host name.
 Subscription findSubscription(java.lang.String host)
          Find and return the Subscription associated with the specified host.
 UserDatabase getDatabase()
          The UserDatabase with which we are associated.
 java.lang.String getFromAddress()
          Return the from address.
 java.lang.String getFullName()
          Return the full name.
 java.lang.String getPassword()
          Return the password.
 java.lang.String getReplyToAddress()
          Return the reply-to address.
 Subscription[] getSubscriptions()
          Find and return all Subscriptions associated with this user.
 java.lang.String getUsername()
          The username (must be unique).
 void removeSubscription(Subscription subscription)
          Remove the specified Subscription from being associated with this User.
 void setFromAddress(java.lang.String fromAddress)
          Set the from address.
 void setFullName(java.lang.String fullName)
          Set the full name.
 void setPassword(java.lang.String password)
          Set the password.
 void setReplyToAddress(java.lang.String replyToAddress)
          Set the reply-to address.
 java.lang.String toString()
          Return a String representation of this object.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

database

private MemoryUserDatabase database
The UserDatabase with which we are associated.

subscriptions

private java.util.HashMap subscriptions
The Subscriptions for this User, keyed by hostname.

username

private java.lang.String username
The username for this user.

fromAddress

private java.lang.String fromAddress
The email address from which messages are sent.

fullName

private java.lang.String fullName
The full name of this user, included in from addresses.

password

private java.lang.String password
The password (in clear text).

replyToAddress

private java.lang.String replyToAddress
The EMAIL address to which replies should be sent.
Constructor Detail

MemoryUser

public MemoryUser(MemoryUserDatabase database,
                  java.lang.String username)

Construct a new User associated with the specified UserDatabase.

Parameters:
database - The user database with which we are associated
username - The username of this user
Method Detail

getDatabase

public UserDatabase getDatabase()
The UserDatabase with which we are associated.
Specified by:
getDatabase in interface User

getFromAddress

public java.lang.String getFromAddress()
Description copied from interface: User
Return the from address.
Specified by:
getFromAddress in interface User

setFromAddress

public void setFromAddress(java.lang.String fromAddress)
Description copied from interface: User
Set the from address.
Specified by:
setFromAddress in interface User
Following copied from interface: org.apache.struts.examples.mailreader.User
Parameters:
fromAddress - The new from address

getFullName

public java.lang.String getFullName()
Description copied from interface: User
Return the full name.
Specified by:
getFullName in interface User

setFullName

public void setFullName(java.lang.String fullName)
Description copied from interface: User
Set the full name.
Specified by:
setFullName in interface User
Following copied from interface: org.apache.struts.examples.mailreader.User
Parameters:
fullName - The new full name

getPassword

public java.lang.String getPassword()
Description copied from interface: User
Return the password.
Specified by:
getPassword in interface User

setPassword

public void setPassword(java.lang.String password)
Description copied from interface: User
Set the password.
Specified by:
setPassword in interface User
Following copied from interface: org.apache.struts.examples.mailreader.User
Parameters:
password - The new password

getReplyToAddress

public java.lang.String getReplyToAddress()
Description copied from interface: User
Return the reply-to address.
Specified by:
getReplyToAddress in interface User

setReplyToAddress

public void setReplyToAddress(java.lang.String replyToAddress)
Description copied from interface: User
Set the reply-to address.
Specified by:
setReplyToAddress in interface User
Following copied from interface: org.apache.struts.examples.mailreader.User
Parameters:
replyToAddress - The new reply-to address

getSubscriptions

public Subscription[] getSubscriptions()
Find and return all Subscriptions associated with this user. If there are none, a zero-length array is returned.
Specified by:
getSubscriptions in interface User

getUsername

public java.lang.String getUsername()
The username (must be unique).
Specified by:
getUsername in interface User

createSubscription

public Subscription createSubscription(java.lang.String host)
Create and return a new Subscription associated with this User, for the specified host name.
Specified by:
createSubscription in interface User
Parameters:
host - Host name for which to create a subscription
Throws:
java.lang.IllegalArgumentException - if the host name is not unique for this user

findSubscription

public Subscription findSubscription(java.lang.String host)
Find and return the Subscription associated with the specified host. If none is found, return null.
Specified by:
findSubscription in interface User
Parameters:
host - Host name to look up

removeSubscription

public void removeSubscription(Subscription subscription)
Remove the specified Subscription from being associated with this User.
Specified by:
removeSubscription in interface User
Parameters:
subscription - Subscription to be removed
Throws:
java.lang.IllegalArgumentException - if the specified subscription is not associated with this User

toString

public java.lang.String toString()
Return a String representation of this object.
Overrides:
toString in class java.lang.Object


Copyright © 2003-2004 - The Apache Software Foundation