Package net.sf.jguiraffe.transform

The transform package contains interfaces and classes for transforming and validating data.

See:
          Description

Interface Summary
Transformer Definition of the Transformer interface.
TransformerContext Definition of an interface for accessing data needed by transformers.
ValidationMessage Definition of an interface describing a validation message.
ValidationMessageHandler Definition of an interface for a central instance that manages validation messages.
ValidationResult An interface that defines the results of a validation process.
Validator Definition of a validator interface.
 

Class Summary
AbstractDecimalTransformer<T extends Number> A base class for number transformers that operate on floating point numbers.
AbstractIntegerTransformer<T extends Number> A base class for number transformers that operate on integer numbers.
ChainValidator A special Validator implementation that allows to combine multiple primitive validators.
DateTimeTransformer A specialized transformer that transforms strings into date objects with both a date and time component.
DateTransformer A specialized transformer that transforms strings into date objects.
DateTransformerBase An abstract base class for date transformer objects.
DefaultValidationMessageHandler A default implementation of the ValidationMessageHandler interface.
DefaultValidationResult A default implementation of the ValidationResult interface.
DefaultValidationResult.Builder A builder class for creating instances of DefaultValidationResult.
DoubleTransformer A specialized number transformer implementation that deals with numbers of type java.lang.Double.
DummyTransformer This class provides dummy implementations for the Transformer and the Validator interfaces.
FloatTransformer A specialized number transformer implementation that deals with numbers of type java.lang.Float.
IntegerTransformer A specialized number transformer implementation that deals with numbers of type java.lang.Integer.
LongTransformer A specialized number transformer implementation that deals with numbers of type java.lang.Long.
NumberTransformerBase<T extends Number> An abstract base class for transformers and validators for numbers.
RegexValidator A specialized Validator implementation that uses regular expressions to validate user input.
RequiredValidator A specialized Validator implementation that checks whether data was entered in mandatory fields.
TimeTransformer A specialized transformer that transforms strings into date objects, taking only the time portion into account.
ToStringTransformer A generic Transformer implementation that transforms arbitrary objects into formatted strings.
TransformerContextPropertiesWrapper A specialized implementation of the TransformerContext interface that allows wrapping an existing context and extending its properties.
ValidationMessageConstants This class defines constants for the keys of validation messages.
 

Enum Summary
ValidationMessageLevel An enumeration class that defines possible levels for validation messages.
 

Package net.sf.jguiraffe.transform Description

The transform package contains interfaces and classes for transforming and validating data.

Form processing always includes the validation of the data entered by the user. If input is valid, it has to be copied into the application's data model. This step may require the conversion of data into some other types to conform with the types used within the model.

This package deals with both of these use cases. It defines the Transformer interface for data conversion and the Validator interface for validation. There are also fully functional implementations of these interfaces for the most common use cases.

It is also possible to implement custom transformers and validators. The interfaces are straight forward and easy to implement. When defining a form using the GUI builder the transformers and validators to use can be specified.

The Form class representing an input form in this framework implements some functionality for processing data entered by the user. It first invokes all registered validators on the input components. Only if this step was successful, the transformers are invoked. This causes the data entered by the user to be converted as necessary and copied into the bean associated with the form.

If a validator finds out that an input field contains invalid data, it returns a ValidationResult object with one or more error messages. Each message consists of a key that is specific for this kind of error message and a text to be displayed to the user. This text can contain further information about the error and how to resolve it (e.g. something like "This field must contain a number less than 100"; note that dynamic data depending on the validator's configuration is automatically added). In the documentation of each validator class the possible error messages are listed.

In addition to the key and the message a ValidationResult object also contains a level. The default level is ERROR indicating the input is actually invalid. It is also possible to use the level WARNING, which means that the input will be accepted, but may cause problems. Whether a validator produces error or warning messages can be configured with properties in the TransformerContext. For more information refer to the documentation of DefaultValidationMessageHandler.

Changing the error messages for certain or all validators is an often required use case. Per default error messages are obtained from the resource manager: the key of the error message is used as resource ID, as resource group the reserved name "validators" is used. The framework is shipped with default error messages in a couple of supported languages. If a specific language you need is not supported, you can add your own bundle for this language. To override specific validation error messages there are the following options:

$Id: package.html 172 2009-11-28 20:05:18Z oheger $



Copyright © 2009 The JGUIraffe Team. All Rights Reserved.