|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.storage.jdbc.JDBCToListModelAdapter
public class JDBCToListModelAdapter
The JDBCToListModelAdapter allows JDBC data sources to be
displayed in any viewer that requires a model of type
javax.swing.ListModel
, mainly being a javax.swing.JList
.
The adapter requires a java.sql.Connection
object and a query statement.
They can be passed in on the constructor or set via methods.
The setConnection()
method will apply the connection object. The
setQueryStatement()
method will apply the SQL query statement. When
non-null values for both connection and query statement have been
applied, the adapter is initialized and ready to use.
The query statement must be a SQL query that is valid for the JDBC data source. This may include a blank statement, if valid.
The setTemplateText method can be used to control which column values from the result set are displayed in the list. Multiple column values can be used along with text. The template text uses the default marker, open, and close characters from com.sas.util.SimpleTemplate( "%", "(", and ")" ). The column names must be defined in the template text as all uppercase variables. If no template text is defined, only the values from the first column of the result set are used as list items.
The general form of the template text is:
text %COL1 more text %COL2Where COL1 and COL2 are fully uppercased column names. The '%' acts as a delimiter and is not part of the column name.If more control is desired on what is displayed in the List, then a column values transform can be set on the adapter, via the
setColumnValuesTransform
method. TheretrieveAllColumnValues
property must be set to true in order for the column values transform to be used. If a column values transform has been specified and theretrieveAllColumnValues
is true, then the adapter will use the specified column values transform to transform the Map containing column names (all uppercased) mapped to column values into a single Object which is returned by thegetElementAt
method. If theretrieveAllColumnValues
property is true, but no column values transform has been set, then the Object returned from thegetElementAt
method will be a Map containing the column names (all uppercased) mapped to the column values.The adapter can be configured and used within a webAF project. Add a
com.sas.storage.jdbc.JDBCConnection
component to your project. Open the customizer and specify the values needed for your JDBC connection.These include driver name and URL. Now open the customizer for the adapter. Specify the value for JDBC Connection using the top combo box. The drop-down list will show all JDBC Connection objects that exist in your project. You can set the properties for query statement, autoCommit, and read-only, as well.
Field Summary | |
---|---|
protected javax.swing.event.EventListenerList |
listenerList
List of listeners |
protected com.sas.util.transforms.MapToTemplateStringTransform |
mapTransform
Transform used templateText is specified |
static java.lang.String |
RB_KEY
|
protected java.lang.String |
templateText
Template text for output string |
Fields inherited from class com.sas.storage.jdbc.JDBCColumnValuesAdapter |
---|
columnValuesTransform, retrieveAllColumnValues |
Fields inherited from class com.sas.storage.jdbc.JDBCAdapter |
---|
autoCommit, CLASS_NAME, columnInfoUsed, conn, designTime, displayTransform, forwardOnly, initialized, isRowCountKnown, LABEL, meta, NAME, printWarnings, queryRowCountDisabled, queryStatement, readOnly, result, resultSetRequeryUsed, resultSetType, resultSetUsed, retrieveNumericTypesAsDouble, rowCount, rowCountQueryString, rowNumber, spcs, stmt, trimUsed |
Constructor Summary | |
---|---|
JDBCToListModelAdapter()
Default constructor called when the adapter is made in a webAF project. |
|
JDBCToListModelAdapter(java.sql.Connection conn,
java.lang.String queryStatement)
Constructor used to create an initialized adapter. |
|
JDBCToListModelAdapter(java.sql.ResultSet result)
Constructor used to connect an adapter directly to a previously created ResultSet. |
Method Summary | |
---|---|
void |
addListDataListener(javax.swing.event.ListDataListener l)
Add a listener to the list that's notified each time a change to the data model occurs. |
void |
fireCellEvent(int row,
int column)
Fire a specific event for a model signaling that one cell has changed. |
void |
fireModelEvent()
Fire a default event for a model signaling the some aspect of the model has changed. |
void |
fireModelEvent(java.util.EventObject event)
Fire a specific event for a model signaling that some aspect of the model has changed. |
java.lang.Object |
getElementAt(int index)
Returns the value at the specified index. |
java.util.Map |
getElementsAt(int index)
Returns a Map containing the column names (all uppercased) mapped to the column values at the specified index in the result set. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this JDBCToListModelAdapter. |
int |
getSize()
Returns the length of the list |
java.lang.String |
getTemplateText()
Returns the text of the template. |
protected void |
initializeData()
|
void |
removeListDataListener(javax.swing.event.ListDataListener l)
Remove a listener from the list that's notified each time a change to the data model occurs. |
void |
setTemplateText(java.lang.String templateText)
Sets the text to be used for the template, determining what values display in the list. |
Methods inherited from class com.sas.storage.jdbc.JDBCColumnValuesAdapter |
---|
getColumnValuesMap, getColumnValuesTransform, isRetrieveAllColumnValues, retrieveColumnValueAt, retrieveValueAt, setColumnValuesTransform, setRetrieveAllColumnValues |
Field Detail |
---|
public static final java.lang.String RB_KEY
protected javax.swing.event.EventListenerList listenerList
protected java.lang.String templateText
protected com.sas.util.transforms.MapToTemplateStringTransform mapTransform
Constructor Detail |
---|
public JDBCToListModelAdapter()
public JDBCToListModelAdapter(java.sql.ResultSet result)
result
- ResultSet to use.public JDBCToListModelAdapter(java.sql.Connection conn, java.lang.String queryStatement)
conn
- A java.sql.Connection
object.queryStatement
- A SQL query that is valid for the database
represented by conn
.Method Detail |
---|
protected void initializeData()
initializeData
in class JDBCAdapter
public void addListDataListener(javax.swing.event.ListDataListener l)
addListDataListener
in interface javax.swing.ListModel
l
- The ListDataListenerpublic void removeListDataListener(javax.swing.event.ListDataListener l)
removeListDataListener
in interface javax.swing.ListModel
l
- The ListDataListenerpublic int getSize()
getSize
in interface javax.swing.ListModel
public java.lang.Object getElementAt(int index)
getElementAt
in interface javax.swing.ListModel
index
- the index to return the value ofpublic java.util.Map getElementsAt(int index) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String getTemplateText()
public void setTemplateText(java.lang.String templateText)
templateText
- text to be set for the templateSimpleTemplate
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public void fireCellEvent(int row, int column)
fireCellEvent
in class JDBCAdapter
row
- row number of the cell that has been modifiedcolumn
- column number of the cell that has been modifiedpublic void fireModelEvent(java.util.EventObject event)
fireModelEvent
in class JDBCAdapter
event
- Event that must be cast that should be firedpublic void fireModelEvent()
fireModelEvent
in class JDBCAdapter
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |