com.iplanet.jato.model.sql
Class QueryFieldDescriptor

java.lang.Object
  |
  +--com.iplanet.jato.model.sql.QueryFieldDescriptor
All Implemented Interfaces:
java.io.Serializable

public class QueryFieldDescriptor
extends java.lang.Object
implements java.io.Serializable

Encapsulates the metadata needed to describe a QueryModel logical field.

The QueryModelBase implementation relies on a collection of QueryFieldDescriptors to supply the metadata that is used to dynamically construct and execute the SQL query. To this end, the descriptor contains metadata which describes the physical table column, such as the column name and whether it is a primary key. The descriptor also contains metadata that specifies rules for what the QueryModelBase should do in the even that no value is present for the field at the time of query execution.

Additionally, QueryModelBase relies on the descriptor to provide the logical model field name and type. It is the logical field, not the column name, that the model interface exposes via the Model.getValue(String) and setValue(String, Object) operations, amongst others. This allows application developers to access the model's logical fields in an object oriented fashion. Internally, QueryModelBase will map the logical field to the physical column as needed.

Note, the name of the logical model field may be, but need not be identical with the column name.

Version:
JATO/1.2.2 $Id: QueryFieldDescriptor.java,v 1.14 2002/03/16 03:26:32 todd Exp $
See Also:
QueryFieldSchema, QueryModel, QueryModelBase, Serialized Form

Field Summary
static int APPLICATION_INSERT_VALUE_SOURCE
          The application provides the inserted value (default)
static int DATABASE_INSERT_VALUE_SOURCE
          The database provides the inserted value (no value is sent)
static int FORMULA_INSERT_VALUE_SOURCE
          The insertFormula property is is the inserted value
static int ON_EMPTY_VALUE_EXCLUDE
          If no value is provided, don't supply a value (default)
static int ON_EMPTY_VALUE_SEND_NULL
          If no value is provided, send NULL to the database
static int ON_EMPTY_VALUE_USE_FORMULA
          If no value is provided, emptyFormula is the provided value
static int QUERY_TYPE_DELETE
          field capable of participation in delete queries
static int QUERY_TYPE_INSERT
          field capable of participation in insert queries
static int QUERY_TYPE_NONE
          field not capable of participation in any queries
static int QUERY_TYPE_SELECT
          field capable of participation in select queries
static int QUERY_TYPE_UPDATE
          field capable of participation in update queries
 
Constructor Summary
QueryFieldDescriptor()
          Default constructor.
QueryFieldDescriptor(java.lang.String logicalName, java.lang.String columnName, java.lang.String qualifiedColumnName, java.lang.Class fieldClass)
          Minimal recommended constructor.
QueryFieldDescriptor(java.lang.String logicalName, java.lang.String columnName, java.lang.String qualifiedColumnName, java.lang.Class fieldClass, boolean isKey)
          Optional constructor allows the key property to be assigned.
QueryFieldDescriptor(java.lang.String logicalName, java.lang.String columnName, java.lang.String qualifiedColumnName, java.lang.Class fieldClass, boolean isKey, boolean isComputedField, int insertValueSource, java.lang.String insertFormula, int onEmptyValuePolicy, java.lang.String emptyFormula)
          Full constructor which allows additional properties to be assigned including parameters associated with computed fields, insert behavior and empty value considerations.
QueryFieldDescriptor(java.lang.String logicalName, java.lang.String columnName, java.lang.String qualifiedColumnName, java.lang.Class fieldClass, boolean isKey, boolean isComputedField, int insertValueSource, java.lang.String insertFormula, int onEmptyValuePolicy, java.lang.String emptyFormula, int queryTypeMask)
          Complete constructor allows the queryTypeMask property to be assigned.
 
Method Summary
 void enableQueryType(int value)
          adds a supported query type to the mask
 java.lang.String getColumnName()
          Short name of the relational database table/view column.
 java.lang.String getEmptyFormula()
          Expression which replaced empty value when ON_EMPTY_VALUE_USE_FORMULA
 java.lang.String getEmptyValue()
           
 java.lang.Class getFieldClass()
          Java type, usually a JDBC SQL type, which assignable from the JDBC results.
 java.lang.String getInsertFormula()
          SQL expression to be used by inserting query when FORMULA_INSERT_VALUE_SOURCE
 int getInsertValueSource()
          Describes where a value for this field comes from when participating in an inserting query.
 java.lang.String getName()
          The arbitrary logical name of this field.
 int getOnEmptyValuePolicy()
          Describes how a query should behave when faced with an empty value for this field.
 java.lang.String getQualifiedColumnName()
          Fully qualified name of the relational database table/view column which may be RDBMS implementation dependent but generally includes schema name uses '.' for a delimiter.
 int getQueryTypeMask()
          Bit mask indicating type of queries which this field can participate in.
 boolean isComputedField()
          Indicates whether this field represents an arbitary SQL expression as opposed to a mapping of a relational database table/view column.
 boolean isKey()
          Indicator of whether this field represents a relational database table/view column which is a key or part of a compound key.
 boolean isQueryTypeEnabled(int value)
          checks the support for a query type
 void setColumnName(java.lang.String value)
          Returns the short name of the relational database table/view column.
 void setComputedField(boolean value)
           
 void setEmptyFormula(java.lang.String value)
           
 void setEmptyValue(java.lang.String value)
           
 void setFieldClass(java.lang.Class value)
           
 void setInsertFormula(java.lang.String value)
           
 void setInsertValueSource(int value)
           
 void setKey(boolean value)
           
 void setName(java.lang.String value)
           
 void setOnEmptyValuePolicy(int value)
           
 void setQualifiedColumnName(java.lang.String value)
           
 void setQueryTypeMask(int value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPLICATION_INSERT_VALUE_SOURCE

public static final int APPLICATION_INSERT_VALUE_SOURCE
The application provides the inserted value (default)

DATABASE_INSERT_VALUE_SOURCE

public static final int DATABASE_INSERT_VALUE_SOURCE
The database provides the inserted value (no value is sent)

FORMULA_INSERT_VALUE_SOURCE

public static final int FORMULA_INSERT_VALUE_SOURCE
The insertFormula property is is the inserted value

ON_EMPTY_VALUE_EXCLUDE

public static final int ON_EMPTY_VALUE_EXCLUDE
If no value is provided, don't supply a value (default)

ON_EMPTY_VALUE_SEND_NULL

public static final int ON_EMPTY_VALUE_SEND_NULL
If no value is provided, send NULL to the database

ON_EMPTY_VALUE_USE_FORMULA

public static final int ON_EMPTY_VALUE_USE_FORMULA
If no value is provided, emptyFormula is the provided value

QUERY_TYPE_NONE

public static final int QUERY_TYPE_NONE
field not capable of participation in any queries

QUERY_TYPE_SELECT

public static final int QUERY_TYPE_SELECT
field capable of participation in select queries

QUERY_TYPE_INSERT

public static final int QUERY_TYPE_INSERT
field capable of participation in insert queries

QUERY_TYPE_UPDATE

public static final int QUERY_TYPE_UPDATE
field capable of participation in update queries

QUERY_TYPE_DELETE

public static final int QUERY_TYPE_DELETE
field capable of participation in delete queries
Constructor Detail

QueryFieldDescriptor

public QueryFieldDescriptor()
Default constructor. An object created with this constructor must be customized in order to be valid, therefore we do not generally recommend use of this constructor.

QueryFieldDescriptor

public QueryFieldDescriptor(java.lang.String logicalName,
                            java.lang.String columnName,
                            java.lang.String qualifiedColumnName,
                            java.lang.Class fieldClass)
Minimal recommended constructor. This constructor provides the minimal information necessary for this object to be valid. The remaining property values are set to the following defaults:

	key = false
	isComputedField = false
	insertValueSource = APPLICATION_INSERT_VALUE_SOURCE
	insertFormula = null
	onEmptyValuePolicy = ON_EMPTY_VALUE_EXCLUDE
	emptyFormula = null
	queryTypeMask =
		QUERY_TYPE_SELECT |
		QUERY_TYPE_INSERT |
		QUERY_TYPE_UPDATE |
		QUERY_TYPE_DELETE
 
Parameters:
logicalName - identifier of this metadata entity, not to be confused with the actual RDBMS column name
columnName - short name of the relational database table/view column
qualifiedColumnName - fully scoped column name
fieldClass - assigns a Java type to this relational entity
See Also:
Optional Constructor

QueryFieldDescriptor

public QueryFieldDescriptor(java.lang.String logicalName,
                            java.lang.String columnName,
                            java.lang.String qualifiedColumnName,
                            java.lang.Class fieldClass,
                            boolean isKey)
Optional constructor allows the key property to be assigned. The remaining property values are set to the following defaults:
Parameters:
isKey - indicates whether this relation entity is a key or is part of a key
See Also:
Common constructor parameters, Full Constructor

QueryFieldDescriptor

public QueryFieldDescriptor(java.lang.String logicalName,
                            java.lang.String columnName,
                            java.lang.String qualifiedColumnName,
                            java.lang.Class fieldClass,
                            boolean isKey,
                            boolean isComputedField,
                            int insertValueSource,
                            java.lang.String insertFormula,
                            int onEmptyValuePolicy,
                            java.lang.String emptyFormula)
Full constructor which allows additional properties to be assigned including parameters associated with computed fields, insert behavior and empty value considerations.
Parameters:
isKey - indicates relational entity is a key or is part of a compound key
isComputedField - indicates field is an SQL expression not necessarily related to table/view columns
insertValueSource - (see property accessor)
insertFormula - SQL expression used when insertValueSource = FORMULA_INSERT_VALUE_SOURCE
onEmptyValuePolicy - (see property accessor)
emptyFormula - expression used when onEmptyValuePolicy = ON_EMPTY_VALUE_USE_FORMULA
See Also:
Common constructor parameters, Complete Constructor

QueryFieldDescriptor

public QueryFieldDescriptor(java.lang.String logicalName,
                            java.lang.String columnName,
                            java.lang.String qualifiedColumnName,
                            java.lang.Class fieldClass,
                            boolean isKey,
                            boolean isComputedField,
                            int insertValueSource,
                            java.lang.String insertFormula,
                            int onEmptyValuePolicy,
                            java.lang.String emptyFormula,
                            int queryTypeMask)
Complete constructor allows the queryTypeMask property to be assigned.
Parameters:
queryTypeMask - indicates types of queries which this field may particpate in (see property accessor)
See Also:
Common constructor parameters, Full Constructor
Method Detail

getName

public java.lang.String getName()
The arbitrary logical name of this field. This is the name of the field that the model will use for various operations (which it will internally map to the column name).

setName

public void setName(java.lang.String value)

getColumnName

public java.lang.String getColumnName()
Short name of the relational database table/view column.

setColumnName

public void setColumnName(java.lang.String value)
Returns the short name of the relational database table/view column.

getQualifiedColumnName

public java.lang.String getQualifiedColumnName()
Fully qualified name of the relational database table/view column which may be RDBMS implementation dependent but generally includes schema name uses '.' for a delimiter.

setQualifiedColumnName

public void setQualifiedColumnName(java.lang.String value)

getFieldClass

public java.lang.Class getFieldClass()
Java type, usually a JDBC SQL type, which assignable from the JDBC results.

setFieldClass

public void setFieldClass(java.lang.Class value)

isKey

public boolean isKey()
Indicator of whether this field represents a relational database table/view column which is a key or part of a compound key.

setKey

public void setKey(boolean value)

isComputedField

public boolean isComputedField()
Indicates whether this field represents an arbitary SQL expression as opposed to a mapping of a relational database table/view column.

setComputedField

public void setComputedField(boolean value)

getInsertValueSource

public int getInsertValueSource()
Describes where a value for this field comes from when participating in an inserting query.

setInsertValueSource

public void setInsertValueSource(int value)
Parameters:
value - one of the following constants:
		APPLICATION_INSERT_VALUE_SOURCE
		DATABASE_INSERT_VALUE_SOURCE
		FORMULA_INSERT_VALUE_SOURCE
 

getOnEmptyValuePolicy

public int getOnEmptyValuePolicy()
Describes how a query should behave when faced with an empty value for this field.

setOnEmptyValuePolicy

public void setOnEmptyValuePolicy(int value)
Parameters:
value - one of the following constants:
		ON_EMPTY_VALUE_EXCLUDE
		ON_EMPTY_VALUE_SEND_NULL
		ON_EMPTY_VALUE_USE_FORMULA
 

getEmptyFormula

public java.lang.String getEmptyFormula()
Expression which replaced empty value when ON_EMPTY_VALUE_USE_FORMULA

setEmptyFormula

public void setEmptyFormula(java.lang.String value)
Parameters:
value - valid expression properly formed for this fields type.

getInsertFormula

public java.lang.String getInsertFormula()
SQL expression to be used by inserting query when FORMULA_INSERT_VALUE_SOURCE

setInsertFormula

public void setInsertFormula(java.lang.String value)
Parameters:
value - valid SQL expression properly formed for this field's type

getEmptyValue

public java.lang.String getEmptyValue()
See Also:
getEmptyFormula()

setEmptyValue

public void setEmptyValue(java.lang.String value)
See Also:
setEmptyFormula(String)

getQueryTypeMask

public int getQueryTypeMask()
Bit mask indicating type of queries which this field can participate in.

setQueryTypeMask

public void setQueryTypeMask(int value)
Parameters:
value - set to QUERY_TYPE_NONE or a combination of any of the following constants:
		QUERY_TYPE_SELECT
		QUERY_TYPE_INSERT
		QUERY_TYPE_UPDATE
		QUERY_TYPE_DELETE
 

enableQueryType

public void enableQueryType(int value)
adds a supported query type to the mask

isQueryTypeEnabled

public boolean isQueryTypeEnabled(int value)
checks the support for a query type