at.spardat.enterprise.fmt
Class AStringFmtRangeRegEx
java.lang.Object
at.spardat.enterprise.fmt.IFmt
at.spardat.enterprise.fmt.AStringFmt
at.spardat.enterprise.fmt.AStringFmtRange
at.spardat.enterprise.fmt.AStringFmtRangeRegEx
- All Implemented Interfaces:
- java.lang.Cloneable
- public class AStringFmtRangeRegEx
- extends AStringFmtRange
A formatter based at java.util.regex.
This class defines a string formatter which accepts, min and max lenght,
valid range of allowed characters, style 'mandatory' and a regular expression
pattern which is validated.
This class is extended from AStringFmtRange, see there for the definition of valid characters (the range).
Additional the input is validated by a regular expression pattern, for this the
java.util.regex classes are used, see there for regular expression usage.
For the error message shown in the case of a negative evaluation of the regular expression
an resource bundle and key have to be specified.
The class FmtFactory (used by the XMA GUI Designer) constructs a AStringFmtRangeRegEx
from a String like this:
sre,(minLen),(maxLen),(range),(m&ul&lc),bundleKey,resBundle,regex
The values in brackets can be empty strings, all commas are mandatory.
An example for email validation:
"sre,,15,a-e@.,m,NoEmail,at.spardat.enterprise.fmt.test.FmtTestErrors,\\w+(\\.\\w+)*@\\w+\\.\\w+"
- Since:
- version_number
- Author:
- s3460
|
Constructor Summary |
AStringFmtRangeRegEx(int maxLen,
java.lang.String range,
int style,
java.lang.String regex,
java.lang.String bundleKey,
java.lang.String resBundle)
Returns a String formatter to limit the input length, the range of valid characters
and a regular expression (according to the java.util.regex packet) against which the input is vlaidated. |
AStringFmtRangeRegEx(int maxLen,
java.lang.String range,
java.lang.String regex,
java.lang.String bundleKey,
java.lang.String resBundle)
Returns a String formatter to limit the input length, the range of valid characters
and a regular expression (according to the java.util.regex packet) against which the input is vlaidated. |
|
Method Summary |
boolean |
isLegalExternalChar(char aChar)
Examines whether a given character may be part of an external representation. |
java.lang.String |
parse(java.lang.String external)
Tries to transform an external encoding to an internal. |
| Methods inherited from class at.spardat.enterprise.fmt.AStringFmt |
format, getInstance, getInstance, getInstance, getInstance, getInstance, getMaxLen, getMinLen, isOneWay, maxLenOfExternal, mayBeAppliedTo, parse2, setMaxLen, setMinLen |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AStringFmtRangeRegEx
public AStringFmtRangeRegEx(int maxLen,
java.lang.String range,
int style,
java.lang.String regex,
java.lang.String bundleKey,
java.lang.String resBundle)
- Returns a String formatter to limit the input length, the range of valid characters
and a regular expression (according to the java.util.regex packet) against which the input is vlaidated.
- Parameters:
maxLen - the maximum length of an accepted string. May be -1, then
the length is unlimited.range - a string denoting one or more character ranges.
See AStringFmtRange for a syntax description.style - may be MANDATORY which forces the input not be empty or
UPPER_CASE or LOWER_CASE.regex - a regular expression according to the java.util.regex packet.
The input string is validated agianst this expression.bundleKey - the resource bundle key of the error message,
which is shown in the case of a negative evalution of the regular expression.resBundle - the resource bundle name (without locale) from which the error message
for negative evalution of the regular expression is taken.
AStringFmtRangeRegEx
public AStringFmtRangeRegEx(int maxLen,
java.lang.String range,
java.lang.String regex,
java.lang.String bundleKey,
java.lang.String resBundle)
- Returns a String formatter to limit the input length, the range of valid characters
and a regular expression (according to the java.util.regex packet) against which the input is vlaidated.
- Parameters:
maxLen - the maximum length of an accepted string. May be -1, then
the length is unlimited.range - a string denoting one or more character ranges.
See AStringFmtRange for a syntax description. *regex - a regular expression according to the java.util.regex packet.
The input string is validated agianst this expression.bundleKey - the resource bundle key of the error message,
which is shown in the case of a negative evalution of the regular expression.resBundle - the resource bundle name from which the error message
for negative evalution of the regular expression is taken.
isLegalExternalChar
public boolean isLegalExternalChar(char aChar)
- Description copied from class:
IFmt
- Examines whether a given character may be part of an external representation.
- Overrides:
isLegalExternalChar in class AStringFmtRange
- See Also:
IFmt.isLegalExternalChar(char)
parse
public java.lang.String parse(java.lang.String external)
throws FmtParseException
- Description copied from class:
IFmt
- Tries to transform an external encoding to an internal. Must not be called if
isOneWay() yields true.
- Overrides:
parse in class AStringFmtRange
- Throws:
FmtParseException- See Also:
IFmt.parse(String)