cmu.survey.jsp.tags
Class DatabaseList

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by cmu.survey.jsp.tags.TagSupportAndMore
          extended by cmu.survey.jsp.tags.DatabaseList
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.Tag, javax.servlet.jsp.tagext.TryCatchFinally
Direct Known Subclasses:
DatabaseUpdate, TableField

public class DatabaseList
extends TagSupportAndMore

Forms the backbone for retrieving things from the database and printing them. (Look at a graph of the hiearchy to see how many different classes it is a parent of)
It can easily print out a list of items, or retrieve any single field. It starts the connection with the database through setupConnection(), does queries through doQuery(), retrieves the fiedls with getField(), prints them out with printField(), and prints out the list with printList().
There is also a large set of related parameters that many printouts desire to use.

See Also:
Serialized Form

Field Summary
 java.sql.ResultSet auxResultSet
           
protected  java.sql.Connection databaseConnection
           
 java.lang.String field
           
protected  java.lang.String[] fieldsToShowArray
           
 javax.servlet.jsp.JspWriter out
          Used to write text directly to the response stream
 java.lang.String queryObjectName
           
 java.sql.ResultSet resultSet
           
 java.lang.String returnMessage
           
 java.sql.Statement select
           
protected  DatabaseConnection theConnection
           
 
Fields inherited from class cmu.survey.jsp.tags.TagSupportAndMore
dateFormatAmerican, dateTimeFormatAmerican, DAYS_OF_THE_WEEK, debug, MONTHS_OF_THE_YEAR, timeFormatAmerican
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
DatabaseList()
           
DatabaseList(DatabaseConnection database)
           
 
Method Summary
 void close()
           
 void doAuxillaryQuery(java.lang.String auxillaryDatabaseQuery)
          Execute the current databaseQuery and leaves the results in the auxResultSet object.
 int doEndTag()
           
 void doQuery(java.lang.String aDatabaseQuery)
          Execute the current databaseQuery and leaves the results in the resultSet object.
 int doStartTag()
           
 void finalize()
           
 java.lang.String formatDateMySQL(java.lang.String currentString, java.text.DateFormat currentFormat)
          Takes a string and a format that it is in, and returns the format that MySQL can understand.
 java.lang.String formatDateSQL(java.util.Calendar cal)
          Takes a string and a format that it is in, and returns the format that SQL can understand.
 java.lang.String formatDateSQL(java.util.Date theDate)
          Takes a string and a format that it is in, and returns the format that SQL can understand.
 java.lang.String formatDateSQLFromHTML(java.lang.String currentString)
           
 java.lang.String formatDateTimeSQL(java.util.Calendar theDate)
          Takes a Calendar and returns the format that SQL can understand.
 java.lang.String formatDateTimeSQL(java.util.Date theDate)
          Takes a Date and returns the format that SQL can understand.
 java.lang.String formatDateTimeSQL(java.lang.String currentString, java.text.DateFormat currentFormat)
          Takes a string and a format that it is in, and returns the format that MySQL can understand.
 java.lang.String formatTimeMySQL(java.lang.String currentString, java.text.DateFormat currentFormat)
          Takes a string and a format that it is in, and returns the format that MySQL can understand.
 java.lang.String formatTimeSQL(java.util.Calendar theDate)
          Takes a Calendar and returns the format that SQL can understand.
 java.lang.String formatTimeSQL(java.util.Date theDate)
          Takes a Date returns it in a format that MySQL can understand.
 java.lang.String getAuxDatabaseQuery()
           
 java.util.Calendar getCalendar()
          Use the following three methods instead of making your own Date or Calendar from scratch.
 java.sql.Connection getDatabaseConnection()
           
 java.lang.String getDatabaseQuery()
           
 java.util.Date getDateField(java.lang.String fieldName)
           
 java.util.Calendar getDateFieldCal(java.lang.String fieldName)
           
 java.util.Calendar getDateFrom(java.util.Calendar cale, java.sql.Time time)
           
 java.util.Calendar getDateTimeCalendarField(java.lang.String fieldName)
           
 java.util.Date getDateTimeField(java.lang.String fieldName)
           
 java.lang.String getEndWith()
           
 java.lang.String getField()
           
 java.lang.String getField(java.lang.String fieldName)
          For the current row in the resultSet, will return the value of the given field.
 java.util.Vector getFields()
           
 java.util.Vector getFields(java.lang.String fieldsToShow)
           
 java.lang.String getFieldToPassInLink()
           
 int getIntField(java.lang.String fieldName)
           
 java.lang.Throwable getLastExceptionThrown()
           
 java.lang.String getLinkTo()
           
 java.lang.String getList(java.lang.String fieldToShow)
           
 java.lang.String getOneLine(java.lang.String fieldToShow)
           
 java.lang.String getOptionTag()
           
 java.lang.String getQueryObjectName()
           
 boolean getSaveAsSession()
           
 boolean getSendErrorMessages()
           
 java.sql.Time getSQLTimeField(java.lang.String fieldName)
           
 java.lang.String getStartWith()
           
 DatabaseConnection getTheConnection()
           
 java.util.Date getTimeField(java.lang.String fieldName)
           
 java.util.Calendar getTimeFieldCal(java.lang.String fieldName)
           
 java.sql.Timestamp getTimestampField(java.lang.String fieldName)
           
 boolean isCurrentItemInAuxQuery(java.lang.String identifierField)
           
 boolean isDatabaseOpen()
           
 boolean moveToNextAuxillaryRecord()
           
 boolean moveToNextRecord()
           
 java.util.Date parseDateFromSQL(java.lang.String time)
          Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand.
 java.util.Calendar parseDateTimeCalendarFromSQL(java.lang.String dateTime)
          Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand.
 java.util.Date parseDateTimeFromSQL(java.lang.String dateTime)
          Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand.
 java.util.Date parseDateTimeFromSQL(java.lang.String date, java.lang.String time)
          Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand.
 java.util.Date parseTimeFromSQL(java.lang.String time)
          Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand.
 void printList(java.lang.String fieldToShow)
          printList Print a list of the fields, showing fieldToShow and adding links if the parameters are right (see below for details)
 void printOneLine(java.lang.String fieldToShow)
          Prints the current record, according to paramaters, to the browser.
 void reinit()
           
 void resetFieldsForNextRecord()
          Nulls out the hash table containing the row from the recordset
 java.lang.String returnOneLine(java.lang.String fieldsToShow)
          Returns a string of the current line EXCEPT the startWith and endWith delimiters.
protected  void saveErrorMessage(java.lang.String error)
           
protected  void saveErrorMessage(java.lang.String error, java.lang.Throwable e)
           
 void setAuxDatabaseQuery(java.lang.String value)
           
 void setDatabaseQuery(java.lang.String value)
           
 void setEndWith(java.lang.String value)
           
 void setField(java.lang.String value)
           
 void setFieldToPassInLink(java.lang.String value)
           
 void setLinkTo(java.lang.String value)
           
 void setOptionTag(java.lang.String value)
           
 void setQueryObjectName(java.lang.String value)
           
 void setSaveAsSession(boolean saveIntoSessionVariable)
           
 void setSendErrorMessages(boolean emailTheErrorMessages)
           
 void setStartWith(java.lang.String value)
           
 void setupConnection()
           
protected  void setupConnection(DatabaseConnection theNewConnection)
          Used to initialize the connection object, statements, and JSPWriter (out).
 
Methods inherited from class cmu.survey.jsp.tags.TagSupportAndMore
breakDownToArray, convertDayNameToNum, convertDayNumToName, convertDayNumToName, convertMonthNumToName, doCatch, doFinally, formatDateTimeViewable, formatDateTimeViewable, formatDateViewable, formatTimeNoSecondsViewable, formatTimeNoSecondsViewable, formatTimeNoSecondsViewable, getNumDaysInWeek, parseTimeNoSecondsFromViewable, print, println
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

select

public java.sql.Statement select

resultSet

public java.sql.ResultSet resultSet

auxResultSet

public java.sql.ResultSet auxResultSet

out

public javax.servlet.jsp.JspWriter out
Used to write text directly to the response stream


databaseConnection

protected java.sql.Connection databaseConnection

theConnection

protected DatabaseConnection theConnection

returnMessage

public java.lang.String returnMessage

fieldsToShowArray

protected java.lang.String[] fieldsToShowArray

field

public java.lang.String field

queryObjectName

public java.lang.String queryObjectName
Constructor Detail

DatabaseList

public DatabaseList()

DatabaseList

public DatabaseList(DatabaseConnection database)
Method Detail

setSendErrorMessages

public void setSendErrorMessages(boolean emailTheErrorMessages)

getSendErrorMessages

public boolean getSendErrorMessages()

saveErrorMessage

protected void saveErrorMessage(java.lang.String error,
                                java.lang.Throwable e)

saveErrorMessage

protected void saveErrorMessage(java.lang.String error)

getLastExceptionThrown

public java.lang.Throwable getLastExceptionThrown()

formatDateSQL

public java.lang.String formatDateSQL(java.util.Date theDate)
Takes a string and a format that it is in, and returns the format that SQL can understand.


formatDateSQL

public java.lang.String formatDateSQL(java.util.Calendar cal)
Takes a string and a format that it is in, and returns the format that SQL can understand.


formatTimeSQL

public java.lang.String formatTimeSQL(java.util.Date theDate)
Takes a Date returns it in a format that MySQL can understand.


formatDateMySQL

public java.lang.String formatDateMySQL(java.lang.String currentString,
                                        java.text.DateFormat currentFormat)
Takes a string and a format that it is in, and returns the format that MySQL can understand.


formatTimeMySQL

public java.lang.String formatTimeMySQL(java.lang.String currentString,
                                        java.text.DateFormat currentFormat)
Takes a string and a format that it is in, and returns the format that MySQL can understand.


formatDateTimeSQL

public java.lang.String formatDateTimeSQL(java.util.Date theDate)
Takes a Date and returns the format that SQL can understand.


formatDateTimeSQL

public java.lang.String formatDateTimeSQL(java.util.Calendar theDate)
Takes a Calendar and returns the format that SQL can understand.


formatTimeSQL

public java.lang.String formatTimeSQL(java.util.Calendar theDate)
Takes a Calendar and returns the format that SQL can understand.


formatDateTimeSQL

public java.lang.String formatDateTimeSQL(java.lang.String currentString,
                                          java.text.DateFormat currentFormat)
Takes a string and a format that it is in, and returns the format that MySQL can understand.


formatDateSQLFromHTML

public java.lang.String formatDateSQLFromHTML(java.lang.String currentString)

parseDateTimeFromSQL

public java.util.Date parseDateTimeFromSQL(java.lang.String dateTime)
Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand.


parseDateTimeCalendarFromSQL

public java.util.Calendar parseDateTimeCalendarFromSQL(java.lang.String dateTime)
Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand.


parseDateTimeFromSQL

public java.util.Date parseDateTimeFromSQL(java.lang.String date,
                                           java.lang.String time)
Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand.


parseDateFromSQL

public java.util.Date parseDateFromSQL(java.lang.String time)
Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand.


parseTimeFromSQL

public java.util.Date parseTimeFromSQL(java.lang.String time)
Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand.


getDateFrom

public java.util.Calendar getDateFrom(java.util.Calendar cale,
                                      java.sql.Time time)

getCalendar

public java.util.Calendar getCalendar()
Use the following three methods instead of making your own Date or Calendar from scratch. They will get the TimeZone from the database and use it. THIS method is in a VERY bad spot! It uses tbladmin, which is only in the ReserveSport software. Anything that depends upon it will only work in ReserveSport -- this should be fixed!!! It should be moved to ObjectSQLStorage (is copied there) and other parts to other places where it can be used properly.


setupConnection

protected void setupConnection(DatabaseConnection theNewConnection)
Used to initialize the connection object, statements, and JSPWriter (out). This should be done before any of those objects are used.


setupConnection

public void setupConnection()

doQuery

public void doQuery(java.lang.String aDatabaseQuery)
Execute the current databaseQuery and leaves the results in the resultSet object.


doAuxillaryQuery

public void doAuxillaryQuery(java.lang.String auxillaryDatabaseQuery)
Execute the current databaseQuery and leaves the results in the auxResultSet object.


isCurrentItemInAuxQuery

public boolean isCurrentItemInAuxQuery(java.lang.String identifierField)

getDateTimeField

public java.util.Date getDateTimeField(java.lang.String fieldName)

getDateTimeCalendarField

public java.util.Calendar getDateTimeCalendarField(java.lang.String fieldName)

getTimeField

public java.util.Date getTimeField(java.lang.String fieldName)

getTimeFieldCal

public java.util.Calendar getTimeFieldCal(java.lang.String fieldName)

getSQLTimeField

public java.sql.Time getSQLTimeField(java.lang.String fieldName)

getDateField

public java.util.Date getDateField(java.lang.String fieldName)

getDateFieldCal

public java.util.Calendar getDateFieldCal(java.lang.String fieldName)

getTimestampField

public java.sql.Timestamp getTimestampField(java.lang.String fieldName)

getIntField

public int getIntField(java.lang.String fieldName)

getField

public java.lang.String getField(java.lang.String fieldName)
For the current row in the resultSet, will return the value of the given field. If the resultset is null, will return null

Parameters:
fieldName - The attribute who's value you want
Returns:
The value of the given attribute in the current row

resetFieldsForNextRecord

public void resetFieldsForNextRecord()
Nulls out the hash table containing the row from the recordset


moveToNextRecord

public boolean moveToNextRecord()

moveToNextAuxillaryRecord

public boolean moveToNextAuxillaryRecord()

getFields

public java.util.Vector getFields()

getFields

public java.util.Vector getFields(java.lang.String fieldsToShow)

returnOneLine

public java.lang.String returnOneLine(java.lang.String fieldsToShow)
Returns a string of the current line EXCEPT the startWith and endWith delimiters. This will be helpful if you want to manipulate the lines in any way.


getOneLine

public java.lang.String getOneLine(java.lang.String fieldToShow)

printOneLine

public void printOneLine(java.lang.String fieldToShow)
Prints the current record, according to paramaters, to the browser.


getList

public java.lang.String getList(java.lang.String fieldToShow)

printList

public void printList(java.lang.String fieldToShow)
printList Print a list of the fields, showing fieldToShow and adding links if the parameters are right (see below for details)


close

public void close()

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

isDatabaseOpen

public boolean isDatabaseOpen()

setSaveAsSession

public void setSaveAsSession(boolean saveIntoSessionVariable)

getSaveAsSession

public boolean getSaveAsSession()

setStartWith

public void setStartWith(java.lang.String value)

setEndWith

public void setEndWith(java.lang.String value)

setLinkTo

public void setLinkTo(java.lang.String value)

getLinkTo

public java.lang.String getLinkTo()

setFieldToPassInLink

public void setFieldToPassInLink(java.lang.String value)

getFieldToPassInLink

public java.lang.String getFieldToPassInLink()

getStartWith

public java.lang.String getStartWith()

getEndWith

public java.lang.String getEndWith()

setDatabaseQuery

public void setDatabaseQuery(java.lang.String value)

getDatabaseQuery

public java.lang.String getDatabaseQuery()

setAuxDatabaseQuery

public void setAuxDatabaseQuery(java.lang.String value)

getAuxDatabaseQuery

public java.lang.String getAuxDatabaseQuery()

setField

public void setField(java.lang.String value)

getField

public java.lang.String getField()

setQueryObjectName

public void setQueryObjectName(java.lang.String value)

getQueryObjectName

public java.lang.String getQueryObjectName()

setOptionTag

public void setOptionTag(java.lang.String value)

getOptionTag

public java.lang.String getOptionTag()

getDatabaseConnection

public java.sql.Connection getDatabaseConnection()
Returns:

getTheConnection

public DatabaseConnection getTheConnection()
Returns:

doStartTag

public int doStartTag()
Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport

doEndTag

public int doEndTag()
Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class TagSupportAndMore

reinit

public void reinit()
Overrides:
reinit in class TagSupportAndMore