org.outerj.xreporter.datatype.type
Class Type

java.lang.Object
  extended byorg.outerj.xreporter.datatype.type.Type
All Implemented Interfaces:
org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable
Direct Known Subclasses:
AbstractDateTimeType, BigDecimalType, LongType, StringType

public abstract class Type
extends java.lang.Object
implements org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.component.Composable

Abstract base class for data types. The difference between this class and DataType/DataTypeImpl is that implementations of this class provide functionality for specific types of data (strings, numbers, dates, ...), while DataType handles the metadata around them (prompt, title, info) and delegates type-specific matters to implementations of Type.


Field Summary
protected  ExpressionManager expressionManager
           
protected  LocaleMap formattingPatterns
          Locale-specific strings that represent patterns used to format (or parse) the data.
protected  java.util.ArrayList validationRules
          List of ValidationRules
 
Constructor Summary
Type()
           
 
Method Summary
protected  void addExpressionValidationRule(org.apache.avalon.framework.configuration.Configuration conf)
           
 void addValidationRule(ValidationRule validationRule)
           
abstract  void bind(java.sql.PreparedStatement statement, int pos, java.lang.Object value)
          Binds a value of this type to a PreparedStatement.
 void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
           
protected  void configureFormattingPatterns(org.apache.avalon.framework.configuration.Configuration configuration)
          This method is a service to implementations of Type that which to use formatting-patterns.
abstract  java.lang.Object convert(java.lang.Object object)
           
abstract  java.lang.Object fetch(java.sql.ResultSet resultSet, java.lang.String fieldName)
          See DataType.fetch
abstract  java.lang.String format(java.lang.Object value, ResourceHandle resourceHandle, FormatCache formatCache)
          See DataType.format
abstract  java.lang.String formatRaw(java.lang.Object value)
          Format a value as simple as possible.
abstract  java.util.List getAllowedOperators()
          Returns a list of Operators supported by this datatype.
abstract  java.lang.String getName()
          Returns a name that identifies this type
abstract  Operator getOperatorById(java.lang.String id)
           
abstract  java.lang.Object parseRawValue(java.lang.String value)
          Parses a value that was serialized using formatRaw(java.lang.Object).
abstract  ValidationResult validate(java.lang.String value, ExecutionContext executionContext)
          See DataType.validate
abstract  ValidationResult validate(java.lang.String value, ExecutionContext executionContext, boolean rawLocale)
           
 java.lang.String validateValue(java.lang.Object value, ExecutionContext executionContext)
          Validates according to the configured validation rules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.avalon.framework.configuration.Configurable
configure
 

Field Detail

formattingPatterns

protected LocaleMap formattingPatterns
Locale-specific strings that represent patterns used to format (or parse) the data. Implementations of Type may or may not use this functionality.


validationRules

protected java.util.ArrayList validationRules
List of ValidationRules


expressionManager

protected ExpressionManager expressionManager
Constructor Detail

Type

public Type()
Method Detail

getAllowedOperators

public abstract java.util.List getAllowedOperators()
Returns a list of Operators supported by this datatype.


validate

public abstract ValidationResult validate(java.lang.String value,
                                          ExecutionContext executionContext)
See DataType.validate


validate

public abstract ValidationResult validate(java.lang.String value,
                                          ExecutionContext executionContext,
                                          boolean rawLocale)

format

public abstract java.lang.String format(java.lang.Object value,
                                        ResourceHandle resourceHandle,
                                        FormatCache formatCache)
See DataType.format


getOperatorById

public abstract Operator getOperatorById(java.lang.String id)

bind

public abstract void bind(java.sql.PreparedStatement statement,
                          int pos,
                          java.lang.Object value)
                   throws java.sql.SQLException
Binds a value of this type to a PreparedStatement.

Throws:
java.sql.SQLException

fetch

public abstract java.lang.Object fetch(java.sql.ResultSet resultSet,
                                       java.lang.String fieldName)
                                throws java.sql.SQLException
See DataType.fetch

Throws:
java.sql.SQLException

configureFormattingPatterns

protected void configureFormattingPatterns(org.apache.avalon.framework.configuration.Configuration configuration)
                                    throws org.apache.avalon.framework.configuration.ConfigurationException
This method is a service to implementations of Type that which to use formatting-patterns.

Throws:
org.apache.avalon.framework.configuration.ConfigurationException

parseRawValue

public abstract java.lang.Object parseRawValue(java.lang.String value)
                                        throws java.text.ParseException
Parses a value that was serialized using formatRaw(java.lang.Object).

Throws:
java.text.ParseException

formatRaw

public abstract java.lang.String formatRaw(java.lang.Object value)
Format a value as simple as possible.


getName

public abstract java.lang.String getName()
Returns a name that identifies this type


convert

public abstract java.lang.Object convert(java.lang.Object object)
                                  throws UnconvertibleException
Throws:
UnconvertibleException

addValidationRule

public void addValidationRule(ValidationRule validationRule)

compose

public void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
             throws org.apache.avalon.framework.component.ComponentException
Specified by:
compose in interface org.apache.avalon.framework.component.Composable
Throws:
org.apache.avalon.framework.component.ComponentException

validateValue

public java.lang.String validateValue(java.lang.Object value,
                                      ExecutionContext executionContext)
Validates according to the configured validation rules. This method is implicitely executed as part of validate(java.lang.String, org.outerj.xreporter.report.definition.ExecutionContext).

Parameters:
value - a value of the correct type (e.g. String, Long, BigDecimal, Date, ...)
Returns:
null if validation succeeded, a (localized) error message otherwise

addExpressionValidationRule

protected void addExpressionValidationRule(org.apache.avalon.framework.configuration.Configuration conf)
                                    throws org.apache.avalon.framework.configuration.ConfigurationException
Throws:
org.apache.avalon.framework.configuration.ConfigurationException