org.outerj.xreporter.datatype
Class DataTypeImpl

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.outerj.xreporter.datatype.DataTypeImpl
All Implemented Interfaces:
org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, DataType, org.apache.avalon.framework.logger.LogEnabled

public class DataTypeImpl
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements DataType, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.component.Composable

Implementation of DataType. This class should not be instantiated immediately, use the DataTypeManagerImpl to retrieve and create object of this class. Functionality specific to a certain base type (string, long, date, ...) is delegated to an implementation of Type.


Field Summary
protected static java.lang.String ARGCOUNT_ATTR
           
protected static java.lang.String BASE_ATTR
           
protected  org.apache.avalon.framework.component.ComponentManager componentManager
           
protected static java.lang.String DATATYPE_EL
           
protected static java.lang.String DESCRIPTION_ATTR
           
protected  Expression expressionForDefault
           
protected  java.lang.String id
           
protected static java.lang.String ID_ATTR
           
protected  java.lang.String info
           
protected static java.lang.String OPERATOR_EL
           
protected static java.lang.String OPERATORS_EL
           
protected  DataTypeImpl parentDataType
           
protected  java.lang.String prompt
           
protected static java.lang.String PROMPT_EL
           
protected  SearchlistDefinition searchlist
           
protected  java.lang.String title
           
protected static java.lang.String TITLE_EL
           
protected static java.lang.String TYPE_EL
           
protected  Type typeDelegate
           
 
Constructor Summary
protected DataTypeImpl()
           
protected DataTypeImpl(DataTypeImpl parentDataType)
           
 
Method Summary
 void bind(java.sql.PreparedStatement statement, int pos, java.lang.Object value)
          Bind a value of this type to a JDBC PreparedStatement at the given position.
 void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
           
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
 java.lang.Object convert(java.lang.Object object)
          Checks that the given object is of the kind that this Type expects.
 java.lang.Object fetch(java.sql.ResultSet resultSet, java.lang.String fieldName)
          Gets a value from a ResultSet using the appropriate methods according to the data type.
 java.lang.String format(java.lang.Object value, ResourceHandle resourceHandle, FormatCache formatCache)
          Creates a string representation of the value, based on the locale.
 java.lang.String formatRaw(java.lang.Object value)
          Formats the value using US Locale rules.
 void generateInputInfoSaxFragment(org.xml.sax.ContentHandler contentHandler, ExecutionContext executionContext, ResourceHandle resourceHandle)
          Generates a piece of SAX representing this data type.
 void generateOutputInfoSaxFragment(org.xml.sax.ContentHandler contentHandler, ResourceHandle resourceHandle)
          Generates a piece of SAX containing certain information about the datatype.
 java.lang.String getDefaultValue(ExecutionContext executionContext, ResourceHandle resourceHandle)
          Determines the default value for this data type.
 Operator getOperatorById(java.lang.String id)
          Retrieves the operator with the specified id.
 java.lang.String getPrompt(Resources dataTypeUserBundle)
           
protected  SearchlistDefinition getSearchListDefinition()
           
 java.lang.String getTitle(ResourceHandle resourceHandle)
           
protected  java.lang.String getTitle(Resources dataTypeUserBundle)
           
 java.lang.String getTypeName()
          Returns a name identifying the underlying built-in type.
 ValidationResult validate(java.lang.String value, ExecutionContext executionContext)
          Same as validate(value, executionContext, false);
 ValidationResult validate(java.lang.String value, ExecutionContext executionContext, boolean rawLocale)
          Validates the given value.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected java.lang.String id

prompt

protected java.lang.String prompt

title

protected java.lang.String title

info

protected java.lang.String info

expressionForDefault

protected Expression expressionForDefault

typeDelegate

protected Type typeDelegate

parentDataType

protected DataTypeImpl parentDataType

searchlist

protected SearchlistDefinition searchlist

componentManager

protected org.apache.avalon.framework.component.ComponentManager componentManager

DATATYPE_EL

protected static final java.lang.String DATATYPE_EL
See Also:
Constant Field Values

PROMPT_EL

protected static final java.lang.String PROMPT_EL
See Also:
Constant Field Values

TITLE_EL

protected static final java.lang.String TITLE_EL
See Also:
Constant Field Values

OPERATORS_EL

protected static final java.lang.String OPERATORS_EL
See Also:
Constant Field Values

OPERATOR_EL

protected static final java.lang.String OPERATOR_EL
See Also:
Constant Field Values

ID_ATTR

protected static final java.lang.String ID_ATTR
See Also:
Constant Field Values

DESCRIPTION_ATTR

protected static final java.lang.String DESCRIPTION_ATTR
See Also:
Constant Field Values

ARGCOUNT_ATTR

protected static final java.lang.String ARGCOUNT_ATTR
See Also:
Constant Field Values

TYPE_EL

protected static final java.lang.String TYPE_EL
See Also:
Constant Field Values

BASE_ATTR

protected static final java.lang.String BASE_ATTR
See Also:
Constant Field Values
Constructor Detail

DataTypeImpl

protected DataTypeImpl()

DataTypeImpl

protected DataTypeImpl(DataTypeImpl parentDataType)
Parameters:
parentDataType - can be null
Method Detail

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

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

validate

public ValidationResult validate(java.lang.String value,
                                 ExecutionContext executionContext)
Description copied from interface: DataType
Same as validate(value, executionContext, false);

Specified by:
validate in interface DataType

validate

public ValidationResult validate(java.lang.String value,
                                 ExecutionContext executionContext,
                                 boolean rawLocale)
Description copied from interface: DataType
Validates the given value. Validation is a two-step process:

getTitle

public java.lang.String getTitle(ResourceHandle resourceHandle)
Specified by:
getTitle in interface DataType

getTitle

protected java.lang.String getTitle(Resources dataTypeUserBundle)

getPrompt

public java.lang.String getPrompt(Resources dataTypeUserBundle)

generateInputInfoSaxFragment

public void generateInputInfoSaxFragment(org.xml.sax.ContentHandler contentHandler,
                                         ExecutionContext executionContext,
                                         ResourceHandle resourceHandle)
                                  throws java.lang.Exception
Description copied from interface: DataType
Generates a piece of SAX representing this data type. The SAX-events startDocument and endDocument will not be called.

The generated output will contain everything about the datatype, includes selection lists etc, thus everything needed for inputing values of this datatype. If you only need some output metadata, use DataType.generateOutputInfoSaxFragment(org.xml.sax.ContentHandler, org.outerj.xreporter.resource.ResourceHandle).

Specified by:
generateInputInfoSaxFragment in interface DataType
Throws:
java.lang.Exception

getSearchListDefinition

protected SearchlistDefinition getSearchListDefinition()

getDefaultValue

public java.lang.String getDefaultValue(ExecutionContext executionContext,
                                        ResourceHandle resourceHandle)
Description copied from interface: DataType
Determines the default value for this data type. This value could be calculated using information from the context in which it is used (a certain report), therefore an ExecutionContext should be provided.

Specified by:
getDefaultValue in interface DataType

generateOutputInfoSaxFragment

public void generateOutputInfoSaxFragment(org.xml.sax.ContentHandler contentHandler,
                                          ResourceHandle resourceHandle)
                                   throws org.xml.sax.SAXException
Description copied from interface: DataType
Generates a piece of SAX containing certain information about the datatype. It will only contain the information typically needed for displaying output, such as columns titles, but not things like selection lists. This method does less then, and is thus faster then, DataType.generateInputInfoSaxFragment(org.xml.sax.ContentHandler, org.outerj.xreporter.report.definition.ExecutionContext, org.outerj.xreporter.resource.ResourceHandle)

Specified by:
generateOutputInfoSaxFragment in interface DataType
Throws:
org.xml.sax.SAXException

getOperatorById

public Operator getOperatorById(java.lang.String id)
Description copied from interface: DataType
Retrieves the operator with the specified id.

Specified by:
getOperatorById in interface DataType

format

public java.lang.String format(java.lang.Object value,
                               ResourceHandle resourceHandle,
                               FormatCache formatCache)
Description copied from interface: DataType
Creates a string representation of the value, based on the locale.

Specified by:
format in interface DataType
Parameters:
formatCache - optional parameter, can be null. See FormatCache for more info.

formatRaw

public java.lang.String formatRaw(java.lang.Object value)
Description copied from interface: DataType
Formats the value using US Locale rules.

Specified by:
formatRaw in interface DataType

bind

public void bind(java.sql.PreparedStatement statement,
                 int pos,
                 java.lang.Object value)
          throws java.sql.SQLException
Description copied from interface: DataType
Bind a value of this type to a JDBC PreparedStatement at the given position.

Specified by:
bind in interface DataType
Parameters:
value - an object of the correct type, depending on the base type of this data type.
Throws:
java.sql.SQLException

fetch

public java.lang.Object fetch(java.sql.ResultSet resultSet,
                              java.lang.String fieldName)
                       throws java.sql.SQLException
Description copied from interface: DataType
Gets a value from a ResultSet using the appropriate methods according to the data type.

Specified by:
fetch in interface DataType
Throws:
java.sql.SQLException

convert

public java.lang.Object convert(java.lang.Object object)
                         throws UnconvertibleException
Description copied from interface: DataType
Checks that the given object is of the kind that this Type expects. If not, it tries to convert it if possible, and otherwise throws an exception.

Specified by:
convert in interface DataType
Throws:
UnconvertibleException

getTypeName

public java.lang.String getTypeName()
Description copied from interface: DataType
Returns a name identifying the underlying built-in type.

Specified by:
getTypeName in interface DataType