|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.barracudamvc.core.forms.DefaultFormElement
public class 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 Format |
format
|
protected String |
key
|
protected static org.apache.log4j.Logger |
logger
|
protected String |
name
|
protected Object |
origVal
|
protected FormMap |
parent
|
protected ParseException |
pe
|
protected FormType |
type
|
protected Object |
val
|
protected FormValidator |
validator
|
Constructor Summary | |
---|---|
DefaultFormElement()
Public noargs constructor. |
|
DefaultFormElement(FormElement feSource)
Public 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 |
int |
compareTo(Object o)
Compares with another object to determine ordering |
Object |
getDefaultVal()
Get the default value for this form element |
Format |
getFormat()
Set the Format object for this element (null indicates default formatting) |
String |
getKey()
Get the key value for this form element |
String |
getName()
Get the name of this form element |
Object |
getOrigVal()
Get the original value for this element |
FormMap |
getParentForm()
Get the parent form map |
ParseException |
getParseException()
Get any parse exceptions associated with the element (ie. that might have occurred when the element was mapped) |
FormType |
getType()
Get the FormType for this for element |
Object |
getVal()
Get the value for this element. |
Object |
getVal(Object dflt)
|
FormValidator |
getValidator()
Get the default FormValidator for this form element |
Object[] |
getVals()
Get all the values for this element. |
Object[] |
getVals(Object[] dflt)
|
FormElement |
setAllowMultiples(boolean val)
Set whether or not this element allows multiple values |
FormElement |
setDefaultVal(Object idefaultVal)
Set the default value for this form element |
FormElement |
setFormat(Format iformat)
Set the Format object for this element (null indicates default formatting) |
FormElement |
setKey(String ikey)
Set the key value for this form element |
FormElement |
setName(String iname)
Set the name of this form element |
FormElement |
setOrigVal(Object iorigVal)
Set the original value for this element |
FormElement |
setParentForm(FormMap iparent)
Set the parent form map |
FormElement |
setParseException(ParseException ipe)
Set the parse exception associated with this element |
FormElement |
setType(FormType itype)
Set the FormType for this form element |
FormElement |
setVal(Object ival)
Set the value for this element |
FormElement |
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 FormMap parent
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
protected Format format
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 namepublic DefaultFormElement(FormElement feSource)
feSource
- the form element on which to base this form elementMethod Detail |
---|
public FormElement setKey(String ikey)
setKey
in interface FormElement
ikey
- the key value for this form element
public String getKey()
getKey
in interface FormElement
public FormElement setName(String iname)
setName
in interface FormElement
iname
- the name of this form element
public String getName()
getName
in interface FormElement
public FormElement setType(FormType itype)
setType
in interface FormElement
itype
- the FormType for this form element
public FormType getType()
getType
in interface FormElement
public FormElement setDefaultVal(Object idefaultVal)
setDefaultVal
in interface FormElement
idefaultVal
- the FormType for this form element
public Object getDefaultVal()
getDefaultVal
in interface FormElement
public FormElement setAllowMultiples(boolean val)
setAllowMultiples
in interface FormElement
val
- true if the element allows multiples
public boolean allowMultiples()
allowMultiples
in interface FormElement
public FormElement setValidator(FormValidator ivalidator)
setValidator
in interface FormElement
ivalidator
- the FormValidator for this form element
public FormValidator getValidator()
getValidator
in interface FormElement
public FormElement setOrigVal(Object iorigVal)
setOrigVal
in interface FormElement
iorigVal
- the original value
public Object getOrigVal()
getOrigVal
in interface FormElement
public FormElement setVal(Object ival)
setVal
in interface FormElement
ival
- the value for this element
public Object getVal()
getVal
in interface FormElement
public Object getVal(Object dflt)
getVal
in interface FormElement
public Object[] getVals()
getVals
in interface FormElement
public Object[] getVals(Object[] dflt)
getVals
in interface FormElement
public FormElement setParseException(ParseException ipe)
setParseException
in interface FormElement
public ParseException getParseException()
getParseException
in interface FormElement
public FormElement setFormat(Format iformat)
setFormat
in interface FormElement
iformat
- the Format for this form element
public Format getFormat()
getFormat
in interface FormElement
public FormElement setParentForm(FormMap iparent)
setParentForm
in interface FormElement
iparent
- the parent map object
public FormMap getParentForm()
getParentForm
in interface FormElement
public int compareTo(Object o)
compareTo
in interface Comparable
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |