com.isti.util.gui.textvalidator
Class ValidatedDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.PlainDocument
          extended by com.isti.util.gui.textvalidator.AbstractValidatedDocument
              extended by com.isti.util.gui.textvalidator.ValidatedDocument
All Implemented Interfaces:
AllowedCharactersConstants, StringConstants, java.io.Serializable, javax.swing.text.Document

public class ValidatedDocument
extends AbstractValidatedDocument
implements AllowedCharactersConstants

Class ValidatedDocument is an extension of 'PlainDocument' that implements the validating of input characters.

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
 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 com.isti.util.StringConstants
ALPHA_CAP_CHARS, ALPHA_CHARS, ALPHA_LOW_CHARS, ALPHANUM_CHARS_STRING, ALPHANUMERIC_CHARS, BOOLEAN_FALSE_TEXT, BOOLEAN_TRUE_TEXT, DATE_FORMAT_AMPM_STR, DATE_FORMAT_RFC_822_STR, DATE_FORMAT24_STR, DEFAULT_JAVA_VERSION_STRING, DEFAULT_NULL_STR, DEFAULT_SEP_STR, EFLOAT_CHARS, EMPTY_STRING, FLOAT_CHARS, HEX_ALPHA_CAP_CHARS, HEX_ALPHA_LOW_CHARS, HEX_CHARS, INTEGER_CHARS, INVALID_FILENAME_CHARS, QUOTE_STRING, SIGNED_EFLOAT_CHARS, SIGNED_FLOAT_CHARS, SIGNED_INT_CHARS, SPACE_STRING, TOD_CHARS, WHITE_SPACE_CHARS, WILDCARD_ALL_CHAR, WILDCARD_CHARS, WILDCARD_SINGLE_CHAR
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
ValidatedDocument(java.lang.String specialChars, boolean numericFlag, int maxNumChars, boolean allowFlag)
          Constructs a plain text document.
 
Method Summary
 boolean getAllowedFlag()
          Gets the allowed flag.
 int getColumns()
          Gets the number of columns.
 int getMaxNumChars()
          Gets the maximum number of characters.
 java.lang.String getSpecialChars()
          Gets the allowed (or not allowed) special characters.
 TextValidator getTextValidator()
          Returns the text validator.
 boolean isNumeric()
          Determines if the characters represent a numeric value.
protected  boolean isReplace()
          Determines if trying to replace characters.
 void setTextValidator(TextValidator tv)
          Sets the text validator.
 
Methods inherited from class com.isti.util.gui.textvalidator.AbstractValidatedDocument
insertString, isAllowed, isReplace, isSpecialChar
 
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

ValidatedDocument

public ValidatedDocument(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, false otherwise.
maxNumChars - maximum number of chars allowed or 0 for none.
allowFlag - true to allow only the special characters, false to not allow the special characters.
Method Detail

getAllowedFlag

public boolean getAllowedFlag()
Gets the allowed flag.

Specified by:
getAllowedFlag in class AbstractValidatedDocument
Returns:
true to allow only the special characters, false to not allow the special characters.
See Also:
getSpecialChars()

getColumns

public int getColumns()
Gets the number of columns.

Specified by:
getColumns in class AbstractValidatedDocument
Returns:
the number of columns or -1 for the default.

getMaxNumChars

public int getMaxNumChars()
Gets the maximum number of characters.

Specified by:
getMaxNumChars in class AbstractValidatedDocument
Returns:
the maximum number of characters or 0 if none.

getSpecialChars

public java.lang.String getSpecialChars()
Gets the allowed (or not allowed) special characters. If there are no special characters then all characters are allowed.

Specified by:
getSpecialChars in class AbstractValidatedDocument
Returns:
the allowed characters or null for none.
See Also:
getAllowedFlag()

getTextValidator

public TextValidator getTextValidator()
Returns the text validator.

Specified by:
getTextValidator in class AbstractValidatedDocument
Returns:
the text validator or null if none.

isNumeric

public boolean isNumeric()
Determines if the characters represent a numeric value.

Specified by:
isNumeric in class AbstractValidatedDocument
Returns:
true if numeric value, false otherwise

isReplace

protected boolean isReplace()
Determines if trying to replace characters.

Overrides:
isReplace in class AbstractValidatedDocument
Returns:
true if trying to replace characters, false otherwise.

setTextValidator

public void setTextValidator(TextValidator tv)
Sets the text validator.

Specified by:
setTextValidator in class AbstractValidatedDocument
Parameters:
tv - the text validator or null if none.