Class com.ibm.db.selector.Selector
java.lang.Object
|
+----com.ibm.db.selector.Selector
- public abstract class Selector
- implements Serializable
- extends Object
This class provides a base implementation for all data selector
beans. Selector beans provide access to a subset of data accessed
via an implementation of the TableModel interface. They provide the
means to change that selected subset, and to coerce data values in
that subset to alternative data types. Data coercion maximizes the
opportunity for connecting a selector bean to other beans.
Typically, a data selector bean would be connected to a data source
that provides data in the form of a TableModel instance.
The selector properties that
define the subset of data of interest may be customised at design
using the facilities of your chosen visual builder, or may be connected
to visual beans of your choice to construct a run time user interface.
Selector beans coerce data via a range of properties, each
named after the data type that they return. If the property data type
does not match the original data type, coercion is attempted. These
properties provide a sort of universal data adapter for
connecting the data source to as many data consumers as possible.
- See Also:
- CellSelector
- RowSelector
- ColumnSelector
- CellRangeSelector
Field Index
- BIGDECIMAL
- Constant representing data type
java.math.BigDecimal
.
- BIGINTEGER
- Constant representing data type
java.math.BigInteger
.
- BOOLEAN
- Constant representing data type
boolean
.
- BYTE
- Constant representing data type
byte
.
- BYTEARRAY
- Constant representing class
byte[]
.
- DATE
- Constant representing class
java.sql.Date
.
- DOUBLE
- Constant representing data type
double
.
- FLOAT
- Constant representing data type
float
.
- INT
- Constant representing data type
int
.
- LONG
- Constant representing data type
long
.
- NATIVE
- Constant used to indicate that the supported data type that most
closely matches the native type of the data source that should be used.
- NO_MAXIMUM
- Constant representing no maximum value.
- NONE
- Constant representing no data type.
- NULL
- Constant representing data type
null
.
- OBJECT
- Constant representing class
Object
.
- SHORT
- Constant representing data type
short
.
- STRING
- Constant representing class
String
.
- TIME
- Constant representing class
java.sql.Time
.
- TIMESTAMP
- Constant representing class
java.sql.Timestamp
.
- VECTOR
- Constant representing class
Vector
.
- VECTOR_ARRAY
- Constant representing class
Vector[]
.
- VECTOR_OF_VECTORS
- Constant representing a vector of vectors.
Method Index
- addPropertyChangeListener(PropertyChangeListener)
- Add the supplied listener to the set of listeners to be
notified when a property change occurs.
- addSelectorListener(SelectorListener)
- Add the specified selector listener to receive selector events
from this selector.
- coerce(Object, Class)
- Return an instance of the supplied target class based on the supplied
source object.
- coerce(Object, Class, boolean)
- Return an instance of the supplied target class based on the supplied
source object and optionally throws an exception if an error occurs.
- deserializeFromByteArray(byte[])
- Return an object that has been deserialized from the supplied
byte[]
, or null
if the byte array
cannot be deserialized.
- getBigDecimal(Object)
- Return the supplied object as a
BigDecimal
.
- getBigInteger(Object)
- Return the supplied object as a
BigInteger
.
- getBoolean(Object)
- Return the supplied object as a
boolean
.
- getByte(Object)
- Return the supplied object as a
byte
.
- getByteArray(Object)
- Return the supplied object as a
byte[]
.
- getColumns()
- Return the number of columns of data that the selector is able to
operate on.
- getDate(Object)
- Return the supplied object as a
java.sql.Date
.
- getDouble(Object)
- Return the supplied object as a
double
.
- getFloat(Object)
- Return the supplied object as a
float
.
- getIndexFromOne()
- Return whether row and column numbers are indexed from one.
- getInt(Object)
- Return the supplied object as an
int
.
- getLong(Object)
- Return the supplied object as a
long
.
- getModel()
- Return the TableModel that is the current data source and target
for this Selector, or
null
is no data source has
been established.
- getNotificationType()
- Return the property for which a
propertyChange
event
will be issued whenever the selector data source or selection
criteria are changed.
- getRows()
- Return the number of rows of data that the selector is able to
operate on.
- getShort(Object)
- Return the supplied object as a
short
.
- getString(Object)
- Return the supplied object as a
String
.
- getTime(Object)
- Return the supplied object as a
java.sql.Time
.
- getTimestamp(Object)
- Return the supplied object as a
java.sql.Timestamp
.
- getVectorContentType()
- Return the data type for data values that will be used to populate
vectors when vector properties are queried.
- removePropertyChangeListener(PropertyChangeListener)
- Remove the supplied listener from the set of listeners to be
notified when a property change occurs.
- removeSelectorListener(SelectorListener)
- Remove the specified selector listener which received selector events
from this selector.
- serializeToByteArray(Serializable)
- Return a
byte[]
containing the serialized data from
the supplied serializable object, or null
if
serialization fails.
- setIndexFromOne(boolean)
- Specify whether row and column numbers are assumed to index
from one.
- setModel(TableModel)
- Specify a new TableModel instance that the selector is to
operate on.
- setNotificationType(int)
- Specify the property for which a
propertyChange
event
will be issued whenever the selector data source or selection
criteria are changed.
- setVectorContentType(int)
- Specify the data type that should be used when populating vectors
in response to a vector property query.
Fields
BIGDECIMAL
public static final int BIGDECIMAL
- Constant representing data type
java.math.BigDecimal
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
BIGINTEGER
public static final int BIGINTEGER
- Constant representing data type
java.math.BigInteger
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
BOOLEAN
public static final int BOOLEAN
- Constant representing data type
boolean
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
BYTE
public static final int BYTE
- Constant representing data type
byte
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
BYTEARRAY
public static final int BYTEARRAY
- Constant representing class
byte[]
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
DATE
public static final int DATE
- Constant representing class
java.sql.Date
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
DOUBLE
public static final int DOUBLE
- Constant representing data type
double
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
FLOAT
public static final int FLOAT
- Constant representing data type
float
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
INT
public static final int INT
- Constant representing data type
int
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
LONG
public static final int LONG
- Constant representing data type
long
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
NATIVE
public static final int NATIVE
- Constant used to indicate that the supported data type that most
closely matches the native type of the data source that should be used.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
NO_MAXIMUM
public static final int NO_MAXIMUM
- Constant representing no maximum value.
Used as an argument to several selector methods.
NONE
public static final int NONE
- Constant representing no data type.
May be used to supress data change notifications.
NULL
public static final int NULL
- Constant representing data type
null
.
OBJECT
public static final int OBJECT
- Constant representing class
Object
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
SHORT
public static final int SHORT
- Constant representing data type
short
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
STRING
public static final int STRING
- Constant representing class
String
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
TIME
public static final int TIME
- Constant representing class
java.sql.Time
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
TIMESTAMP
public static final int TIMESTAMP
- Constant representing class
java.sql.Timestamp
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
VECTOR
public static final int VECTOR
- Constant representing class
Vector
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
VECTOR_ARRAY
public static final int VECTOR_ARRAY
- Constant representing class
Vector[]
.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
VECTOR_OF_VECTORS
public static final int VECTOR_OF_VECTORS
- Constant representing a vector of vectors.
Used as an argument to selector setNotificationType and
setVectorContentType methods.
Methods
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener propertyListener)
- Add the supplied listener to the set of listeners to be
notified when a property change occurs.
- Parameters:
- propertyListener - the listener to be added.
addSelectorListener
public void addSelectorListener(SelectorListener selectorListener)
- Add the specified selector listener to receive selector events
from this selector.
- Parameters:
- selectorlistener - the listener to be added.
- See Also:
- SelectorListener
coerce
public static Object coerce(Object sourceObject,
Class targetClass)
- Return an instance of the supplied target class based on the supplied
source object. If the source object cannot be coerced to the required
class,
null
is returned.
- Parameters:
- sourceObject - the object to be coerced.
- targetClass - the class to which the object is to be coerced.
- Returns:
- Object an object of the required class, or null.
coerce
public static Object coerce(Object sourceObject,
Class targetClass,
boolean throwException)
- Return an instance of the supplied target class based on the supplied
source object and optionally throws an exception if an error occurs. If
the source object cannot be coerced to the required
class,
null
is returned, or a SelectorException is
thrown if throwException
is true .
- Parameters:
- sourceObject - the object to be coerced.
- targetClass - the class to which the object is to be coerced.
- throwException - a boolean flag indicating whether coercion
failure should generate an exception.
- Returns:
- Object an object of the required class, or null.
- Throws: SelectorException
- COERCION
- if data coercion fails and throwException is true.
- See Also:
- COERCION
deserializeFromByteArray
public static Serializable deserializeFromByteArray(byte[] bytes)
- Return an object that has been deserialized from the supplied
byte[]
, or null
if the byte array
cannot be deserialized.
- Parameters:
- bytes - the serialized form of an object.
- Returns:
- Serializable an object instantiated from the supplied serialized
form.
getBigDecimal
public static BigDecimal getBigDecimal(Object value)
- Return the supplied object as a
BigDecimal
.
- Parameters:
- value - the object to be coerced to a BigDecimal.
- Returns:
- a BigDecimal representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a BigDecimal
and is not null.
- See Also:
- COERCION
getBigInteger
public static BigInteger getBigInteger(Object value)
- Return the supplied object as a
BigInteger
.
- Parameters:
- value - the object to be coerced to a BigInteger.
- Returns:
- a BigInteger representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a BigInteger
and is not null.
- See Also:
- COERCION
getBoolean
public static boolean getBoolean(Object value)
- Return the supplied object as a
boolean
.
Returns true
if the supplied value is:
- a
Boolean
of value true
- a
String
of value "true"
- a
Number
of a value other than 0
- a
Character
of numeric value other than 0
Returns false
for any other supplied value of the above
types.
- Parameters:
- value - the object to be coerced to a boolean.
- Returns:
- a boolean representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a boolean.
- See Also:
- COERCION
getByte
public static byte getByte(Object value)
- Return the supplied object as a
byte
.
- Parameters:
- value - the object to be coerced to a byte.
- Returns:
- a byte representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a byte.
- See Also:
- COERCION
getByteArray
public static byte[] getByteArray(Object value)
- Return the supplied object as a
byte[]
.
- Parameters:
- value - the object to be coerced to a byte[].
- Returns:
- a byte[] representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a byte[]
and is not null.
- See Also:
- COERCION
getColumns
public int getColumns()
- Return the number of columns of data that the selector is able to
operate on. This property might be used to control the range
of values for which column number specification is allowed.
- Returns:
- the number of columns in the source TableModel, or
0
if there is no source TableModel.
getDate
public static Date getDate(Object value)
- Return the supplied object as a
java.sql.Date
.
If the supplied object is a Number
number
it is treated as the number of milliseconds since midnight on
January 1st 1970.
String values must be in the JDBC escape date format
yyyy-mm-dd
.
- Parameters:
- value - the object to be coerced to a Date.
- Returns:
- a Date representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a Date
and is not null.
- See Also:
- COERCION
getDouble
public static double getDouble(Object value)
- Return the supplied object as a
double
.
- Parameters:
- value - the object to be coerced to a double.
- Returns:
- a double representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a double.
- See Also:
- COERCION
getFloat
public static float getFloat(Object value)
- Return the supplied object as a
float
.
- Parameters:
- value - the object to be coerced to a float.
- Returns:
- a float representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a float.
- See Also:
- COERCION
getIndexFromOne
public boolean getIndexFromOne()
- Return whether row and column numbers are indexed from one.
- Returns:
- boolean indicating row and column index origin.
true
indicates an index origin of 1
,
false
indicates an index origin of 0
.
- See Also:
- setIndexFromOne
getInt
public static int getInt(Object value)
- Return the supplied object as an
int
.
- Parameters:
- value - the object to be coerced to an int.
- Returns:
- an int representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a int.
- See Also:
- COERCION
getLong
public static long getLong(Object value)
- Return the supplied object as a
long
.
If the supplied value is a java.util.Date
then
the mumber of milliseconds since midnight on January 1st 1970
is returned.
- Parameters:
- value - the object to be coerced to a long.
- Returns:
- a long representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a long.
- See Also:
- COERCION
getModel
public TableModel getModel()
- Return the TableModel that is the current data source and target
for this Selector, or
null
is no data source has
been established.
- Returns:
- TableModel acting as the data source for this Selector.
- See Also:
- setModel
getNotificationType
public int getNotificationType()
- Return the property for which a
propertyChange
event
will be issued whenever the selector data source or selection
criteria are changed.
- Returns:
- int representing the type of data for which a property
change event will be issued.
- See Also:
- setNotificationType
getRows
public int getRows()
- Return the number of rows of data that the selector is able to
operate on. This property might be used to control the range
of values for which row number specification is allowed.
- Returns:
- the number of rows in the source TableModel, or
0
if there is no source TableModel.
getShort
public static short getShort(Object value)
- Return the supplied object as a
short
.
- Parameters:
- value - the object to be coerced to a short.
- Returns:
- a short representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a short.
- See Also:
- COERCION
getString
public static String getString(Object value)
- Return the supplied object as a
String
. If the
supplied object cannot be interpreted as a String
then null
is returned.
- Parameters:
- value - the object to be coerced to a String.
- Returns:
- a String representation of the object.
getTime
public static Time getTime(Object value)
- Return the supplied object as a
java.sql.Time
.
If the supplied object is a Number
number
it is treated as the number of milliseconds since midnight on
January 1st 1970.
String values must be in the JDBC escape time format
hh:mm:ss
.
- Parameters:
- value - the object to be coerced to a Time.
- Returns:
- a Time representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a Time
and is not null.
- See Also:
- COERCION
getTimestamp
public static Timestamp getTimestamp(Object value)
- Return the supplied object as a
java.sql.Timestamp
.
If the supplied object is a Number
number
it is treated as the number of milliseconds since midnight on
January 1st 1970.
String values must be in the JDBC escape timestamp format
yyyy-mm-dd hh:mm:ss.fffffffff
.
- Parameters:
- value - the object to be coerced to a Timestamp.
- Returns:
- a Timestamp representation of the object.
- Throws: SelectorException
- COERCION
- if supplied value cannot be coerced to a Timestamp
and is not null.
- See Also:
- COERCION
getVectorContentType
public int getVectorContentType()
- Return the data type for data values that will be used to populate
vectors when vector properties are queried.
- Returns:
- int representing the type of data that will be used to
populate vectors when vector properties are queried.
- See Also:
- setVectorContentType
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener propertyListener)
- Remove the supplied listener from the set of listeners to be
notified when a property change occurs.
- Parameters:
- propertyListener - the listener to be removed.
removeSelectorListener
public void removeSelectorListener(SelectorListener selectorListener)
- Remove the specified selector listener which received selector events
from this selector.
- Parameters:
- SelectorListener - the listener to be removed.
- See Also:
- SelectorListener
serializeToByteArray
public static byte[] serializeToByteArray(Serializable serializable)
- Return a
byte[]
containing the serialized data from
the supplied serializable object, or null
if
serialization fails.
- Parameters:
- serializable - any serializable object.
- Returns:
- the serialized form of the supplied object.
setIndexFromOne
public void setIndexFromOne(boolean indexFromOne)
- Specify whether row and column numbers are assumed to index
from one. This property should be set to
true
where the selection row and/or column properties are connected
to a bean property that indexes from one. If set to
false
, indexing is from zero.
- Parameters:
- indexFromOne -
true
specifies an index origin of 1
,
false
specifies an index origin of 0
.
setModel
public void setModel(TableModel model)
- Specify a new TableModel instance that the selector is to
operate on. A
dataChanged
event is generated, as
well as a propertyChange
event for the property
matching the current notification type.
- Parameters:
- model - the TableModel to be used as the source and target
for data for this Selector.
- See Also:
- setNotificationType
setNotificationType
public void setNotificationType(int notificationType)
- Specify the property for which a
propertyChange
event
will be issued whenever the selector data source or selection
criteria are changed.
Selectors are able to coerce source data
into a variety of data types, each of which has a corresponding
bound property. All of these properties are theoretically altered
when the selector data source or selection criteria are changed.
However, it would be very inefficient to generate property change
events for all these properties, so the property of interest may
be specified, limiting property change events to a single
property. By default, no property change events are generated.
- Parameters:
- notificationType - int representing the notification type. It may have one of the
following values:
- See Also:
setVectorContentType
public void setVectorContentType(int vectorContentType)
- Specify the data type that should be used when populating vectors
in response to a vector property query.
Some beans may require data
to be fed to them in a vector, and may further expect the elements
in the vector to be of a specific type. Where this is the case
the notificationType
property may be set to
Selector.VECTOR
to cause propertyChange
events to be generated for the vector
property.
- Parameters:
- vectorContentType - int representing the vector content type. It may have one of the
following values:
- See Also:
- setNotificationType
