ProgramixGenericLib v5.0.1

com.programix.gui.text
Class FilterChainDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.PlainDocument
          extended by com.programix.gui.text.FilterChainDocument
All Implemented Interfaces:
Serializable, Document

public class FilterChainDocument
extends PlainDocument

This is a extension of PlainDocument that allows zero or more filters to be applied to text that is trying to be inserted.

Author:
Paul Hyde
See Also:
Serialized Form

Nested Class Summary
static class FilterChainDocument.BasicFilter
          Implements the FilterChainDocument.Filter interface and provides a new, single FilterChainDocument.BasicFilter.filter(String) abstract method for subclasses to implement.
static interface FilterChainDocument.Filter
          Interface that all filters for a FilterChainDocument must implement.
static class FilterChainDocument.LengthFilter
          Filters content by only allowing a maximum number of characters to be in the document.
static class FilterChainDocument.WinnowFilter
          Winnows out invalid characters from the source String keeping only the characters specified as valid during construction.
 
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
 
Field Summary
static FilterChainDocument.Filter ALPHA_FILTER
          FilterChainDocument.Filter that keeps the characters as specified in StringTools.winnowAlpha(String).
static FilterChainDocument.Filter ALPHANUMERIC_FILTER
          FilterChainDocument.Filter that keeps the characters as specified in StringTools.winnowAlphaNumeric(String).
static FilterChainDocument.Filter DECIMAL_FILTER
          FilterChainDocument.Filter that keeps the characters as specified in StringTools.winnowDecimal(String).
static FilterChainDocument.Filter DIGIT_FILTER
          FilterChainDocument.Filter that keeps the characters as specified in StringTools.winnowDigit(String).
static FilterChainDocument.Filter TO_LOWER_CASE_FILTER
          FilterChainDocument.Filter that translates any upper-case characters to lower-case.
static FilterChainDocument.Filter TO_UPPER_CASE_FILTER
          FilterChainDocument.Filter that translates any lower-case characters to upper-case.
 
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
FilterChainDocument()
           
FilterChainDocument(FilterChainDocument.Filter firstFilter)
           
 
Method Summary
 FilterChainDocument append(FilterChainDocument.Filter filter)
           
 void clear()
           
 void insertString(int offset, String src, AttributeSet attr)
           
 
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

TO_UPPER_CASE_FILTER

public static final FilterChainDocument.Filter TO_UPPER_CASE_FILTER
FilterChainDocument.Filter that translates any lower-case characters to upper-case.


TO_LOWER_CASE_FILTER

public static final FilterChainDocument.Filter TO_LOWER_CASE_FILTER
FilterChainDocument.Filter that translates any upper-case characters to lower-case.


ALPHA_FILTER

public static final FilterChainDocument.Filter ALPHA_FILTER
FilterChainDocument.Filter that keeps the characters as specified in StringTools.winnowAlpha(String).


ALPHANUMERIC_FILTER

public static final FilterChainDocument.Filter ALPHANUMERIC_FILTER
FilterChainDocument.Filter that keeps the characters as specified in StringTools.winnowAlphaNumeric(String).


DIGIT_FILTER

public static final FilterChainDocument.Filter DIGIT_FILTER
FilterChainDocument.Filter that keeps the characters as specified in StringTools.winnowDigit(String).


DECIMAL_FILTER

public static final FilterChainDocument.Filter DECIMAL_FILTER
FilterChainDocument.Filter that keeps the characters as specified in StringTools.winnowDecimal(String).

Constructor Detail

FilterChainDocument

public FilterChainDocument(FilterChainDocument.Filter firstFilter)

FilterChainDocument

public FilterChainDocument()
Method Detail

append

public FilterChainDocument append(FilterChainDocument.Filter filter)

clear

public void clear()

insertString

public void insertString(int offset,
                         String src,
                         AttributeSet attr)
                  throws BadLocationException
Specified by:
insertString in interface Document
Overrides:
insertString in class PlainDocument
Throws:
BadLocationException

ProgramixGenericLib v5.0.1

Copyright © 2001-2009 Programix Incorporated. All rights reserved. ProgramixGenericLib is free and is OSI Certified Open Source Software under the BSD license.