java.lang.Object
javax.swing.JFormattedTextField.AbstractFormatter
javax.swing.text.DefaultFormatter
com.inductiveautomation.factorypmi.application.components.util.RegExFormatter
All Implemented Interfaces:
Serializable, Cloneable

public class RegExFormatter extends DefaultFormatter
A regular expression based implementation of AbstractFormatter.
See Also:
  • Constructor Details

    • RegExFormatter

      public RegExFormatter()
    • RegExFormatter

      public RegExFormatter(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
    • RegExFormatter

      public RegExFormatter(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 Details

    • setPattern

      public void setPattern(String strPattern)
      Sets the pattern that will be used to determine if a value is legal.
    • 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.
    • setMatcher

      protected void setMatcher(Matcher matcher)
      Sets the Matcher used in the most recent test if a value is legal.
    • getMatcher

      protected Matcher getMatcher()
      Returns the Matcher from the most test.
    • 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