org.outerj.xreporter.datatype
Interface DataType

All Superinterfaces:
org.apache.avalon.framework.configuration.Configurable
All Known Implementing Classes:
DataTypeImpl

public interface DataType
extends org.apache.avalon.framework.configuration.Configurable

A data type is a definition of a domain-specific type based on one of a few built-in types (such as string, long, date, ...) and can be augmented with metadata (prompt, title, default value, ...), validation rules and formatting patterns.


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.
 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 getTitle(ResourceHandle resourceHandle)
           
 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 interface org.apache.avalon.framework.configuration.Configurable
configure
 

Method Detail

generateInputInfoSaxFragment

public void generateInputInfoSaxFragment(org.xml.sax.ContentHandler contentHandler,
                                         ExecutionContext executionContext,
                                         ResourceHandle resourceHandle)
                                  throws java.lang.Exception
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 generateOutputInfoSaxFragment(org.xml.sax.ContentHandler, org.outerj.xreporter.resource.ResourceHandle).

Throws:
java.lang.Exception

generateOutputInfoSaxFragment

public void generateOutputInfoSaxFragment(org.xml.sax.ContentHandler contentHandler,
                                          ResourceHandle resourceHandle)
                                   throws org.xml.sax.SAXException
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, generateInputInfoSaxFragment(org.xml.sax.ContentHandler, org.outerj.xreporter.report.definition.ExecutionContext, org.outerj.xreporter.resource.ResourceHandle)

Throws:
org.xml.sax.SAXException

validate

public ValidationResult validate(java.lang.String value,
                                 ExecutionContext executionContext)
Same as validate(value, executionContext, false);


validate

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

format

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

Parameters:
formatCache - optional parameter, can be null. See FormatCache for more info.

formatRaw

public java.lang.String formatRaw(java.lang.Object value)
Formats the value using US Locale rules.


getOperatorById

public Operator getOperatorById(java.lang.String id)
Retrieves the operator with the specified id.


bind

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

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
Gets a value from a ResultSet using the appropriate methods according to the data type.

Throws:
java.sql.SQLException

getTitle

public java.lang.String getTitle(ResourceHandle resourceHandle)

getDefaultValue

public java.lang.String getDefaultValue(ExecutionContext executionContext,
                                        ResourceHandle resourceHandle)
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.


convert

public java.lang.Object convert(java.lang.Object object)
                         throws UnconvertibleException
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.

Throws:
UnconvertibleException

getTypeName

public java.lang.String getTypeName()
Returns a name identifying the underlying built-in type.