Fields Summary |
---|
private MemoryUserDatabase | databaseThe {@link UserDatabase} with which we are associated. |
private HashMap | subscriptionsThe {@link Subscription}s for this User, keyed by hostname. |
private String | usernameThe username for this user. |
private String | fromAddressThe email address from which messages are sent. |
private String | fullNameThe full name of this user, included in from addresses. |
private String | passwordThe password (in clear text). |
private String | replyToAddressThe EMAIL address to which replies should be sent. |
Methods Summary |
---|
public org.apache.struts.webapp.example.Subscription | createSubscription(java.lang.String host)Create and return a new {@link Subscription} associated with this
User, for the specified host name.
synchronized (subscriptions) {
if (subscriptions.get(host) != null) {
throw new IllegalArgumentException("Duplicate host '" + host
+ "' for user '" +
username + "'");
}
MemorySubscription subscription =
new MemorySubscription(this, host);
synchronized (subscriptions) {
subscriptions.put(host, subscription);
}
return (subscription);
}
|
public org.apache.struts.webapp.example.Subscription | findSubscription(java.lang.String host)Find and return the {@link Subscription} associated with the specified
host. If none is found, return null .
synchronized (subscriptions) {
return ((Subscription) subscriptions.get(host));
}
|
public org.apache.struts.webapp.example.UserDatabase | getDatabase()The {@link UserDatabase} with which we are associated.
// ------------------------------------------------------------- Properties
return (this.database);
|
public java.lang.String | getFromAddress()
return (this.fromAddress);
|
public java.lang.String | getFullName()
return (this.fullName);
|
public java.lang.String | getPassword()
return (this.password);
|
public java.lang.String | getReplyToAddress()
return (this.replyToAddress);
|
public org.apache.struts.webapp.example.Subscription[] | getSubscriptions()Find and return all {@link Subscription}s associated with this user.
If there are none, a zero-length array is returned.
synchronized (subscriptions) {
Subscription results[] = new Subscription[subscriptions.size()];
return ((Subscription[]) subscriptions.values().toArray(results));
}
|
public java.lang.String | getUsername()The username (must be unique).
return (this.username);
|
public void | removeSubscription(org.apache.struts.webapp.example.Subscription subscription)Remove the specified {@link Subscription} from being associated
with this User.
if (!(this == subscription.getUser())) {
throw new IllegalArgumentException
("Subscription not associated with this user");
}
synchronized (subscriptions) {
subscriptions.remove(subscription.getHost());
}
|
public void | setFromAddress(java.lang.String fromAddress)
this.fromAddress = fromAddress;
|
public void | setFullName(java.lang.String fullName)
this.fullName = fullName;
|
public void | setPassword(java.lang.String password)
this.password = password;
|
public void | setReplyToAddress(java.lang.String replyToAddress)
this.replyToAddress = replyToAddress;
|
public java.lang.String | toString()Return a String representation of this object.
StringBuffer sb = new StringBuffer("<user username=\"");
sb.append(username);
sb.append("\"");
if (fromAddress != null) {
sb.append(" fromAddress=\"");
sb.append(fromAddress);
sb.append("\"");
}
if (fullName != null) {
sb.append(" fullName=\"");
sb.append(fullName);
sb.append("\"");
}
if (password != null) {
sb.append(" password=\"");
sb.append(password);
sb.append("\"");
}
if (replyToAddress != null) {
sb.append(" replyToAddress=\"");
sb.append(replyToAddress);
sb.append("\"");
}
sb.append(">");
return (sb.toString());
|