com.instantbank.component.lettertemplate.util
Class VariablesFormat

java.lang.Object
  |
  +--com.instantbank.component.lettertemplate.util.VariablesFormat

public class VariablesFormat
extends java.lang.Object

Formatter for variables values.

Author:
InstantBank (Rodrigo Lopez)

Inner Class Summary
(package private)  class VariablesFormat.IbNumberFormat
          Auxiliary class representing all number formatters.
(package private) static interface VariablesFormat.MakeUpFormat
          Interface establishing special make ups to the basic formated strings
(package private)  class VariablesFormat.Phone_MakeUp
          Formatter for Phone format.
(package private)  class VariablesFormat.Rounder
          Implementation of MakeUpFormat intended for formatting numbers (not SSN nor Phone)
(package private)  class VariablesFormat.SSN_MakeUp
          Formatter for SSN format.
 
Field Summary
static int[] dateFormatCode
          dateFormatCode
static java.lang.String[] dateFormatPattern
          Strings describing date formats.
(package private)  java.util.Hashtable dateFormatter
          Actual date formatters are stored here, next to their corresponding format codes.
(package private)  java.text.SimpleDateFormat dateParser
          The overall date parser.
static int DD_MMM_YYYY
          Code for format DD-MMM-YYYY
(package private)  Debug debug
           
static int MMMcwYYYY
          Code for format MMM, YYYY
static int MMMwDDcwYY
          Code for format MMM DD, YY
static int MMMwDDcwYYYY
          Code for format MMM DD, YYYY
static int MMsDDsYY
          Code for format MM/DD/YY
static int MMsDDsYYYY
          Code for format MM/DD/YYYY
static int N9999
          Code for format 9999
static int N9999p99
          Code for format 9999.99
static int N9c999
          Code for format 9,999
static int N9c999p99
          Code for format 9,999.99
static int Nd9c999p99
          Code for format $9,999.99
static int NdZcZZ9p99
          Code for format $Z,ZZ9.99
static int NPhone
          Code for format Phone
static int NSSN
          Code for format SSN
static int[] numberFormatCode
          Table of actual codes for Number Formats
(package private)  java.util.Hashtable numberFormatter
          Actual number formatters are stored here, next to their corresponding format codes.
(package private)  java.text.NumberFormat numberParser
          The overall number parser.
static int NZcZZ9
          Code for format Z,ZZ9
static int NZcZZ9_
          Code for format Z,ZZ9-
static int NZcZZ9p99
          Code for format Z,ZZ9.99
static int NZcZZ9p99_
          Code for format Z,ZZ9.99-
static int NZZ9p9999pc
          Code for format ZZ9.9999%
static int NZZ9p999pc
          Code for format ZZ9.999%
static int NZZZ9
          Code for format ZZZ9
static int NZZZ9_
          Code for format ZZZ9-
static int NZZZ9p99
          Code for format ZZZ9.99
(package private)  java.util.Locale uslocale
          Formats follow general conventions for the US.
static int YYYYsMMsDD
          Code for format YYYY/MM/DD
 
Constructor Summary
VariablesFormat()
          VariablesFormat constructor.
 
Method Summary
private  java.text.DecimalFormat baseFormatter(int formatNumber, java.lang.String pattern)
          Every number formattes is constructed over an object like this one.
private  VariablesFormat.IbNumberFormat buildNumberFormatter(int formatNumber)
          Delivers the number formatters.
 java.lang.String format(java.lang.String varValue, java.lang.Long fmtCode)
          Formats a string of chars according to a format.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

uslocale

java.util.Locale uslocale
Formats follow general conventions for the US.

N9999

public static final int N9999
Code for format 9999

NZZZ9

public static final int NZZZ9
Code for format ZZZ9

NZcZZ9

public static final int NZcZZ9
Code for format Z,ZZ9

NZZZ9_

public static final int NZZZ9_
Code for format ZZZ9-

NZcZZ9_

public static final int NZcZZ9_
Code for format Z,ZZ9-

NZcZZ9p99_

public static final int NZcZZ9p99_
Code for format Z,ZZ9.99-

NZZ9p999pc

public static final int NZZ9p999pc
Code for format ZZ9.999%

NZZ9p9999pc

public static final int NZZ9p9999pc
Code for format ZZ9.9999%

N9999p99

public static final int N9999p99
Code for format 9999.99

NZZZ9p99

public static final int NZZZ9p99
Code for format ZZZ9.99

N9c999

public static final int N9c999
Code for format 9,999

N9c999p99

public static final int N9c999p99
Code for format 9,999.99

NZcZZ9p99

public static final int NZcZZ9p99
Code for format Z,ZZ9.99

Nd9c999p99

public static final int Nd9c999p99
Code for format $9,999.99

NdZcZZ9p99

public static final int NdZcZZ9p99
Code for format $Z,ZZ9.99

NSSN

public static final int NSSN
Code for format SSN

NPhone

public static final int NPhone
Code for format Phone

numberFormatCode

public static final int[] numberFormatCode
Table of actual codes for Number Formats

MMsDDsYY

public static final int MMsDDsYY
Code for format MM/DD/YY

MMsDDsYYYY

public static final int MMsDDsYYYY
Code for format MM/DD/YYYY

YYYYsMMsDD

public static final int YYYYsMMsDD
Code for format YYYY/MM/DD

DD_MMM_YYYY

public static final int DD_MMM_YYYY
Code for format DD-MMM-YYYY

MMMwDDcwYY

public static final int MMMwDDcwYY
Code for format MMM DD, YY

MMMwDDcwYYYY

public static final int MMMwDDcwYYYY
Code for format MMM DD, YYYY

MMMcwYYYY

public static final int MMMcwYYYY
Code for format MMM, YYYY

dateFormatCode

public static final int[] dateFormatCode
dateFormatCode

dateFormatPattern

public static final java.lang.String[] dateFormatPattern
Strings describing date formats.

dateFormatter

java.util.Hashtable dateFormatter
Actual date formatters are stored here, next to their corresponding format codes.

numberFormatter

java.util.Hashtable numberFormatter
Actual number formatters are stored here, next to their corresponding format codes.

numberParser

java.text.NumberFormat numberParser
The overall number parser. It is used just before formatting numbers.

dateParser

java.text.SimpleDateFormat dateParser
The overall date parser. It is used just before formatting a date.

debug

Debug debug
Constructor Detail

VariablesFormat

public VariablesFormat()
VariablesFormat constructor. Initiates dateParser and numberParser. It also creates the formatters corresponding to all formats.
Method Detail

baseFormatter

private java.text.DecimalFormat baseFormatter(int formatNumber,
                                              java.lang.String pattern)
Every number formattes is constructed over an object like this one.
Parameters:
formatNumber - Format code.
pattern - Format pattern
Returns:
DecimalFormat

buildNumberFormatter

private VariablesFormat.IbNumberFormat buildNumberFormatter(int formatNumber)
Delivers the number formatters. It is implemented as a large "switch" on formatNumber.
Parameters:
formatNumber - Format code
Returns:
The constructed formatter for the formatNumber code.

format

public java.lang.String format(java.lang.String varValue,
                               java.lang.Long fmtCode)
Formats a string of chars according to a format.
Parameters:
varValue - The string to be formated.
fmtCode - The format code.
Returns:
The formatted string or "-----/--/--" if a date formatting fails or "#########" if a number formatting fails. The string to be formated is returned if it only contains whitespaces.