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

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    static final String
    Default Field Package
    static final String
    Default Validator Package
    protected T
    Default value of the field
    protected T
    Value of the field to use if the mapped parameter is empty or non-existent
    protected org.apache.avalon.framework.logger.Logger
    Logging
    protected String
    Class name of the object to which the field is mapped
    protected org.apache.fulcrum.parser.ValueParser
    The object containing the field data.
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    Field(XmlField field, Group group)
    Constructs a field based on data in the xml specification and assigns it to a Group.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    void
    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 Logging
    void
    Loads the default value from the object
    protected String
    Produces the fully qualified class name of the default validator.
    Get the default Value
    Get the display name of the field.
    Gets the display size of the field.
    Get the Value to use if the field is empty
    Returns the Group this field belongs to or null 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.
    Get the key used to identify the field.
    Returns the Locale used when localizing data for this field, or null if unknown.
    Get the name of the object that takes this input
    Gets the maximum size of the field.
    Get any error message resulting from invalid input.
    Gets the name of the field.
    void
    Loads the valid value from a bean
    protected 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.
    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.
    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 properties
    boolean
    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
    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
    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 parameters
    abstract void
    Set the default Value.
    void
    setDisplayName(String newDisplayName)
    Set the display name of the field.
    abstract void
    Set the empty Value.
    void
    setMessage(String message)
    Sets an error message.
    void
    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 set
    protected void
    setValid(boolean validFlag)
    Set the internal flag that the field is valid
    protected void
    setValidated(boolean validated)
    Set the internal flag that the field has been validated
    Calls toString() on the object returned by getValue(), unless null; and then it returns "", the empty String.
    boolean
    Compares request data with constraints and sets the valid flag.

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Felddetails

    • defaultValidatorPackage

      public static final String defaultValidatorPackage
      Default Validator Package
      Siehe auch:
    • defaultFieldPackage

      public static final String defaultFieldPackage
      Default Field Package
      Siehe auch:
    • mapToObject

      protected String mapToObject
      Class name of the object to which the field is mapped
    • defaultValue

      protected T defaultValue
      Default value of the field
    • emptyValue

      protected T emptyValue
      Value of the field to use if the mapped parameter is empty or non-existent
    • parser

      protected org.apache.fulcrum.parser.ValueParser parser
      The object containing the field data.
    • log

      protected transient org.apache.avalon.framework.logger.Logger log
      Logging
  • Konstruktordetails

    • Field

      public Field(XmlField field, Group group) throws IntakeException
      Constructs a field based on data in the xml specification and assigns it to a Group.
      Parameter:
      field - a XmlField value
      group - a Group 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 Schnittstelle org.apache.avalon.framework.logger.LogEnabled
    • initGetterAndSetter

      public void initGetterAndSetter()
      Initialize getter and setter from properties
    • init

      public Field<T> init(org.apache.fulcrum.parser.ValueParser pp) throws IntakeException
      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 - a ValueParser value
      Gibt zurück:
      a Field value
      Löst aus:
      IntakeException - this exception is only thrown by subclasses overriding this implementation.
    • init

      public Field<T> init(Retrievable obj)
      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 - a Retrievable value
      Gibt zurück:
      a Field value
    • getGroup

      public Group getGroup()
      Returns the Group this field belongs to or null if unknown.
      Gibt zurück:
      The group this field belongs to.
    • getLocale

      public Locale getLocale()
      Returns the Locale used when localizing data for this field, or null if unknown.
      Gibt zurück:
      Where to localize for.
    • getDefaultValidator

      protected String getDefaultValidator()
      Produces the fully qualified class name of the default validator.
      Gibt zurück:
      class name of the default validator
    • getValidator

      public Validator<T> getValidator()
      Gets the Validator object for this field.
      Gibt zurück:
      a Validator object
    • getMapToObject

      public String 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

      public void setRequired(boolean v, String message)
      Set the value of required.
      Parameter:
      v - a boolean value
      message - 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

      public String getKey()
      Get the key used to identify the field.
      Gibt zurück:
      the query data key.
    • getValueIfAbsent

      public String 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

      public String 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

      public void setDisplayName(String newDisplayName)
      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

      public String getMessage()
      Get any error message resulting from invalid input.
      Gibt zurück:
      a String value
    • setMessage

      public void setMessage(String message)
      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

      public abstract void setDefaultValue(String prop)
      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

      public abstract void setEmptyValue(String prop)
      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

      public T getInitialValue() throws IntakeException
      Get the value used as a default. If the initial value has not been set and a Retrievable 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

      public T 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

      public String toString()
      Calls toString() on the object returned by getValue(), unless null; and then it returns "", the empty String.
      Setzt außer Kraft:
      toString in Klasse Object
      Gibt zurück:
      a String value
    • getHTMLString

      public 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

      public void getProperty(Object obj) throws IntakeException
      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

      public void setProperty(Object obj) throws IntakeException
      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

      public T getDefaultValue()
      Get the default Value
      Gibt zurück:
      the default value
    • getEmptyValue

      public T getEmptyValue()
      Get the Value to use if the field is empty
      Gibt zurück:
      the value to use if the field is empty.
    • getSafeEmptyValue

      protected Object 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

      public String getName()
      Gets the name of the field.
      Gibt zurück:
      name of the field as specified in the XML file.
    • getDisplaySize

      public String 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

      public String 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

      public String 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