org.springframework.richclient.form.binding.swing.text
Class RegExDocumentFactory

Show UML class diagram
java.lang.Object
  extended by org.springframework.richclient.form.binding.swing.text.RegExDocumentFactory
All Implemented Interfaces:
DocumentFactory

public class RegExDocumentFactory
extends Object
implements DocumentFactory

This DocumentFactory will create a Document which holds a Pattern. This Pattern is then used to verify each character that is inserted. This makes it possible to eg. allow only alfanumeric. Note that if you need a specific sequence of characters, you probably need a formatted textField with formatter instead.

Author:
Lieven Doclo, Jan Hoskens

Constructor Summary
RegExDocumentFactory()
          Default constructor sets the pattern to use '.'.
RegExDocumentFactory(String characterPattern)
          Construct a RegExDocumentFactory with the given pattern.
RegExDocumentFactory(String characterPattern, boolean convertToUppercase)
          Construct a RegExDocumentFactory with the given pattern and convert to uppercase if requested.
 
Method Summary
 Document createDocument()
          Create a new Document to be used in a JTextComponent.
 String getCharacterPattern()
          Returns the pattern that is used by this RegExDocumentFactory.
 boolean isConvertToUppercase()
          Returns true if the Document should convert all lowercase letters to uppercase.
 void setCharacterPattern(String characterPattern)
          Set the pattern to be used by this RegExDocumentFactory.
 void setConvertToUppercase(boolean convertToUppercase)
          Set to true if all lowercase letters should be converted to uppercase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegExDocumentFactory

public RegExDocumentFactory()
Default constructor sets the pattern to use '.'.


RegExDocumentFactory

public RegExDocumentFactory(String characterPattern)
Construct a RegExDocumentFactory with the given pattern.

Parameters:
characterPattern - the pattern to use.

RegExDocumentFactory

public RegExDocumentFactory(String characterPattern,
                            boolean convertToUppercase)
Construct a RegExDocumentFactory with the given pattern and convert to uppercase if requested.

Parameters:
characterPattern - the pattern to use.
convertToUppercase - if true convert all letters to uppercase.
Method Detail

getCharacterPattern

public String getCharacterPattern()
Returns the pattern that is used by this RegExDocumentFactory.

Returns:
the pattern.

setCharacterPattern

public void setCharacterPattern(String characterPattern)
Set the pattern to be used by this RegExDocumentFactory.

Parameters:
characterPattern - the pattern.

isConvertToUppercase

public boolean isConvertToUppercase()
Returns true if the Document should convert all lowercase letters to uppercase.

Returns:
true if lowercase is converted to uppercase.

setConvertToUppercase

public void setConvertToUppercase(boolean convertToUppercase)
Set to true if all lowercase letters should be converted to uppercase.

Parameters:
convertToUppercase - set to true if conversion should happen.

createDocument

public Document createDocument()
Create a new Document to be used in a JTextComponent.

Specified by:
createDocument in interface DocumentFactory
Returns:
an implementation of Document.


Copyright © 2004-2009 The Spring Framework. All Rights Reserved.