Home » Mojarra-2.0.1 » javax » faces » convert » [javadoc | source]
javax.faces.convert
public class: EnumConverter [javadoc | source]
java.lang.Object
   javax.faces.convert.EnumConverter

All Implemented Interfaces:
    PartialStateHolder, Converter

Converter implementation for java.lang.Enum (and enum primitive) values.

Field Summary
public static final  String CONVERTER_ID   

The standard converter id for this converter.

 
public static final  String ENUM_ID   

The message identifier of the javax.faces.application.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  String ENUM_NO_CLASS_ID   

The message identifier of the javax.faces.application.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:
 public EnumConverter() 
 public EnumConverter(Class targetClass) 
Method from javax.faces.convert.EnumConverter Summary:
clearInitialState,   getAsObject,   getAsString,   initialStateMarked,   isTransient,   markInitialState,   restoreState,   saveState,   setTransient
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.faces.convert.EnumConverter Detail:
 public  void clearInitialState() 
 public Object getAsObject(FacesContext context,
    UIComponent component,
    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.

 public String getAsString(FacesContext context,
    UIComponent component,
    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 argument is null, return null. If the value is an instance of the provided target class, return its string value by casting it to a java.lang.Enum and returning the result of calling the name() method. Otherwise, throw a ConverterException containing the #ENUM_ID message with proper parameters.

 public boolean initialStateMarked() 
 public boolean isTransient() 
 public  void markInitialState() 
 public  void restoreState(FacesContext facesContext,
    Object object) 
 public Object saveState(FacesContext facesContext) 
 public  void setTransient(boolean b)