com.isti.util.gui
Class FilteredDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.PlainDocument
          extended by com.isti.util.gui.FilteredDocument
All Implemented Interfaces:
java.io.Serializable, javax.swing.text.Document

 class FilteredDocument
extends javax.swing.text.PlainDocument

Class FilteredDocument is an extension of 'PlainDocument' that implements the filtering of input characters.


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
 boolean allowFlag
           
 int maxNumChars
           
 boolean numericFlag
           
 java.lang.String specialChars
           
 
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
FilteredDocument(java.lang.String allowedChars, boolean numericFlag, int maxNumChars)
          Constructs a plain text document.
FilteredDocument(java.lang.String specialChars, boolean numericFlag, int maxNumChars, boolean allowFlag)
          Constructs a plain text document.
 
Method Summary
 java.lang.Comparable getMaxValueObj()
          Returns the maximum value to be allowed for numeric entries, or null if no value has been entered.
 void insertString(int insOffs, java.lang.String insStr, javax.swing.text.AttributeSet aSet)
          Inserts data into the document, filtering it along the way.
 void setMaxValueObj(java.lang.Comparable obj)
          Sets a maximum value to be allowed for numeric entries (only used if the 'numericFlag' is true).
 
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, 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

specialChars

public final java.lang.String specialChars

numericFlag

public final boolean numericFlag

maxNumChars

public final int maxNumChars

allowFlag

public final boolean allowFlag
Constructor Detail

FilteredDocument

public FilteredDocument(java.lang.String allowedChars,
                        boolean numericFlag,
                        int maxNumChars)
Constructs a plain text document.

Parameters:
allowedChars - a String of characters allowed to be entered into the document.
numericFlag - true for valid numeric only
maxNumChars - maximum number of chars allowed

FilteredDocument

public FilteredDocument(java.lang.String specialChars,
                        boolean numericFlag,
                        int maxNumChars,
                        boolean allowFlag)
Constructs a plain text document.

Parameters:
specialChars - a String of characters allowed (or not) into the document.
numericFlag - true for valid numeric only
maxNumChars - maximum number of chars allowed
allowFlag - true to allow only the special characters, false to not allow the special characters.
Method Detail

insertString

public void insertString(int insOffs,
                         java.lang.String insStr,
                         javax.swing.text.AttributeSet aSet)
                  throws javax.swing.text.BadLocationException
Inserts data into the document, filtering it along the way.

Specified by:
insertString in interface javax.swing.text.Document
Overrides:
insertString in class javax.swing.text.PlainDocument
Parameters:
insOffs - the starting offset (greater than or equal to zero).
insStr - the string to insert (empty and null strings are ignored).
aSet - the attributes for the inserted content.
Throws:
javax.swing.text.BadLocationException - if the given position is not a valid position within the document.

setMaxValueObj

public void setMaxValueObj(java.lang.Comparable obj)
Sets a maximum value to be allowed for numeric entries (only used if the 'numericFlag' is true).

Parameters:
obj - a "maximum" value object that implements the 'Comparable' interface (or null for no maximum).

getMaxValueObj

public java.lang.Comparable getMaxValueObj()
Returns the maximum value to be allowed for numeric entries, or null if no value has been entered.

Returns:
A "maximum" value object that implements the 'Comparable' interface, or null if no maximum.