Class RegExFormatter
java.lang.Object
javax.swing.JFormattedTextField.AbstractFormatter
javax.swing.text.DefaultFormatter
com.inductiveautomation.factorypmi.application.components.util.RegExFormatter
- All Implemented Interfaces:
Serializable
,Cloneable
A regular expression based implementation of
AbstractFormatter
.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRegExFormatter
(String pattern) Creates a regular expression basedAbstractFormatter
.RegExFormatter
(Pattern pattern) Creates a regular expression basedAbstractFormatter
. -
Method Summary
Modifier and TypeMethodDescriptionprotected Matcher
Returns theMatcher
from the most test.Returns thePattern
used to determine if a value is legal.protected void
setMatcher
(Matcher matcher) Sets theMatcher
used in the most recent test if a value is legal.void
setPattern
(String strPattern) Sets the pattern that will be 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.stringToValue
(String text) Parsestext
returning an arbitrary Object.Methods inherited from class javax.swing.text.DefaultFormatter
clone, getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getNavigationFilter, getOverwriteMode, getValueClass, install, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClass, valueToString
Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter
getActions, getFormattedTextField, invalidEdit, setEditValid, uninstall
-
Constructor Details
-
RegExFormatter
public RegExFormatter() -
RegExFormatter
Creates a regular expression basedAbstractFormatter
.pattern
specifies the regular expression that will be used to determine if a value is legal.- Throws:
PatternSyntaxException
-
RegExFormatter
Creates a regular expression basedAbstractFormatter
.pattern
specifies the regular expression that will be used to determine if a value is legal.
-
-
Method Details
-
setPattern
Sets the pattern that will be used to determine if a value is legal. -
setPattern
Sets the pattern that will be used to determine if a value is legal. -
getPattern
Returns thePattern
used to determine if a value is legal. -
setMatcher
Sets theMatcher
used in the most recent test if a value is legal. -
getMatcher
Returns theMatcher
from the most test. -
stringToValue
Parsestext
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 invokesetMatcher
.- Overrides:
stringToValue
in classDefaultFormatter
- Parameters:
text
- String to convert- Returns:
- Object representation of text
- Throws:
ParseException
- if there is an error in the conversion
-