org.mmbase.datatypes.handlers
Class AbstractHandler<C>

Package class diagram package AbstractHandler
java.lang.Object
  extended by org.mmbase.datatypes.handlers.AbstractHandler<C>
All Implemented Interfaces:
Serializable, Handler<C>
Direct Known Subclasses:
HtmlHandler

public abstract class AbstractHandler<C>
extends Object
implements Handler<C>

Handlers can be associated to DataTypes, but different Handler can be associated with different content types. The main implementation will of course be one that produces HTML, like forms, and post and things like that.

Since:
MMBase-1.9.1
Version:
$Id: AbstractHandler.java 44500 2011-01-05 10:43:44Z michiel $
Author:
Michiel Meeuwissen
See Also:
Serialized Form

Constructor Summary
AbstractHandler()
           
 
Method Summary
protected  Object cast(Object value, Node node, Field field)
           
abstract  C check(Request request, Node node, Field field, boolean errors)
          Checks the user input, and invalidates the request, if this user input was invalid.
protected  String findString(Request request, Field field)
           
protected  Object getEvaluatedFieldValue(Request request, Node node, Field field)
          Returns the field value to be used in the page.
protected  Object getFieldValue(Request request, Node node, Field field)
          Returns the field value as specified by the client's post.
protected  Object getFieldValue(Request request, Node node, Field field, boolean form)
           
protected  int getOperator(Field field)
          The operator to be used by search(request, field, query)
protected  Object getSearchFieldValue(Request request, Field field)
           
protected  String getSearchValue(String string, Field field, int operator)
          Converts the value to the actual value to be searched.
protected  Object getValue(Node node, String fieldName)
           
protected  String id(String s)
          Puts a prefix 'mm_' before an id in form fields.
abstract  C input(Request request, Node node, Field field, boolean search)
          Produces an form input field for the given Node, and Field.
protected  boolean interpretEmptyAsNull(Field field)
           
 Constraint search(Request request, Field field, Query query)
          Uses the user's input to create a constraint for the given query
 boolean set(Request request, Node node, Field field)
          Sets the user's input into the field of the node
protected  void setValue(Request request, Node node, String fieldName, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mmbase.datatypes.handlers.Handler
id
 

Constructor Detail

AbstractHandler

public AbstractHandler()
Method Detail

id

protected String id(String s)
Puts a prefix 'mm_' before an id in form fields. To be used in ccs etc..


interpretEmptyAsNull

protected boolean interpretEmptyAsNull(Field field)

cast

protected Object cast(Object value,
                      Node node,
                      Field field)

getValue

protected Object getValue(Node node,
                          String fieldName)

getFieldValue

protected Object getFieldValue(Request request,
                               Node node,
                               Field field)
Returns the field value as specified by the client's post.

Parameters:
node - This parameter could be used if the client does not fully specify the field's value (possible e.g. with Date fields). The existing specification could be used then.

getEvaluatedFieldValue

protected Object getEvaluatedFieldValue(Request request,
                                        Node node,
                                        Field field)
Returns the field value to be used in the page.

Parameters:
request - The request, Request.isPost() is used to determin whether the value is given by the user, otherwise the value of the node is used, or if that is null the default value of the field.
node - A node or null
field - The field, never null.

getSearchFieldValue

protected Object getSearchFieldValue(Request request,
                                     Field field)

getFieldValue

protected Object getFieldValue(Request request,
                               Node node,
                               Field field,
                               boolean form)
Parameters:
request -
node - or null
field -
form - If false then this value is to be used for search inputs. The node and the default values are not used

getOperator

protected int getOperator(Field field)
The operator to be used by search(request, field, query)


getSearchValue

protected String getSearchValue(String string,
                                Field field,
                                int operator)
Converts the value to the actual value to be searched. (mainly targeted at StringHandler).


findString

protected final String findString(Request request,
                                  Field field)

search

public Constraint search(Request request,
                         Field field,
                         Query query)
Description copied from interface: Handler
Uses the user's input to create a constraint for the given query

Specified by:
search in interface Handler<C>

setValue

protected void setValue(Request request,
                        Node node,
                        String fieldName,
                        Object value)

check

public abstract C check(Request request,
                        Node node,
                        Field field,
                        boolean errors)
Description copied from interface: Handler
Checks the user input, and invalidates the request, if this user input was invalid.

Specified by:
check in interface Handler<C>
errors - If true then report the errors, otherwise the return value can remain empty.

set

public boolean set(Request request,
                   Node node,
                   Field field)
Description copied from interface: Handler
Sets the user's input into the field of the node

Specified by:
set in interface Handler<C>

input

public abstract C input(Request request,
                        Node node,
                        Field field,
                        boolean search)
Description copied from interface: Handler
Produces an form input field for the given Node, and Field.

Specified by:
input in interface Handler<C>
search - if true, then a search field is produced.


MMBase2 Bridge 2.0-SNAPSHOT - 2013-03-30T06:34