|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.enhydra.barracuda.core.forms.DefaultFormElement
A FormElement defines how an element in a FormMap should be mapped to a first class java object. There are several key pieces of information required:
Once we have this information, we basically have enough data to map a String value in the data source to a first class Java object in the element.
Note that the element keeps track of the original value as well, so that if for some reason you ever need to get to it that information is available.
Also not that we provide convenience methods which automatically cast for you (Note however: this type of thing is not type safe, meaning that you can get a ClassCastException if you do a getXXXVal() when the underlying object is not of type XXX.
Field Summary | |
protected boolean |
allowMultiples
|
protected Object |
defaultVal
|
protected String |
key
|
protected static org.apache.log4j.Logger |
logger
|
protected String |
name
|
protected Object |
origVal
|
protected ParseException |
pe
|
protected FormType |
type
|
protected Object |
val
|
protected FormValidator |
validator
|
Constructor Summary | |
DefaultFormElement()
Public noargs constructor. |
|
DefaultFormElement(String ikey)
Public constructor. |
|
DefaultFormElement(String ikey,
FormType itype)
Public constructor. |
|
DefaultFormElement(String ikey,
FormType itype,
Object idefaultVal)
Public constructor. |
|
DefaultFormElement(String ikey,
FormType itype,
Object idefaultVal,
FormValidator ivalidator)
Public constructor. |
|
DefaultFormElement(String ikey,
FormType itype,
Object idefaultVal,
FormValidator ivalidator,
boolean iallowMultiples)
Public constructor, Name defaults to Key |
|
DefaultFormElement(String ikey,
String iname,
FormType itype,
Object idefaultVal,
FormValidator ivalidator,
boolean iallowMultiples)
Public constructor |
Method Summary | |
boolean |
allowMultiples()
Does this element allow multiple values |
Boolean |
getBooleanVal()
Get the value for this element as a Boolean |
Boolean |
getBooleanVal(Boolean dflt)
Get a Boolean value from the map, defaulting accordingly if the value is null |
Date |
getDateVal()
Get the value for this element as a Date |
Date |
getDateVal(Date dflt)
Get a Date value from the map, defaulting accordingly if the value is null |
Object |
getDefaultVal()
Get the default value for this form element |
Double |
getDoubleVal()
Get the value for this element as a Double |
Double |
getDoubleVal(Double dflt)
Get a Double value from the map, defaulting accordingly if the value is null |
Float |
getFloatVal()
Get the value for this element as a Float |
Float |
getFloatVal(Float dflt)
Get a Float value from the map, defaulting accordingly if the value is null |
Integer |
getIntegerVal()
Get the value for this element as a Integer |
Integer |
getIntegerVal(Integer dflt)
Get a Integer value from the map, defaulting accordingly if the value is null |
String |
getKey()
Get the key value for this form element |
Long |
getLongVal()
Get the value for this element as a Long |
Long |
getLongVal(Long dflt)
Get a Long value from the map, defaulting accordingly if the value is null |
String |
getName()
Get the name of this form element |
Object |
getOrigVal()
Get the original value for this element |
ParseException |
getParseException()
Get any parse exceptions associated with the element (ie. that might have occurred when the element was mapped) |
Short |
getShortVal()
Get the value for this element as a Short |
Short |
getShortVal(Short dflt)
Get a Short value from the map, defaulting accordingly if the value is null |
String |
getStringVal()
Get the value for this element as a String |
String |
getStringVal(String dflt)
Get the value for this element as a String, defaulting accordingly if the value is null |
FormType |
getType()
Get the FormType for this for element |
Object |
getVal()
Get the value for this element. |
FormValidator |
getValidator()
Get the default FormValidator for this form element |
Object[] |
getVals()
Get all the values for this element. |
void |
setAllowMultiples(boolean val)
Set whether or not this element allows multiple values |
void |
setDefaultVal(Object idefaultVal)
Set the default value for this form element |
void |
setKey(String ikey)
Set the key value for this form element |
void |
setName(String iname)
Set the name of this form element |
void |
setOrigVal(Object iorigVal)
Set the original value for this element |
void |
setParseException(ParseException ipe)
Set the parse exception associated with this element |
void |
setType(FormType itype)
Set the FormType for this form element |
void |
setVal(Object ival)
Set the value for this element |
void |
setValidator(FormValidator ivalidator)
Set the FormValidator for this form element |
String |
toString()
Get a string representation of this element |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final org.apache.log4j.Logger logger
protected String key
protected String name
protected FormType type
protected Object defaultVal
protected ParseException pe
protected FormValidator validator
protected boolean allowMultiples
protected Object origVal
protected Object val
Constructor Detail |
public DefaultFormElement()
public DefaultFormElement(String ikey)
ikey
- the key name in the data sourcepublic DefaultFormElement(String ikey, FormType itype)
ikey
- the key name in the data sourceitype
- the FormType for the elementpublic DefaultFormElement(String ikey, FormType itype, Object idefaultVal)
ikey
- the key name in the data sourceitype
- the FormType for the elementidefaultVal
- the default value to be used if the key is
not found in the data source or the value for the key is nullpublic DefaultFormElement(String ikey, FormType itype, Object idefaultVal, FormValidator ivalidator)
ikey
- the key name in the data sourceitype
- the FormType for the elementidefaultVal
- the default value to be used if the key is
not found in the data source or the value for the key is nullivalidator
- the FormValidator associated with this elementpublic DefaultFormElement(String ikey, FormType itype, Object idefaultVal, FormValidator ivalidator, boolean iallowMultiples)
ikey
- the key name in the data sourceitype
- the FormType for the elementidefaultVal
- the default value to be used if the key is
not found in the data source or the value for the key is nullivalidator
- the FormValidator associated with this elementiallowMultiples
- true if there may be multiple values in the datasource
for this particular key namepublic DefaultFormElement(String ikey, String iname, FormType itype, Object idefaultVal, FormValidator ivalidator, boolean iallowMultiples)
ikey
- the key name in the data sourceiname
- the name for the elementitype
- the FormType for the elementidefaultVal
- the default value to be used if the key is
not found in the data source or the value for the key is nullivalidator
- the FormValidator associated with this elementiallowMultiples
- true if there may be multiple values in the datasource
for this particular key nameMethod Detail |
public void setKey(String ikey)
setKey
in interface FormElement
ikey
- the key value for this form elementpublic String getKey()
getKey
in interface FormElement
public void setName(String iname)
setName
in interface FormElement
iname
- the name of this form elementpublic String getName()
getName
in interface FormElement
public void setType(FormType itype)
setType
in interface FormElement
itype
- the FormType for this form elementpublic FormType getType()
getType
in interface FormElement
public void setDefaultVal(Object idefaultVal)
setDefaultVal
in interface FormElement
idefaultVal
- the FormType for this form elementpublic Object getDefaultVal()
getDefaultVal
in interface FormElement
public void setAllowMultiples(boolean val)
setAllowMultiples
in interface FormElement
val
- true if the element allows multiplespublic boolean allowMultiples()
allowMultiples
in interface FormElement
public void setValidator(FormValidator ivalidator)
setValidator
in interface FormElement
ivalidator
- the FormValidator for this form elementpublic FormValidator getValidator()
getValidator
in interface FormElement
public void setOrigVal(Object iorigVal)
setOrigVal
in interface FormElement
iorigVal
- the original valuepublic Object getOrigVal()
getOrigVal
in interface FormElement
public void setVal(Object ival)
setVal
in interface FormElement
ival
- the value for this elementpublic Object getVal()
getVal
in interface FormElement
public Object[] getVals()
getVals
in interface FormElement
public String getStringVal()
getStringVal
in interface FormElement
public String getStringVal(String dflt)
getStringVal
in interface FormElement
public Boolean getBooleanVal()
getBooleanVal
in interface FormElement
public Boolean getBooleanVal(Boolean dflt)
getBooleanVal
in interface FormElement
public Integer getIntegerVal()
getIntegerVal
in interface FormElement
public Integer getIntegerVal(Integer dflt)
getIntegerVal
in interface FormElement
public Date getDateVal()
getDateVal
in interface FormElement
public Date getDateVal(Date dflt)
getDateVal
in interface FormElement
public Long getLongVal()
getLongVal
in interface FormElement
public Long getLongVal(Long dflt)
getLongVal
in interface FormElement
public Short getShortVal()
getShortVal
in interface FormElement
public Short getShortVal(Short dflt)
getShortVal
in interface FormElement
public Double getDoubleVal()
getDoubleVal
in interface FormElement
public Double getDoubleVal(Double dflt)
getDoubleVal
in interface FormElement
public Float getFloatVal()
getFloatVal
in interface FormElement
public Float getFloatVal(Float dflt)
getFloatVal
in interface FormElement
public void setParseException(ParseException ipe)
setParseException
in interface FormElement
public ParseException getParseException()
getParseException
in interface FormElement
public String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |