public class RegexFormatter extends DefaultFormatter
AbstractFormatter
.
From:
http://java.sun.com/products/jfc/tsc/articles/reftf/
Note: requires v1.4
Looks interessting but not yet used.Constructor and Description |
---|
RegexFormatter() |
RegexFormatter(Pattern pattern)
Creates a regular expression based
AbstractFormatter . |
RegexFormatter(String pattern)
Creates a regular expression based
AbstractFormatter . |
Modifier and Type | Method and Description |
---|---|
protected Matcher |
getMatcher()
Returns the
Matcher from the most test. |
Pattern |
getPattern()
Returns the
Pattern used to determine if a value is
legal. |
protected void |
setMatcher(Matcher matcher)
Sets the
Matcher used in the most recent test
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. |
clone, getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getNavigationFilter, getOverwriteMode, getValueClass, install, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClass, valueToString
getActions, getFormattedTextField, invalidEdit, setEditValid, uninstall
public RegexFormatter()
public RegexFormatter(String pattern) throws PatternSyntaxException
AbstractFormatter
.
pattern
specifies the regular expression that will
be used to determine if a value is legal.PatternSyntaxException
public RegexFormatter(Pattern pattern)
AbstractFormatter
.
pattern
specifies the regular expression that will
be used to determine if a value is legal.public void setPattern(Pattern pattern)
public Pattern getPattern()
Pattern
used to determine if a value is
legal.protected void setMatcher(Matcher matcher)
Matcher
used in the most recent test
if a value is legal.protected Matcher getMatcher()
Matcher
from the most test.public Object stringToValue(String text) throws ParseException
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
.
stringToValue
in class DefaultFormatter
text
- String to convertParseException
- if there is an error in the conversionCopyright © 2002–2016 SoftSmithy. All rights reserved.