com.nqadmin.swingSet
Class SSTextDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.PlainDocument
          extended by com.nqadmin.swingSet.SSTextDocument
All Implemented Interfaces:
java.io.Serializable, javax.swing.text.Document

public class SSTextDocument
extends javax.swing.text.PlainDocument

SSTextDocument.java

SwingSet - Open Toolkit For Making Swing Controls Database-Aware

 Java PlainDocument that is 'database-aware'.  When developing a database
 application the SSTextDocument can be used in conjunction with the
 SSDataNavigator to allow for both editing and navigation of the rows in a
 database table.

 The SSTextDocument takes a SSRowSet and either a column index or a column name
 as arguments.  Whenever the cursor is moved (e.g. navigation occurs on the
 SSDataNavigator), the document property of the bound Swing control changes to
 reflect the new value for the database column.

 Note that a SSRowSet insert doesn't implicitly modify the cursor which is why
 the SSDBNavImp is provided for clearing controls following an insert.

Version:
$Revision: 1.27 $
Author:
$Author: prasanth $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement
 
Field Summary
protected  javax.swing.text.SimpleAttributeSet attribute
          A straightforward implementation of MutableAttributeSet (a mutable collection of unique attributes) using a hash table.
protected  int columnIndex
          Index of SSRowSet column to which the document will be bound.
protected  java.lang.String columnName
          Name of SSRowSet column to which the document will be bound.
protected  int columnType
          Column SQL data type.
protected  SSRowSet sSRowSet
          SSRowSet from which document will get/set values.
 
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttribute
 
Fields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
SSTextDocument(SSRowSet _sSRowSet, int _columnIndex)
          Constructs a SSTextDocument with the given SSRowSet and column index.
SSTextDocument(SSRowSet _sSRowSet, java.lang.String _columnName)
          Constructs a SSTextDocument with the given SSRowSet and column name.
 
Method Summary
protected  void bind()
          Retrieves meta data for column & initializes document text if applicable.
 int getColumnIndex()
          Returns the index of the column to which the document is bound.
 java.lang.String getColumnName()
          Returns the column name to which the document is bound.
protected  java.sql.Date getSQLDate(java.lang.String _strDate)
          Converts a date string in "MM/dd/yyyy" format to an SQL Date.
 SSRowSet getSSRowSet()
          Returns the SSRowSet to which the document is bound.
protected  java.lang.String getText()
          Method used by sSRowSet listeners to get the new text when the SSRowSet events are triggered.
 void setColumnIndex(int _columnIndex)
          Sets the column index to which the document is to be bound.
 void setColumnName(java.lang.String _columnName)
          Sets the column name to which the document is to be bound.
 void setSSRowSet(SSRowSet _sSRowSet)
          Sets the SSRowSet to which the document is bound.
protected  void updateDocument()
          Method used by sSRowSet listeners to update the bound document.
protected  void updateText(java.lang.String strValue)
          Method used by document listeners to update the underlying sSRowSet.
 
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertString, insertUpdate, removeUpdate
 
Methods inherited from class javax.swing.text.AbstractDocument
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sSRowSet

protected SSRowSet sSRowSet
SSRowSet from which document will get/set values.


columnName

protected java.lang.String columnName
Name of SSRowSet column to which the document will be bound.


columnType

protected int columnType
Column SQL data type.


columnIndex

protected int columnIndex
Index of SSRowSet column to which the document will be bound.


attribute

protected javax.swing.text.SimpleAttributeSet attribute
A straightforward implementation of MutableAttributeSet (a mutable collection of unique attributes) using a hash table.

Constructor Detail

SSTextDocument

public SSTextDocument(SSRowSet _sSRowSet,
                      java.lang.String _columnName)
Constructs a SSTextDocument with the given SSRowSet and column name. The document is bound to the specified column in the SSRowSet

Parameters:
_sSRowSet - SSRowSet upon which document will be based
_columnName - column name within SSRowSet upon which document will be based

SSTextDocument

public SSTextDocument(SSRowSet _sSRowSet,
                      int _columnIndex)
Constructs a SSTextDocument with the given SSRowSet and column index. The document is bound to the specified column in the SSRowSet.

Parameters:
_sSRowSet - SSRowSet upon which document will be based
_columnIndex - column index within SSRowSet upon which document will be based
Method Detail

setColumnName

public void setColumnName(java.lang.String _columnName)
Sets the column name to which the document is to be bound.

Parameters:
_columnName - column Name to which the document is to be bound

getColumnName

public java.lang.String getColumnName()
Returns the column name to which the document is bound.

Returns:
returns the column name to which the document is bound.

setColumnIndex

public void setColumnIndex(int _columnIndex)
Sets the column index to which the document is to be bound.

Parameters:
_columnIndex - column index to which the document is to be bound

getColumnIndex

public int getColumnIndex()
Returns the index of the column to which the document is bound.

Returns:
returns the index of the column to which the document is bound

setSSRowSet

public void setSSRowSet(SSRowSet _sSRowSet)
Sets the SSRowSet to which the document is bound.

Parameters:
_sSRowSet - SSRowSet to which the component is bound

getSSRowSet

public SSRowSet getSSRowSet()
Returns the SSRowSet to which the document is bound.

Returns:
SSRowSet to which the document is bound

bind

protected void bind()
Retrieves meta data for column & initializes document text if applicable.


updateDocument

protected void updateDocument()
Method used by sSRowSet listeners to update the bound document.


updateText

protected void updateText(java.lang.String strValue)
Method used by document listeners to update the underlying sSRowSet.


getText

protected java.lang.String getText()
Method used by sSRowSet listeners to get the new text when the SSRowSet events are triggered.


getSQLDate

protected java.sql.Date getSQLDate(java.lang.String _strDate)
Converts a date string in "MM/dd/yyyy" format to an SQL Date.

Parameters:
_strDate - date string in "MM/dd/yyyy" format
Returns:
return SQL date for the string specified