com.arsdigita.bebop.parameters
Class EmailParameter

java.lang.Object
  extended bycom.arsdigita.bebop.parameters.ParameterModel
      extended bycom.arsdigita.bebop.parameters.StringParameter
          extended bycom.arsdigita.bebop.parameters.EmailParameter
All Implemented Interfaces:
Lockable

public class EmailParameter
extends StringParameter

An email address parameter. The parameter in the request is only accepted if it represents a valid email address such as webmaster@foo.com. The email address from the request is converted into a InternetAddress if it looks like a valid email address. If it does not, the parameter flags a parameter validation error.

The request value looks like a valid email address if it matches the regular expression ^[^@<>\"\t ]+@[^@<>\".\t]+([.][^@<>\".\n]+)+$

Author:
Karl Goldstein, Uday Mathur, Rory Solomon

Field Summary
 
Fields inherited from class com.arsdigita.bebop.parameters.StringParameter
versionId
 
Fields inherited from class com.arsdigita.bebop.parameters.ParameterModel
m_defaultValue, m_locked, m_name, m_parameterListeners
 
Constructor Summary
EmailParameter(String name)
          Create a new email parameter corresponding to a request parameter with the given name.
 
Method Summary
 Class getValueClass()
          Return the class that all values produced by the model will have.
 Object transformValue(javax.servlet.http.HttpServletRequest request)
          Retrieve the email address from the request.
 Object unmarshal(String encoded)
          Reconstruct the parameter value from an encoded string produced by marshal.
 
Methods inherited from class com.arsdigita.bebop.parameters.ParameterModel
addParameterListener, createParameterData, createParameterData, createParameterData, getDefaultOverridesNull, getDefaultValue, getName, isLocked, isPassIn, lock, marshal, setDefaultOverridesNull, setDefaultValue, setName, setPassIn, transformSingleValue, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmailParameter

public EmailParameter(String name)
Create a new email parameter corresponding to a request parameter with the given name.

Parameters:
name - the name of the request parameter from which the email address is read.
Method Detail

transformValue

public Object transformValue(javax.servlet.http.HttpServletRequest request)
                      throws IllegalArgumentException
Retrieve the email address from the request. Returns null if the request parameter does not look like a valid email address.

Overrides:
transformValue in class StringParameter
Parameters:
request - represents the current request
Returns:
the transformed email address as a InternetAddress or null if there is no request parameter with the email parameter's name.
Throws:
IllegalArgumentException - if the request parameter does not look like a valid email address.

unmarshal

public Object unmarshal(String encoded)
                 throws IllegalArgumentException
Description copied from class: ParameterModel
Reconstruct the parameter value from an encoded string produced by marshal. This is an optional operation, which needs to be implemented by specific subclasses; this implementation just throws an UnsupportedOperationException.

The contract between marshal and unmarshal is that for any possible object obj this parameter model can produce obj.equals(unmarshal(marshal(obj)).

Overrides:
unmarshal in class StringParameter
Throws:
IllegalArgumentException

getValueClass

public Class getValueClass()
Description copied from class: ParameterModel
Return the class that all values produced by the model will have. This should be the most specific common base class of all classes of which the model will ever produce values. This implementation returns Object.class

Overrides:
getValueClass in class StringParameter


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC