IMC Epclient 5.0.3

at.spardat.enterprise.fmt
Class AStringFmt

java.lang.Object
  extended byat.spardat.enterprise.fmt.IFmt
      extended byat.spardat.enterprise.fmt.AStringFmt
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
AStringFmtRange

public class AStringFmt
extends IFmt

A formatter to validate the length and char set in strings.


Field Summary
static int LOWER_CASE
          Defines that this formatter makes all characters lowercase using the method Character.
static int MAX_MAX_LEN
          Defines an upper bound on a specified maximum length.
static int UPPER_CASE
          Defines that this formatter makes all characters uppercase
 
Fields inherited from class at.spardat.enterprise.fmt.IFmt
DEFAULT, LAST_STYLE, MANDATORY, style_
 
Constructor Summary
AStringFmt(int maxLen)
          Constructs a length limited String formatter.
AStringFmt(int maxLen, int style)
          Constructs a length limited String formatter.
 
Method Summary
 java.lang.String format(java.lang.String internal)
          Transforms an internal encoding to an external.
static AStringFmt getInstance(int maxLen)
          Returns a String formatter to limit the input length.
static AStringFmt getInstance(int maxLen, int style)
          Returns a String formatter to limit the input length.
static AStringFmt getInstance(int maxLen, java.lang.String range)
          Returns a String formatter to limit the input length.
static AStringFmt getInstance(int maxLen, java.lang.String range, int style)
          Returns a String formatter to limit the input length.
static AStringFmt getInstance(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) for input validation.
 int getMaxLen()
          Returns the maximum length a string accepted by this formatter may have.
 int getMinLen()
          Returns the minimum length.
 boolean isLegalExternalChar(char aChar)
          Examines whether a given character may be part of an external representation.
 boolean isLegalInternal(java.lang.String internal)
          Determines if the given string is a legal internal representation.
 boolean isOneWay()
          An IFmt is one way, if the external encoding may be generated out of the internal, but not vice versa.
 int maxLenOfExternal()
          Returns the maximum length an external string representation may have.
 boolean mayBeAppliedTo(byte type)
          Defines if this formatter is able to successfully format a specified type.
 java.lang.String parse(java.lang.String external)
          Tries to transform an external encoding to an internal.
 java.lang.String parse2(java.lang.String external)
          Does the parse without the mandatory-check
 void setMaxLen(int maxLen)
          Sets the maximum string length this formatter accepts.
 void setMinLen(int minLen)
          Sets the minimum length a string accepted must have.
 
Methods inherited from class at.spardat.enterprise.fmt.IFmt
checkMandatory, clone, getStyle, isMandatory, setMandatory
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UPPER_CASE

public static final int UPPER_CASE
Defines that this formatter makes all characters uppercase

See Also:
Constant Field Values

LOWER_CASE

public static final int LOWER_CASE
Defines that this formatter makes all characters lowercase using the method Character.

See Also:
Constant Field Values

MAX_MAX_LEN

public static final int MAX_MAX_LEN
Defines an upper bound on a specified maximum length. If you specify -1 (unlimited) for the maximum length in the constructor, the maximum length is set to this constant.

See Also:
Constant Field Values
Constructor Detail

AStringFmt

public AStringFmt(int maxLen)
Constructs a length limited String formatter.

Parameters:
maxLen - the maximum length of an accepted string. May be -1, then the length is unlimited.

AStringFmt

public AStringFmt(int maxLen,
                  int style)
Constructs a length limited String formatter.

Parameters:
maxLen - the maximum length of an accepted string or -1, if no length limitation should be imposed.
style - may be MANDATORY.
Method Detail

getInstance

public static AStringFmt getInstance(int maxLen)
Returns a String formatter to limit the input length.

Parameters:
maxLen - the maximum length of an accepted string. May be -1, then the length is unlimited.

getInstance

public static AStringFmt getInstance(int maxLen,
                                     int style)
Returns a String formatter to limit the input length.

Parameters:
maxLen - the maximum length of an accepted string. May be -1, then the length is unlimited.
style - may be MANDATORY which forces the input not to be empty or UPPER_CASE or LOWER_CASE.

getInstance

public static AStringFmt getInstance(int maxLen,
                                     java.lang.String range)
Returns a String formatter to limit the input length.

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.

getInstance

public static AStringFmt getInstance(int maxLen,
                                     java.lang.String range,
                                     int style)
Returns a String formatter to limit the input length.

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.

getInstance

public static AStringFmt getInstance(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) for input validation.

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 by 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.

setMaxLen

public void setMaxLen(int maxLen)
Sets the maximum string length this formatter accepts.

Parameters:
maxLen - the maximum length of an accepted string. May be -1, then the length is unlimited (theoretically), but practically set to MAX_MAX_LEN.

getMaxLen

public int getMaxLen()
Returns the maximum length a string accepted by this formatter may have.

Returns:
max number of characters. Returns MAX_MAX_LEN if you have set an unlimited maximum size.

setMinLen

public void setMinLen(int minLen)
Sets the minimum length a string accepted must have. Note that this does not control if a empty string is allowed or not. For this purpose, use the MANDATORY-style. A AStringFmt with a minLen of 5 does accept strings of length 0 and greater than or equal to 5 if MANDATORY is not set.


getMinLen

public int getMinLen()
Returns the minimum length.


parse

public java.lang.String parse(java.lang.String external)
Description copied from class: IFmt
Tries to transform an external encoding to an internal. Must not be called if isOneWay() yields true.

Specified by:
parse in class IFmt
Parameters:
external - the external encoding
Returns:
the internal encoding. May be the empty String, but never is null.
See Also:
IFmt.parse(String)

parse2

public java.lang.String parse2(java.lang.String external)
Does the parse without the mandatory-check


format

public java.lang.String format(java.lang.String internal)
Description copied from class: IFmt
Transforms an internal encoding to an external.

Specified by:
format in class IFmt
Parameters:
internal - the provided internal encoding. This String must satisfy the condition isLegalInternal(), otherwise the behaviour of this method is undefined.
Returns:
the external representation. May be the empty string, but is never null.
See Also:
IFmt.format(String)

maxLenOfExternal

public int maxLenOfExternal()
Description copied from class: IFmt
Returns the maximum length an external string representation may have.

Specified by:
maxLenOfExternal in class IFmt
Returns:
the maximum length or -1 if there is no known maximum.
See Also:
IFmt.maxLenOfExternal()

isLegalExternalChar

public boolean isLegalExternalChar(char aChar)
Description copied from class: IFmt
Examines whether a given character may be part of an external representation.

Specified by:
isLegalExternalChar in class IFmt
Parameters:
aChar - the character to check
Returns:
boolean if the character may be part of an external rep.
See Also:
IFmt.isLegalExternalChar(char)

isLegalInternal

public boolean isLegalInternal(java.lang.String internal)
Description copied from class: IFmt
Determines if the given string is a legal internal representation.

Specified by:
isLegalInternal in class IFmt
Parameters:
internal - the internal encoding.
Returns:
whether the provided string follows a legal internal encoding.
See Also:
IFmt.isLegalInternal(String)

isOneWay

public boolean isOneWay()
Description copied from class: IFmt
An IFmt is one way, if the external encoding may be generated out of the internal, but not vice versa.

Specified by:
isOneWay in class IFmt
Returns:
true, if format may be called, but parse not.
See Also:
IFmt.isOneWay()

mayBeAppliedTo

public boolean mayBeAppliedTo(byte type)
Description copied from class: IFmt
Defines if this formatter is able to successfully format a specified type.

Specified by:
mayBeAppliedTo in class IFmt
Parameters:
type - a type constant defined in Types.
See Also:
IFmt.mayBeAppliedTo(byte)

IMC Epclient 5.0.3