IMC Epclient 5.0.3

at.spardat.enterprise.fmt
Class ADateFmtMediumSmart

java.lang.Object
  extended byat.spardat.enterprise.fmt.IFmt
      extended byat.spardat.enterprise.fmt.ADateFmt
          extended byat.spardat.enterprise.fmt.ADateFmtMediumSmart
All Implemented Interfaces:
java.lang.Cloneable

public class ADateFmtMediumSmart
extends ADateFmt
implements java.lang.Cloneable

This class is a high speed implementation for parsing and formatting dates, like the MEDIUM format of DateFormat. A very restricted set of patterns is allowed. A pattern is a sequence of the following:

 d1 ... represents a day component without leading zero
 d2 ... represents a two digits day component
 m1 ... represents a month component witout leading zero
 m2 ... represents a two digits month component
 y2 ... represents a two digit year component
 y4 ... represents a four digit year component
 
Other characters must be used to delimit the components, as long as they do not start with d, m or y. A typical pattern for the austrian local may be "d2.m2.y4". The pattern must consist of exactly one d, one m and one y component. The components must be separated by delimiters. Therefore, a pattern "d2m2y4" is illegal.


Field Summary
protected  int twoDigitYearOffset_
           
 
Fields inherited from class at.spardat.enterprise.fmt.ADateFmt
FULL, LONG, MEDIUM, SHORT
 
Fields inherited from class at.spardat.enterprise.fmt.IFmt
DEFAULT, LAST_STYLE, MANDATORY, style_
 
Constructor Summary
protected ADateFmtMediumSmart(java.lang.String pattern, int style)
          Constructs using a pattern as defined in the class header.
 
Method Summary
 java.lang.String format(java.lang.String internal)
          Transforms an internal encoding to an external.
 java.lang.String getPattern()
          Returns the pattern set.
 boolean isLegalExternalChar(char aChar)
          Examines whether a given character may be part of an external 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.
 java.lang.String parse(java.lang.String external)
          The parse method accepts the following inputs: '0' ... zero stands for today '[-+] number' ... a signed number stands for today plus/minus the provided number of days.
 void setPattern(java.lang.String pattern)
          Sets the pattern as defined in the class header.
 
Methods inherited from class at.spardat.enterprise.fmt.ADateFmt
checkDateRange, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getMax, getMaxDate, getMin, getMinDate, isLegalInternal, mayBeAppliedTo, setMax, setMaxDate, setMin, setMinDate
 
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

twoDigitYearOffset_

protected int twoDigitYearOffset_
Constructor Detail

ADateFmtMediumSmart

protected ADateFmtMediumSmart(java.lang.String pattern,
                              int style)
Constructs using a pattern as defined in the class header.

Parameters:
pattern - the pattern used
style - may be MANDATORY
Throws:
java.lang.RuntimeException - on wrong patterns.
Method Detail

setPattern

public void setPattern(java.lang.String pattern)
Sets the pattern as defined in the class header.

Parameters:
pattern - the pattern to set
Throws:
java.lang.RuntimeException - on wrong patterns

getPattern

public java.lang.String getPattern()
Returns the pattern set.


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)

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)

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()

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()

parse

public java.lang.String parse(java.lang.String external)
                       throws AParseException
The parse method accepts the following inputs: The separators between the numbers need not match the separators provided in the patterns.

Some rules apply to parsing the year component. If this componenent consists of at least 3 digits, it is taken as year itself, i.e., 002 means the year 0002. If the year component consists of 2 or 1 digit(s), it is thought of a year without century and a century using a sliding window approach is set down. The century is fixed in a way that the resulting year lies in the interval (currentYear+twoDigitYearOffset_, currentYear+twoDigitYearOffset_+100]

Specified by:
parse in class IFmt
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.
See Also:
IFmt.parse(String)

IMC Epclient 5.0.3