|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.jhu.tmaj.beans.JBean
public abstract class JBean
Represents a database table that can be converted into a Swing JTable and edited. A JBean class represents a database table. An instance of a JBean represents one row in that table. Classes InputPanel3 and TableData4 allow a database table to be editted as a JTable. This class, the JBean class, fills in the information about the particular table. This class provides functionality that turns a database row into a Bean, as well as the reverse. In addition this class provides functionality that turns a JTable row into this bean, as well as the reverse. To Summarize: Database <--> Bean <--> Swing-Interface As you can see, data is read from the database, put into this JBean, and then put into a row in a JTable. When the user makes a change, data goes from a row in the JTable, into this JBean, and finally is written back to the database. Note: The JBean, InputPanel, and TableData classes are the most complicated classes in TMAJ.
Field Summary | |
---|---|
protected StaticMetaData |
staticMetaData
|
Constructor Summary | |
---|---|
protected |
JBean(StaticMetaData staticMetaData)
Constructs a JBean. |
Method Summary | |
---|---|
int |
compareTo(java.lang.Object o)
Compares this Bean to another Bean by doing a case-insensitive compare using toString() |
void |
createFromResultSet(java.sql.ResultSet rs,
java.util.Set<java.lang.String> columnNames)
Creates this Bean from a row in the database. |
void |
createFromSwingMap(java.util.Map<DatabaseField,java.lang.Object> columnField_value)
Creates this Bean from a row in a swing JTable. |
void |
delete()
Deletes this Bean from the database. |
boolean |
equals(java.lang.Object obj)
Returns true if this bean is equal to obj, that is, if the bean's classes and ids are the same. |
java.util.List<DatabaseField> |
getAllStaticColumnIdentifiers()
Returns a List of all regular columnIdentifiers for this Bean. |
protected java.lang.String |
getBaseSQL(Search search)
Returns the SQL for a Search without the WHERE Clause. |
protected JBean |
getBeanInDatabase()
|
protected java.util.List<JBean> |
getBeanList(Search search)
Returns a List of Beans from a Search. |
java.util.List<JBean> |
getBeanList(java.lang.String sql)
Returns a List of Beans from a SQL statement. |
(package private) boolean |
getBooleanField(DatabaseField field)
Gets the boolean value of a field whose type is TFieldType.BOOLEAN |
static java.lang.Class |
getClassForType(DatabaseFieldType tFieldType)
|
protected java.util.List<DatabaseField> |
getColumnIdentifiers(Search search,
java.util.List<JBean> beanList)
Returns a List of ColumnIdentifiers based on a Search and the list of Beans generated. |
(package private) static java.util.Set<java.lang.String> |
getColumnNamesSet(java.sql.ResultSet rs)
Returns a Set of lowercase column names contained in the ResultSet |
protected java.util.Date |
getDateField(DatabaseField field)
Gets a Date value of a field who type is TField.DATE |
static java.lang.Object |
getDefaultBeanObjectForType(DatabaseFieldType tFieldType)
|
static java.lang.Object |
getDefaultSwingObjectForType(DatabaseFieldType tFieldType)
|
protected java.lang.Double |
getDoubleField(DatabaseField field)
Gets the int value of a field whose type is TFieldType.DOUBLE |
java.util.List<PickListEnumeration> |
getEnumerations(DatabaseField field)
Returns a List of Enumerations for a given field (column). |
abstract DatabaseField[] |
getFieldsArray()
Returns an Array of TFields representing the columnnames of this bean. |
java.lang.Object |
getFieldValue(DatabaseField field)
Gets the value of a field. |
static java.util.Map<java.lang.Integer,JBean> |
getID_Bean_Map(java.util.List<JBean> beanList)
Returns a Map with an Integer representing the JBean's primary key ID and the value representing the Bean record itself. |
java.lang.Integer |
getID()
Gets the id of this bean |
protected java.lang.Integer |
getIntegerField(DatabaseField field)
Gets the int value of a field whose type is TFieldType.INTEGER |
abstract JBean |
getNewInstance()
Returns a new instance of this bean. |
static java.lang.String |
getNonNullString(java.sql.ResultSet rs,
java.lang.String fieldName)
Returns the value of fieldName in rs, or "" if the value is null. |
DatabaseField |
getPrimaryKeyField()
Returns the TField that is the Primary Key for the bean's table. |
java.lang.String |
getPrimaryKeyName()
Gets the primary key name of the bean's table. |
SelectResponse |
getSelectResponse(Search search)
Returns a SelectResponse containing a beanList and columnIdentifiers from a Search. |
java.lang.String |
getSQL(Search search)
Returns a SELECT SQL statement given a Search. |
StaticMetaData |
getStaticMetaData()
Gets the StaticMetaData of this bean. |
protected java.lang.String |
getStringField(DatabaseField field)
Gets the String value of a field whose type is TFieldType.STRING |
java.util.Map<DatabaseField,java.lang.Object> |
getSwingHash()
Gets a Map with the fields as the keys, and the swing-ready values as the Map's values. |
protected java.lang.Object |
getSwingToBeanObject(DatabaseField columnField,
java.lang.Object oldValue)
Gets the value for this bean from a Swing JTable cell. |
abstract DatabaseTable |
getTable()
|
java.lang.String |
getTableName()
Returns the name of the database table to which this bean refers. |
protected UserBean |
getUserBean()
Returns the UserBean of the person reading and writing data to this bean. |
(package private) java.lang.String |
getWantedColumnsString(Search search)
Returns a comma, delimited list of columnNames desired in a Search. |
(package private) java.util.List<DatabaseField> |
getWantedStaticColumnIdentifiers(Search search)
Returns a List of the ColumnIdentifiers that are desired by the end-user's search. |
protected static java.lang.String |
getWhereClause(Search search,
JBean bean,
java.lang.String additional)
Returns the WHERE Clause of a SELECT statement given a Search. |
int |
hashCode()
Returns the ID of this bean. |
void |
insert()
Inserts the database row with the data in this Bean. |
boolean |
isEnumerated(DatabaseField field)
Returns true if the column is enumerated (gives a comboBox of choices). |
(package private) void |
setBooleanField(DatabaseField field,
java.lang.Boolean bool)
Sets a field of type TFieldType.BOOLEAN |
(package private) void |
setDateField(DatabaseField field,
java.util.Date date)
|
protected void |
setDoubleField(DatabaseField field,
java.lang.Double newValue)
Sets a field of type TFieldType.DOUBLE |
void |
setID(int id)
Sets the id of this bean. |
protected void |
setIntegerField(DatabaseField field,
java.lang.Integer newValue)
Sets a field of type TFieldType.INTEGER |
(package private) void |
setStringField(DatabaseField field,
java.lang.String s)
Sets a field of type TFieldType.STRING |
void |
setUserBean(UserBean u)
Sets the User who is reading and writing information to this bean. |
java.lang.String |
toString()
Returns the primary key name of the bean's table, along with the bean's ID. |
void |
update()
Updates the database row with the data in this Bean. |
void |
verify()
Overwritten by subclasses, this method may throw an exception before an insert() or update() is done if there is something wrong with the JBean. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final StaticMetaData staticMetaData
Constructor Detail |
---|
protected JBean(StaticMetaData staticMetaData)
Method Detail |
---|
public java.util.List<PickListEnumeration> getEnumerations(DatabaseField field)
public boolean isEnumerated(DatabaseField field)
final boolean getBooleanField(DatabaseField field)
protected final java.lang.Integer getIntegerField(DatabaseField field)
protected final java.lang.Double getDoubleField(DatabaseField field)
protected final java.lang.String getStringField(DatabaseField field)
protected final java.util.Date getDateField(DatabaseField field)
public final java.lang.Object getFieldValue(DatabaseField field)
public final void setUserBean(UserBean u)
protected final UserBean getUserBean()
protected final void setIntegerField(DatabaseField field, java.lang.Integer newValue)
protected final void setDoubleField(DatabaseField field, java.lang.Double newValue)
final void setStringField(DatabaseField field, java.lang.String s)
final void setBooleanField(DatabaseField field, java.lang.Boolean bool)
final void setDateField(DatabaseField field, java.util.Date date)
public java.util.Map<DatabaseField,java.lang.Object> getSwingHash()
public void createFromSwingMap(java.util.Map<DatabaseField,java.lang.Object> columnField_value)
columnField_value
- A map where the keys are the columns in the Swing table, and the values are the
data the user put in.public final void createFromResultSet(java.sql.ResultSet rs, java.util.Set<java.lang.String> columnNames) throws java.sql.SQLException
rs
- a ResultSet pointing to a row in the database tablecolumnNames
- the column names in the resultset to get.
java.sql.SQLException
public void update() throws java.sql.SQLException
java.sql.SQLException
public void insert() throws java.sql.SQLException
java.sql.SQLException
protected java.lang.Object getSwingToBeanObject(DatabaseField columnField, java.lang.Object oldValue)
public final java.lang.Integer getID()
public final void setID(int id)
public void delete() throws java.sql.SQLException
java.sql.SQLException
public final java.util.List<DatabaseField> getAllStaticColumnIdentifiers()
final java.util.List<DatabaseField> getWantedStaticColumnIdentifiers(Search search)
protected java.util.List<DatabaseField> getColumnIdentifiers(Search search, java.util.List<JBean> beanList)
public final SelectResponse getSelectResponse(Search search) throws java.sql.SQLException
java.sql.SQLException
public final java.util.List<JBean> getBeanList(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
protected java.util.List<JBean> getBeanList(Search search) throws java.sql.SQLException
java.sql.SQLException
static final java.util.Set<java.lang.String> getColumnNamesSet(java.sql.ResultSet rs) throws java.sql.SQLException
java.sql.SQLException
public final DatabaseField getPrimaryKeyField()
public final java.lang.String getPrimaryKeyName()
public final java.lang.String getTableName()
public abstract JBean getNewInstance()
public abstract DatabaseField[] getFieldsArray()
protected final java.lang.String getBaseSQL(Search search)
public java.lang.String getSQL(Search search)
final java.lang.String getWantedColumnsString(Search search)
protected static java.lang.String getWhereClause(Search search, JBean bean, java.lang.String additional)
public static java.util.Map<java.lang.Integer,JBean> getID_Bean_Map(java.util.List<JBean> beanList)
public static java.lang.String getNonNullString(java.sql.ResultSet rs, java.lang.String fieldName) throws java.sql.SQLException
java.sql.SQLException
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
public java.lang.String toString()
toString
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public void verify() throws java.sql.SQLException
java.sql.SQLException
public final StaticMetaData getStaticMetaData()
protected JBean getBeanInDatabase() throws java.sql.SQLException
java.sql.SQLException
public abstract DatabaseTable getTable()
public static java.lang.Object getDefaultSwingObjectForType(DatabaseFieldType tFieldType)
public static java.lang.Object getDefaultBeanObjectForType(DatabaseFieldType tFieldType)
public static java.lang.Class getClassForType(DatabaseFieldType tFieldType)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |