Package org.apache.fulcrum.intake.model
Klasse Field<T>
java.lang.Object
org.apache.fulcrum.intake.model.Field<T>
- Alle implementierten Schnittstellen:
Serializable
,org.apache.avalon.framework.logger.LogEnabled
- Bekannte direkte Unterklassen:
BigDecimalField
,BooleanField
,DateStringField
,DoubleField
,FloatField
,IntegerField
,LongField
,ShortField
,StringField
,UploadPartField
public abstract class Field<T>
extends Object
implements Serializable, org.apache.avalon.framework.logger.LogEnabled
Base class for Intake generated input processing classes.
- Version:
- $Id$
- Autor:
- John McNally, Daniel Rall, Henning P. Schmiedehausen, Quinton McCombs, Jürgen Hoffmann, Thomas Vandahl
- Siehe auch:
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final String
Default Field Packagestatic final String
Default Validator Packageprotected T
Default value of the fieldprotected T
Value of the field to use if the mapped parameter is empty or non-existentprotected org.apache.avalon.framework.logger.Logger
Loggingprotected String
Class name of the object to which the field is mappedprotected org.apache.fulcrum.parser.ValueParser
The object containing the field data. -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
dispose()
Disposes the object after use.protected abstract void
Sets the value of the field from data in the parser.void
enableLogging
(org.apache.avalon.framework.logger.Logger logger) Enable Avalon Loggingvoid
Loads the default value from the objectprotected String
Produces the fully qualified class name of the default validator.Get the default ValueGet the display name of the field.Gets the display size of the field.Get the Value to use if the field is emptygetGroup()
Returns theGroup
this field belongs to ornull
if unknown.Calls toString() on the object returned by getValue(), unless null; and then it returns "", the empty String.Get the value used as a default.getKey()
Get the key used to identify the field.Returns theLocale
used when localizing data for this field, ornull
if unknown.Get the name of the object that takes this inputGets the maximum size of the field.Get any error message resulting from invalid input.getName()
Gets the name of the field.void
getProperty
(Object obj) Loads the valid value from a beanprotected Object
Provides access to emptyValue such that the value returned will be acceptable as an argument parameter to Method.invoke.Gets the String representation of the Value.<TT> TT
Get the value input by a user that will be validated.Gets the Validator object for this field.getValue()
Get the value of the field.Use in a hidden field assign a default value in the event the field is absent from the query parameters.init
(Retrievable obj) Method called when this field or the group it belongs to is pulled from the pool.init
(org.apache.fulcrum.parser.ValueParser pp) Method called when this field (the group it belongs to) is pulled from the pool.void
Initialize getter and setter from propertiesboolean
Flag to determine whether the field has been declared as multi-valued.boolean
Flag to determine whether the field has been declared as required.boolean
isSet()
Flag set to true, if the test value has been set by the parser (even to an empty value, so don't used this to determine if the field contains a non-empty value).boolean
isValid()
Flag set to true, if the test value met the constraints.boolean
Flag to determine whether the field has been validated.void
Removes references to this group and its fields from the query parametersabstract void
setDefaultValue
(String prop) Set the default Value.void
setDisplayName
(String newDisplayName) Set the display name of the field.abstract void
setEmptyValue
(String prop) Set the empty Value.void
setMessage
(String message) Sets an error message.void
setProperty
(Object obj) Calls a setter method on obj, if this field has been set.void
setRequired
(boolean v) Set whether this field is required to have a value.void
setRequired
(boolean v, String message) Set the value of required.protected void
setSet
(boolean setFlag) Set the internal flag that the field has been setprotected void
setValid
(boolean validFlag) Set the internal flag that the field is validprotected void
setValidated
(boolean validated) Set the internal flag that the field has been validatedtoString()
Calls toString() on the object returned by getValue(), unless null; and then it returns "", the empty String.boolean
validate()
Compares request data with constraints and sets the valid flag.
-
Felddetails
-
defaultValidatorPackage
Default Validator Package- Siehe auch:
-
defaultFieldPackage
Default Field Package- Siehe auch:
-
mapToObject
Class name of the object to which the field is mapped -
defaultValue
Default value of the field -
emptyValue
Value of the field to use if the mapped parameter is empty or non-existent -
parser
protected org.apache.fulcrum.parser.ValueParser parserThe object containing the field data. -
log
protected transient org.apache.avalon.framework.logger.Logger logLogging
-
-
Konstruktordetails
-
Field
Constructs a field based on data in the xml specification and assigns it to a Group.- Parameter:
field
- aXmlField
valuegroup
- aGroup
value- Löst aus:
IntakeException
- indicates the validator was not valid or could not be loaded.
-
-
Methodendetails
-
enableLogging
public void enableLogging(org.apache.avalon.framework.logger.Logger logger) Enable Avalon Logging- Angegeben von:
enableLogging
in Schnittstelleorg.apache.avalon.framework.logger.LogEnabled
-
initGetterAndSetter
public void initGetterAndSetter()Initialize getter and setter from properties -
init
Method called when this field (the group it belongs to) is pulled from the pool. The request data is searched to determine if a value has been supplied for this field. If so, the value is validated.- Parameter:
pp
- aValueParser
value- Gibt zurück:
- a
Field
value - Löst aus:
IntakeException
- this exception is only thrown by subclasses overriding this implementation.
-
init
Method called when this field or the group it belongs to is pulled from the pool. The retrievable object can provide a default value for the field, or using setProperty the field's value can be transferred to the retrievable.- Parameter:
obj
- aRetrievable
value- Gibt zurück:
- a
Field
value
-
getGroup
Returns theGroup
this field belongs to ornull
if unknown.- Gibt zurück:
- The group this field belongs to.
-
getLocale
Returns theLocale
used when localizing data for this field, ornull
if unknown.- Gibt zurück:
- Where to localize for.
-
getDefaultValidator
Produces the fully qualified class name of the default validator.- Gibt zurück:
- class name of the default validator
-
getValidator
Gets the Validator object for this field.- Gibt zurück:
- a
Validator
object
-
getMapToObject
Get the name of the object that takes this input- Gibt zurück:
- the name of the mapped object
-
isMultiValued
public boolean isMultiValued()Flag to determine whether the field has been declared as multi-valued.- Gibt zurück:
- value of isMultiValued.
-
isRequired
public boolean isRequired()Flag to determine whether the field has been declared as required.- Gibt zurück:
- value of required.
-
setRequired
public void setRequired(boolean v) Set whether this field is required to have a value. If the field is already required due to a setting in the XML file, this method can not set it to false.- Parameter:
v
- Value to assign to required.
-
setRequired
Set the value of required.- Parameter:
v
- aboolean
valuemessage
- override the value from intake.xml
-
removeFromRequest
public void removeFromRequest()Removes references to this group and its fields from the query parameters -
dispose
public void dispose()Disposes the object after use. The method is called when the Group is returned to its pool. if overridden, super.dispose() should be called. -
getKey
Get the key used to identify the field.- Gibt zurück:
- the query data key.
-
getValueIfAbsent
Use in a hidden field assign a default value in the event the field is absent from the query parameters. Used to track checkboxes, since they only show up if checked.- Gibt zurück:
- the value if not in the request
-
isValid
public boolean isValid()Flag set to true, if the test value met the constraints. Is also true, in the case the test value was not set, unless this field has been marked as required.- Gibt zurück:
- a
boolean
value
-
isValidated
public boolean isValidated()Flag to determine whether the field has been validated.- Gibt zurück:
- value of validated.
-
isSet
public boolean isSet()Flag set to true, if the test value has been set by the parser (even to an empty value, so don't used this to determine if the field contains a non-empty value). Validation will only be executed for fields that have been set in this manner.- Gibt zurück:
- a
boolean
value
-
getDisplayName
Get the display name of the field. Useful for building data entry forms. Returns name of field if no display name has been assigned to the field by xml input file.- Gibt zurück:
- a
String
value
-
setDisplayName
Set the display name of the field. Display names are used in building data entry forms and serve as a user friendly description of the data contained in the field.- Parameter:
newDisplayName
- the new display name for the field
-
getMessage
Get any error message resulting from invalid input.- Gibt zurück:
- a
String
value
-
setMessage
Sets an error message. The field is also marked as invalid.- Parameter:
message
- the new error message
-
setSet
protected void setSet(boolean setFlag) Set the internal flag that the field has been set- Parameter:
setFlag
- the setFlag to set
-
setValid
protected void setValid(boolean validFlag) Set the internal flag that the field is valid- Parameter:
validFlag
- the validFlag to set
-
setValidated
protected void setValidated(boolean validated) Set the internal flag that the field has been validated- Parameter:
validated
- the validated to set
-
validate
public boolean validate()Compares request data with constraints and sets the valid flag.- Gibt zurück:
- true if the validation succeeded
-
setDefaultValue
Set the default Value. This value is used if Intake should map this field to a new object.- Parameter:
prop
- The value to use if the field is mapped to a new object.
-
setEmptyValue
Set the empty Value. This value is used if Intake maps a field to a parameter returned by the user and the corresponding field is either empty (empty string) or non-existent.- Parameter:
prop
- The value to use if the field is empty.
-
doSetValue
protected abstract void doSetValue()Sets the value of the field from data in the parser. -
getInitialValue
Get the value used as a default. If the initial value has not been set and aRetrievable
object has been associated with this field, the objects property will be used as the initial value.- Gibt zurück:
- an
Object
value - Löst aus:
IntakeException
- indicates the value could not be returned from the mapped object
-
getTestValue
public <TT> TT getTestValue()Get the value input by a user that will be validated.- Typparameter:
TT
- the type of the test value- Gibt zurück:
- an
TT
value
-
getValue
Get the value of the field. if a test value has been set, it will be returned as is, unless it is so badly formed that the validation could not parse it. In most cases the test value is returned even though invalid, so that it can be returned to the user to make modifications. If the test value is not set the initial value is returned.- Gibt zurück:
- an
Object
value
-
toString
Calls toString() on the object returned by getValue(), unless null; and then it returns "", the empty String. -
getHTMLString
Calls toString() on the object returned by getValue(), unless null; and then it returns "", the empty String. Escapes " characters to be able to display these in HTML form fields.- Gibt zurück:
- a
String
value
-
getProperty
Loads the valid value from a bean- Parameter:
obj
- the object whose getter to call- Löst aus:
IntakeException
- indicates a problem during the execution of the object's getter method
-
getDefault
public void getDefault()Loads the default value from the object -
setProperty
Calls a setter method on obj, if this field has been set.- Parameter:
obj
- the object whose setter to call- Löst aus:
IntakeException
- indicates a problem during the execution of the object's setter method
-
getDefaultValue
Get the default Value- Gibt zurück:
- the default value
-
getEmptyValue
Get the Value to use if the field is empty- Gibt zurück:
- the value to use if the field is empty.
-
getSafeEmptyValue
Provides access to emptyValue such that the value returned will be acceptable as an argument parameter to Method.invoke. Subclasses that deal with primitive types should ensure that they return an appropriate value wrapped in the object wrapper class for the primitive type.- Gibt zurück:
- the value to use when the field is empty or an Object that wraps the empty value for primitive types.
-
getName
Gets the name of the field.- Gibt zurück:
- name of the field as specified in the XML file.
-
getDisplaySize
Gets the display size of the field. This is useful when building the HTML input tag. If no displaySize was set, an empty string is returned.- Gibt zurück:
- the size information for this field
-
getMaxSize
Gets the maximum size of the field. This is useful when building the HTML input tag. The maxSize is set with the maxLength rule. If this rule was not set, an empty string is returned.- Gibt zurück:
- the maximum size information of the field
-
getStringValue
Gets the String representation of the Value. This is basically a wrapper method for the toString method which doesn't seem to show anything on screen if accessed from Template. Name is also more in line with getValue method which returns the actual Object. This is useful for displaying correctly formatted data such as dates, such as 18/11/1968 instead of the toString dump of a Date Object.- Gibt zurück:
- the String Value
-