butler.swing.util
Class ButlerFormatter

java.lang.Object
  extended by javax.swing.JFormattedTextField.AbstractFormatter
      extended by javax.swing.text.DefaultFormatter
          extended by butler.swing.util.ButlerFormatter
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class ButlerFormatter
extends javax.swing.text.DefaultFormatter

Author:
Sara Olsson
See Also:
Serialized Form

Constructor Summary
ButlerFormatter(StringDatatype datatype)
           
 
Method Summary
 javax.swing.text.DocumentFilter getDocumentFilter()
          Returns the DocumentFilter used to restrict the characters that can be input into the JFormattedTextField.
 void setContent(java.lang.String content)
           
 void setDatatype(StringDatatype datatype)
           
 java.lang.Object stringToValue(java.lang.String text)
          Parses text returning an arbitrary Object.
 java.lang.String valueToString(java.lang.Object value)
           
 
Methods inherited from class javax.swing.text.DefaultFormatter
clone, getAllowsInvalid, getCommitsOnValidEdit, getNavigationFilter, getOverwriteMode, getValueClass, install, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClass
 
Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter
getActions, getFormattedTextField, invalidEdit, setEditValid, uninstall
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ButlerFormatter

public ButlerFormatter(StringDatatype datatype)
                throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

setDatatype

public void setDatatype(StringDatatype datatype)
                 throws java.lang.Exception
Throws:
java.lang.Exception

stringToValue

public java.lang.Object stringToValue(java.lang.String text)
                               throws java.text.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 javax.swing.text.DefaultFormatter
Parameters:
text - String to convert
Returns:
Object representation of text
Throws:
java.text.ParseException - if there is an error in the conversion

valueToString

public java.lang.String valueToString(java.lang.Object value)
                               throws java.text.ParseException
Overrides:
valueToString in class javax.swing.text.DefaultFormatter
Throws:
java.text.ParseException

setContent

public void setContent(java.lang.String content)

getDocumentFilter

public javax.swing.text.DocumentFilter getDocumentFilter()
Returns the DocumentFilter used to restrict the characters that can be input into the JFormattedTextField.

Overrides:
getDocumentFilter in class javax.swing.text.DefaultFormatter