Package org.fishbolt.common.presenter

The Value Presenter Pattern.

See:
          Description

Interface Summary
IPresentationsSuite<V,P> Declares a set of methods that give us an opportunity to represent a set of values in the user interface, for example, as a list.
IValuePresenter<V,P> This is the base interface of the value presenter.
 

Class Summary
BidirectValuePresenter<V,P> The class means for types with the infinite set of values.
BoundedValuePresenter<V,P> The class means for types with the bounded set of values.
CollectionValuePresenter<V,P> As is well known, the collections (java.util.Collection) are used in Java for working with a set of objects.
PresentationsSuite<V,P> Base implementation of IPresentationsSuite
ValuePresenter<V,P> The simplest implementation of the IValuePresenter interface The implementation of the ValuePresenter.getPresentation(Object) method takes into account that a value of argument can be empty (null).
ValuePresenterWrapper<V,P> Wraps presenters BidirectValuePresenter, BoundedValuePresenter or CollectionValuePresenter to the simple IValuePresenter.
 

Exception Summary
PresentationException Its thrown mostly when it's impossible to get value by its presentation
 

Package org.fishbolt.common.presenter Description

The Value Presenter Pattern.

The most of developers should well-know the common principles of the Model-View-Controller (MVC) pattern. To provide the complete MVC implementation for the chosen data structure and some concrete set of the program tools used for designing the user interface, developers have to solve a lot of difficult problems. Their solutions can be especially non-trivial, when we tell about the flexible data model that permits changes including the changes through the user interface.

We suggest to the developer firstly to solve the task, how to represent the unit information. After that, the following ways of the MVC pattern implementation becomes obvious. To solve the task of data presentation, let us introduce the term "presentation type" into practice: The presentation type is a type, to which some value is preliminary reduced for the following presentation in the user interface. Traditionally, a string (text) is one the most wild-spread forms of data: numerical, time, and logical types can be easily represented as a string.

Using such an abstraction as a presentation type decreases the dependency of a code from the concrete library used for designing the user interface. This approach gives us possibility, if necessary, to easily move to another library. Now it is necessary to have the code that is able to transform a value type to a presentation type. Note that the user interface often supposes possibility both to view, and to correct data (input). As a result, the reverse transformation task appears: transformation from a presentation type to a value type.

When we tell about a unit data, we imagine some data object having the concrete type. The number of possible values for some data type defines how the object having this type will be presented in the user interface. Thus, on the base of this information you should provide different visual elements to the user: a pick list (combo-box) to choose the value from the list of possible values, or a text field to insert some value. From the number of possible values point of view, every data type can be classified as follows:

  1. A data type with the bounded set of possible values (logical, enumeration).
  2. A data type having so many possible values that their number can be considered as infinity (real, integer).
  3. A collection. The collection can contain the objects having the first or second type (We don’t consider a collection of collections in our classification).