|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.faces.convert.EnumConverter
public class EnumConverter
Converter implementation for java.lang.Enum
(and enum primitive) values.
| Field Summary | |
|---|---|
static java.lang.String |
CONVERTER_ID
The standard converter id for this converter. |
static java.lang.String |
ENUM_ID
The message identifier of the FacesMessage to be created if
the conversion to Enum fails. |
static java.lang.String |
ENUM_NO_CLASS_ID
The message identifier of the FacesMessage to be created if
the conversion to Enum fails and no target class has been
provided. |
| Constructor Summary | |
|---|---|
EnumConverter()
|
|
EnumConverter(java.lang.Class targetClass)
|
|
| Method Summary | |
|---|---|
java.lang.Object |
getAsObject(FacesContext context,
UIComponent component,
java.lang.String value)
Convert the value argument to one of the enum
constants of the class provided in our constructor. |
java.lang.String |
getAsString(FacesContext context,
UIComponent component,
java.lang.Object value)
Convert the enum constant given by the value
argument into a String. |
boolean |
isTransient()
If true, the Object implementing this interface must not participate in state saving or restoring. |
void |
restoreState(FacesContext facesContext,
java.lang.Object object)
Perform any processing required to restore the state from the entries in the state Object. |
java.lang.Object |
saveState(FacesContext facesContext)
Gets the state of the instance as a Serializable Object. |
void |
setTransient(boolean b)
Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CONVERTER_ID
The standard converter id for this converter.
public static final java.lang.String ENUM_ID
The message identifier of the FacesMessage to be created if
the conversion to Enum fails. The message format
string for this message may optionally include the following
placeholders:
{0} replaced by the unconverted value.{1} replaced by one of the enum constants or the empty
string if none can be found.{2} replaced by a String whose value
is the label of the input component that produced this message.
public static final java.lang.String ENUM_NO_CLASS_ID
The message identifier of the FacesMessage to be created if
the conversion to Enum fails and no target class has been
provided. The message format
string for this message may optionally include the following
placeholders:
{0} replaced by the unconverted value.{1} replaced by a String whose value
is the label of the input component that produced this message.
| Constructor Detail |
|---|
public EnumConverter()
public EnumConverter(java.lang.Class targetClass)
| Method Detail |
|---|
public java.lang.Object getAsObject(FacesContext context,
UIComponent component,
java.lang.String value)
Convert the value argument to one of the enum
constants of the class provided in our constructor. If no
target class argument has been provided to the constructor of
this instance, throw a ConverterException
containing the ENUM_NO_CLASS_ID message with proper
parameters. If the value argument is null
or it has a length of zero, return null.
Otherwise, perform the equivalent of Enum.valueOf using
target class and value and return the Object.
If the conversion fails, throw a ConverterException
containing the ENUM_ID message with proper parameters.
getAsObject in interface Convertercontext - the FacesContext for this request.component - the UIComponent to which this value
will be applied.value - the String value to be converted to
Object.
null if the value to convert is null,
otherwise the result of the conversion
ConverterException - if conversion cannot be successfully
performed
java.lang.NullPointerException - if context or
component is null
public java.lang.String getAsString(FacesContext context,
UIComponent component,
java.lang.Object value)
Convert the enum constant given by the value
argument into a String. If no target class argument has been
provided to the constructor of this instance, throw a
ConverterException containing the
ENUM_NO_CLASS_ID message with proper parameters. If the
value,/code> argument is null, return null.
If the value is an instance of the provided target class, return its
string value (value.toString()). Otherwise, throw a
ConverterException containing the ENUM_ID message with
proper parameters.
getAsString in interface Convertercontext - FacesContext for the request being processedcomponent - UIComponent with which this model object
value is associatedvalue - Model object value to be converted
(may be null)
null,
otherwise the result of the conversion
ConverterException - if conversion cannot be successfully
performed
java.lang.NullPointerException - if context or
component is null
public void restoreState(FacesContext facesContext,
java.lang.Object object)
StateHolderPerform any processing required to restore the state from the entries in the state Object.
If the class that implements this interface has references to
instances that also implement StateHolder (such as a
UIComponent with event handlers, validators, etc.)
this method must call the StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object) method on all those
instances as well.
restoreState in interface StateHolderpublic java.lang.Object saveState(FacesContext facesContext)
StateHolder Gets the state of the instance as a
Serializable Object.
If the class that implements this interface has references to
instances that implement StateHolder (such as a
UIComponent with event handlers, validators, etc.)
this method must call the StateHolder.saveState(javax.faces.context.FacesContext) method on all those
instances as well. This method must not save the state
of children and facets. That is done via the StateManager
This method must not alter the state of the implementing object. In other words, after executing this code:
Object state = component.saveState(facesContext);
component should be the same as before executing
it.
The return from this method must be Serializable
saveState in interface StateHolderpublic void setTransient(boolean b)
StateHolderDenotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
setTransient in interface StateHolderb - boolean pass true if this Object
will participate in state saving or restoring, otherwise
pass false.public boolean isTransient()
StateHolderIf true, the Object implementing this interface must not participate in state saving or restoring.
isTransient in interface StateHolder
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||