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 MatcherReturns theMatcherfrom the most test.Returns thePatternused to determine if a value is legal.protected voidsetMatcher(Matcher matcher) Sets theMatcherused in the most recent test if a value is legal.voidsetPattern(String strPattern) Sets the pattern that will be used to determine if a value is legal.voidsetPattern(Pattern pattern) Sets the pattern that will be used to determine if a value is legal.stringToValue(String text) Parsestextreturning an arbitrary Object.Methods inherited from class javax.swing.text.DefaultFormatter
clone, getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getNavigationFilter, getOverwriteMode, getValueClass, install, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClass, valueToStringMethods inherited from class javax.swing.JFormattedTextField.AbstractFormatter
getActions, getFormattedTextField, invalidEdit, setEditValid, uninstall
-
Constructor Details
-
RegExFormatter
public RegExFormatter() -
RegExFormatter
Creates a regular expression basedAbstractFormatter.patternspecifies the regular expression that will be used to determine if a value is legal.- Throws:
PatternSyntaxException
-
RegExFormatter
Creates a regular expression basedAbstractFormatter.patternspecifies 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 thePatternused to determine if a value is legal. -
setMatcher
Sets theMatcherused in the most recent test if a value is legal. -
getMatcher
Returns theMatcherfrom the most test. -
stringToValue
Parsestextreturning an arbitrary Object. Some formatters may return null.If a
Patternhas been specified and the text completely matches the regular expression this will invokesetMatcher.- Overrides:
stringToValuein classDefaultFormatter- Parameters:
text- String to convert- Returns:
- Object representation of text
- Throws:
ParseException- if there is an error in the conversion
-