com.quadrique.jbuildingblocks.gui
Class RegularExpressionFormatter

java.lang.Object
  extended by javax.swing.JFormattedTextField.AbstractFormatter
      extended by javax.swing.text.DefaultFormatter
          extended by com.quadrique.jbuildingblocks.gui.RegularExpressionFormatter
All Implemented Interfaces:
Serializable, Cloneable

public class RegularExpressionFormatter
extends DefaultFormatter

A regular expression based implementation of AbstractFormatter.

See Also:
Serialized Form

Constructor Summary
RegularExpressionFormatter()
           
RegularExpressionFormatter(Pattern pattern)
          Creates a regular expression based AbstractFormatter.
RegularExpressionFormatter(String pattern)
          Creates a regular expression based AbstractFormatter.
 
Method Summary
 Pattern getPattern()
          Returns the Pattern used to determine if a value is legal.
 void setPattern(Pattern pattern)
          Sets the pattern that will be used to determine if a value is legal.
 Object stringToValue(String text)
          Parses text returning an arbitrary Object.
 
Methods inherited from class javax.swing.text.DefaultFormatter
clone, getAllowsInvalid, getCommitsOnValidEdit, getOverwriteMode, getValueClass, install, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClass, valueToString
 
Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter
uninstall
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegularExpressionFormatter

public RegularExpressionFormatter()

RegularExpressionFormatter

public RegularExpressionFormatter(String pattern)
                           throws PatternSyntaxException
Creates a regular expression based AbstractFormatter. pattern specifies the regular expression that will be used to determine if a value is legal.

Throws:
PatternSyntaxException

RegularExpressionFormatter

public RegularExpressionFormatter(Pattern pattern)
Creates a regular expression based AbstractFormatter. pattern specifies the regular expression that will be used to determine if a value is legal.

Method Detail

setPattern

public void setPattern(Pattern pattern)
Sets the pattern that will be used to determine if a value is legal.


getPattern

public Pattern getPattern()
Returns the Pattern used to determine if a value is legal.


stringToValue

public Object stringToValue(String text)
                     throws ParseException
Parses text returning an arbitrary Object. Some formatters may return null.

If a Pattern has been specified and the text completely matches the regular expression this will invoke setMatcher.

Overrides:
stringToValue in class DefaultFormatter
Parameters:
text - String to convert
Returns:
Object representation of text
Throws:
ParseException - if there is an error in the conversion


Copyright © 2001-2009 Quadrique Corporation. All Rights Reserved.