IMC Epclient 5.0.3

at.spardat.enterprise.fmt
Class IFmt

java.lang.Object
  extended byat.spardat.enterprise.fmt.IFmt
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
ABcdFmt, ADateFmt, AStringFmt, ATimeStampFmt

public abstract class IFmt
extends java.lang.Object
implements java.lang.Cloneable

IFmt objects are responsible for converting an internal string encoding of a particular AtomicAttrVal type to an UI encoding and vice versa.


Field Summary
static int DEFAULT
          May be used in subclasses where ever a style is needed.
static int LAST_STYLE
          For subclasses which should start their style numbering at LAST_STYLE*2;
static int MANDATORY
          Used to express that any provided external input must not be empty.
protected  int style_
          Style-field that may also be used by subclasses.
 
Constructor Summary
IFmt()
           
 
Method Summary
 void checkMandatory(java.lang.String internal)
          Utility method to check a provided String for emptyness if the MANDATORY style is present.
 java.lang.Object clone()
          Returns a clone of this;
abstract  java.lang.String format(java.lang.String internal)
          Transforms an internal encoding to an external.
 int getStyle()
          Returns the style-property.
abstract  boolean isLegalExternalChar(char aChar)
          Examines whether a given character may be part of an external representation.
abstract  boolean isLegalInternal(java.lang.String internal)
          Determines if the given string is a legal internal representation.
 boolean isMandatory()
          Returns true, if this formatter only accepts non-empty input.
abstract  boolean isOneWay()
          An IFmt is one way, if the external encoding may be generated out of the internal, but not vice versa.
abstract  int maxLenOfExternal()
          Returns the maximum length an external string representation may have.
abstract  boolean mayBeAppliedTo(byte type)
          Defines if this formatter is able to successfully format a specified type.
abstract  java.lang.String parse(java.lang.String external)
          Tries to transform an external encoding to an internal.
 void setMandatory(boolean what)
          Sets the mandatory-property to the provided value.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static final int DEFAULT
May be used in subclasses where ever a style is needed.

See Also:
Constant Field Values

MANDATORY

public static final int MANDATORY
Used to express that any provided external input must not be empty. Method parse throws an exception if empty input is provided.

See Also:
Constant Field Values

LAST_STYLE

public static final int LAST_STYLE
For subclasses which should start their style numbering at LAST_STYLE*2;

See Also:
Constant Field Values

style_

protected int style_
Style-field that may also be used by subclasses. Within this class, only the style MANDATORY is known.

Constructor Detail

IFmt

public IFmt()
Method Detail

parse

public abstract java.lang.String parse(java.lang.String external)
                                throws AParseException
Tries to transform an external encoding to an internal. Must not be called if isOneWay() yields true.

Parameters:
external - the external encoding
Returns:
the internal encoding. May be the empty String, but never is null.
Throws:
AParseException - if the external encoding cannot be successfully parsed.

format

public abstract java.lang.String format(java.lang.String internal)
Transforms an internal encoding to an external.

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.

maxLenOfExternal

public abstract int maxLenOfExternal()
Returns the maximum length an external string representation may have.

Returns:
the maximum length or -1 if there is no known maximum.

isLegalExternalChar

public abstract boolean isLegalExternalChar(char aChar)
Examines whether a given character may be part of an external representation.

Parameters:
aChar - the character to check
Returns:
boolean if the character may be part of an external rep.

isLegalInternal

public abstract boolean isLegalInternal(java.lang.String internal)
Determines if the given string is a legal internal representation.

Parameters:
internal - the internal encoding.
Returns:
whether the provided string follows a legal internal encoding.

isOneWay

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

Returns:
true, if format may be called, but parse not.

mayBeAppliedTo

public abstract boolean mayBeAppliedTo(byte type)
Defines if this formatter is able to successfully format a specified type.

Parameters:
type - a type constant defined in Types.

isMandatory

public boolean isMandatory()
Returns true, if this formatter only accepts non-empty input.


setMandatory

public void setMandatory(boolean what)
Sets the mandatory-property to the provided value. Mandatory indicates that empty values are not accepted by this formatter.


getStyle

public int getStyle()
Returns the style-property. May be used to check if a particular style-bit is set, e.g., if((getStyle() & SOMESTYLE) != 0) ....


checkMandatory

public void checkMandatory(java.lang.String internal)
                    throws AParseException
Utility method to check a provided String for emptyness if the MANDATORY style is present.

Throws:
AParseException - if isMandatory() and the provided String is either null or empty.

clone

public java.lang.Object clone()
Returns a clone of this;


IMC Epclient 5.0.3