forked from geodmms/xdgnjobs

?? ?
2008-06-09 bd210ee7438fd203c19d3e8080ea12b79fe56159
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/PrintfFormat.java
@@ -90,7 +90,7 @@
 * In format strings containing the %<code>n</code>$
 * form of conversion specifications, each argument
 * in the argument list is used exactly once.</p>
 *
 * <p/>
 * <h4>Escape Sequences</h4>
 * <p>
 * The following table lists escape sequences and
@@ -98,40 +98,40 @@
 * the action.
 * <table>
 * <tr><th align=left>Sequence</th>
 *    <th align=left>Name</th>
 *    <th align=left>Description</th></tr>
 * <th align=left>Name</th>
 * <th align=left>Description</th></tr>
 * <tr><td>\\</td><td>backlash</td><td>None.
 * </td></tr>
 * <tr><td>\a</td><td>alert</td><td>Attempts to alert
 *          the user through audible or visible
 *          notification.
 * the user through audible or visible
 * notification.
 * </td></tr>
 * <tr><td>\b</td><td>backspace</td><td>Moves the
 *          printing position to one column before
 *          the current position, unless the
 *          current position is the start of a line.
 * printing position to one column before
 * the current position, unless the
 * current position is the start of a line.
 * </td></tr>
 * <tr><td>\f</td><td>form-feed</td><td>Moves the
 *          printing position to the initial
 *          printing position of the next logical
 *          page.
 * printing position to the initial
 * printing position of the next logical
 * page.
 * </td></tr>
 * <tr><td>\n</td><td>newline</td><td>Moves the
 *          printing position to the start of the
 *          next line.
 * printing position to the start of the
 * next line.
 * </td></tr>
 * <tr><td>\r</td><td>carriage-return</td><td>Moves
 *          the printing position to the start of
 *          the current line.
 * the printing position to the start of
 * the current line.
 * </td></tr>
 * <tr><td>\t</td><td>tab</td><td>Moves the printing
 *          position to the next implementation-
 *          defined horizontal tab position.
 * position to the next implementation-
 * defined horizontal tab position.
 * </td></tr>
 * <tr><td>\v</td><td>vertical-tab</td><td>Moves the
 *          printing position to the start of the
 *          next implementation-defined vertical
 *          tab position.
 * printing position to the start of the
 * next implementation-defined vertical
 * tab position.
 * </td></tr>
 * </table></p>
 * <h4>Conversion Specifications</h4>
@@ -206,55 +206,55 @@
 * be mixed with the %<code>n</code>$ form.  The
 * results of mixing numbered and unnumbered argument
 * specifications in a format string are undefined.</p>
 *
 * <p/>
 * <h4>Flag Characters</h4>
 * <p>
 * The flags and their meanings are:</p>
 * <dl>
 * <dt>'<dd> integer portion of the result of a
 *      decimal conversion (%i, %d, %f, %g, or %G) will
 *      be formatted with thousands' grouping
 *      characters.  For other conversions the flag
 *      is ignored.  The non-monetary grouping
 *      character is used.
 * decimal conversion (%i, %d, %f, %g, or %G) will
 * be formatted with thousands' grouping
 * characters.  For other conversions the flag
 * is ignored.  The non-monetary grouping
 * character is used.
 * <dt>-<dd> result of the conversion is left-justified
 *      within the field.  (It will be right-justified
 *      if this flag is not specified).</td></tr>
 * within the field.  (It will be right-justified
 * if this flag is not specified).</td></tr>
 * <dt>+<dd> result of a signed conversion always
 *      begins with a sign (+ or -).  (It will begin
 *      with a sign only when a negative value is
 *      converted if this flag is not specified.)
 * begins with a sign (+ or -).  (It will begin
 * with a sign only when a negative value is
 * converted if this flag is not specified.)
 * <dt>&lt;space&gt;<dd> If the first character of a
 *      signed conversion is not a sign, a space
 *      character will be placed before the result.
 *      This means that if the space character and +
 *      flags both appear, the space flag will be
 *      ignored.
 * signed conversion is not a sign, a space
 * character will be placed before the result.
 * This means that if the space character and +
 * flags both appear, the space flag will be
 * ignored.
 * <dt>#<dd> value is to be converted to an alternative
 *      form.  For c, d, i, and s conversions, the flag
 *      has no effect.  For o conversion, it increases
 *      the precision to force the first digit of the
 *      result to be a zero.  For x or X conversion, a
 *      non-zero result has 0x or 0X prefixed to it,
 *      respectively.  For e, E, f, g, and G
 *      conversions, the result always contains a radix
 *      character, even if no digits follow the radix
 *      character (normally, a decimal point appears in
 *      the result of these conversions only if a digit
 *      follows it).  For g and G conversions, trailing
 *      zeros will not be removed from the result as
 *      they normally are.
 * form.  For c, d, i, and s conversions, the flag
 * has no effect.  For o conversion, it increases
 * the precision to force the first digit of the
 * result to be a zero.  For x or X conversion, a
 * non-zero result has 0x or 0X prefixed to it,
 * respectively.  For e, E, f, g, and G
 * conversions, the result always contains a radix
 * character, even if no digits follow the radix
 * character (normally, a decimal point appears in
 * the result of these conversions only if a digit
 * follows it).  For g and G conversions, trailing
 * zeros will not be removed from the result as
 * they normally are.
 * <dt>0<dd> d, i, o, x, X, e, E, f, g, and G
 *      conversions, leading zeros (following any
 *      indication of sign or base) are used to pad to
 *      the field width;  no space padding is
 *      performed.  If the 0 and - flags both appear,
 *      the 0 flag is ignored.  For d, i, o, x, and X
 *      conversions, if a precision is specified, the
 *      0 flag will be ignored. For c conversions,
 *      the flag is ignored.
 * conversions, leading zeros (following any
 * indication of sign or base) are used to pad to
 * the field width;  no space padding is
 * performed.  If the 0 and - flags both appear,
 * the 0 flag is ignored.  For d, i, o, x, and X
 * conversions, if a precision is specified, the
 * 0 flag will be ignored. For c conversions,
 * the flag is ignored.
 * </dl>
 *
 * <p/>
 * <h4>Conversion Characters</h4>
 * <p>
 * Each conversion character results in fetching zero
@@ -263,103 +263,103 @@
 * Usually, an unchecked exception will be thrown.
 * If the format is exhausted while arguments remain,
 * the excess arguments are ignored.</p>
 *
 * <p/>
 * <p>
 * The conversion characters and their meanings are:
 * </p>
 * <dl>
 * <dt>d,i<dd>The int argument is converted to a
 *        signed decimal in the style [-]dddd.  The
 *        precision specifies the minimum number of
 *        digits to appear;  if the value being
 *        converted can be represented in fewer
 *        digits, it will be expanded with leading
 *        zeros.  The default precision is 1.  The
 *        result of converting 0 with an explicit
 *        precision of 0 is no characters.
 * signed decimal in the style [-]dddd.  The
 * precision specifies the minimum number of
 * digits to appear;  if the value being
 * converted can be represented in fewer
 * digits, it will be expanded with leading
 * zeros.  The default precision is 1.  The
 * result of converting 0 with an explicit
 * precision of 0 is no characters.
 * <dt>o<dd> The int argument is converted to unsigned
 *        octal format in the style ddddd.  The
 *        precision specifies the minimum number of
 *        digits to appear;  if the value being
 *        converted can be represented in fewer
 *        digits, it will be expanded with leading
 *        zeros.  The default precision is 1.  The
 *        result of converting 0 with an explicit
 *        precision of 0 is no characters.
 * octal format in the style ddddd.  The
 * precision specifies the minimum number of
 * digits to appear;  if the value being
 * converted can be represented in fewer
 * digits, it will be expanded with leading
 * zeros.  The default precision is 1.  The
 * result of converting 0 with an explicit
 * precision of 0 is no characters.
 * <dt>x<dd> The int argument is converted to unsigned
 *        hexadecimal format in the style dddd;  the
 *        letters abcdef are used.  The precision
 *        specifies the minimum numberof digits to
 *        appear; if the value being converted can be
 *        represented in fewer digits, it will be
 *        expanded with leading zeros.  The default
 *        precision is 1.  The result of converting 0
 *        with an explicit precision of 0 is no
 *        characters.
 * hexadecimal format in the style dddd;  the
 * letters abcdef are used.  The precision
 * specifies the minimum numberof digits to
 * appear; if the value being converted can be
 * represented in fewer digits, it will be
 * expanded with leading zeros.  The default
 * precision is 1.  The result of converting 0
 * with an explicit precision of 0 is no
 * characters.
 * <dt>X<dd> Behaves the same as the x conversion
 *        character except that letters ABCDEF are
 *        used instead of abcdef.
 * character except that letters ABCDEF are
 * used instead of abcdef.
 * <dt>f<dd> The floating point number argument is
 *        written in decimal notation in the style
 *        [-]ddd.ddd, where the number of digits after
 *        the radix character (shown here as a decimal
 *        point) is equal to the precision
 *        specification.  A Locale is used to determine
 *        the radix character to use in this format.
 *        If the precision is omitted from the
 *        argument, six digits are written after the
 *        radix character;  if the precision is
 *        explicitly 0 and the # flag is not specified,
 *        no radix character appears.  If a radix
 *        character appears, at least 1 digit appears
 *        before it.  The value is rounded to the
 *        appropriate number of digits.
 * written in decimal notation in the style
 * [-]ddd.ddd, where the number of digits after
 * the radix character (shown here as a decimal
 * point) is equal to the precision
 * specification.  A Locale is used to determine
 * the radix character to use in this format.
 * If the precision is omitted from the
 * argument, six digits are written after the
 * radix character;  if the precision is
 * explicitly 0 and the # flag is not specified,
 * no radix character appears.  If a radix
 * character appears, at least 1 digit appears
 * before it.  The value is rounded to the
 * appropriate number of digits.
 * <dt>e,E<dd>The floating point number argument is
 *        written in the style [-]d.ddde{+-}dd
 *        (the symbols {+-} indicate either a plus or
 *        minus sign), where there is one digit before
 *        the radix character (shown here as a decimal
 *        point) and the number of digits after it is
 *        equal to the precision.  A Locale is used to
 *        determine the radix character to use in this
 *        format.  When the precision is missing, six
 *        digits are written after the radix character;
 *        if the precision is 0 and the # flag is not
 *        specified, no radix character appears.  The
 *        E conversion will produce a number with E
 *        instead of e introducing the exponent.  The
 *        exponent always contains at least two digits.
 *        However, if the value to be written requires
 *        an exponent greater than two digits,
 *        additional exponent digits are written as
 *        necessary.  The value is rounded to the
 *        appropriate number of digits.
 * written in the style [-]d.ddde{+-}dd
 * (the symbols {+-} indicate either a plus or
 * minus sign), where there is one digit before
 * the radix character (shown here as a decimal
 * point) and the number of digits after it is
 * equal to the precision.  A Locale is used to
 * determine the radix character to use in this
 * format.  When the precision is missing, six
 * digits are written after the radix character;
 * if the precision is 0 and the # flag is not
 * specified, no radix character appears.  The
 * E conversion will produce a number with E
 * instead of e introducing the exponent.  The
 * exponent always contains at least two digits.
 * However, if the value to be written requires
 * an exponent greater than two digits,
 * additional exponent digits are written as
 * necessary.  The value is rounded to the
 * appropriate number of digits.
 * <dt>g,G<dd>The floating point number argument is
 *        written in style f or e (or in sytle E in the
 *        case of a G conversion character), with the
 *        precision specifying the number of
 *        significant digits.  If the precision is
 *        zero, it is taken as one.  The style used
 *        depends on the value converted:  style e
 *        (or E) will be used only if the exponent
 *        resulting from the conversion is less than
 *        -4 or greater than or equal to the precision.
 *        Trailing zeros are removed from the result.
 *        A radix character appears only if it is
 *        followed by a digit.
 * written in style f or e (or in sytle E in the
 * case of a G conversion character), with the
 * precision specifying the number of
 * significant digits.  If the precision is
 * zero, it is taken as one.  The style used
 * depends on the value converted:  style e
 * (or E) will be used only if the exponent
 * resulting from the conversion is less than
 * -4 or greater than or equal to the precision.
 * Trailing zeros are removed from the result.
 * A radix character appears only if it is
 * followed by a digit.
 * <dt>c,C<dd>The integer argument is converted to a
 *        char and the result is written.
 *
 * char and the result is written.
 * <p/>
 * <dt>s,S<dd>The argument is taken to be a string and
 *        bytes from the string are written until the
 *        end of the string or the number of bytes
 *        indicated by the precision specification of
 *        the argument is reached.  If the precision
 *        is omitted from the argument, it is taken to
 *        be infinite, so all characters up to the end
 *        of the string are written.
 * bytes from the string are written until the
 * end of the string or the number of bytes
 * indicated by the precision specification of
 * the argument is reached.  If the precision
 * is omitted from the argument, it is taken to
 * be infinite, so all characters up to the end
 * of the string are written.
 * <dt>%<dd>Write a % character;  no argument is
 *        converted.
 * converted.
 * </dl>
 * <p>
 * If a conversion specification does not match one of
@@ -431,25 +431,31 @@
 *
 * @author Allan Jacobs
 * @version 1
 * Release 1: Initial release.
 * Release 2: Asterisk field widths and precisions
 *            %n$ and *m$
 *            Bug fixes
 *              g format fix (2 digits in e form corrupt)
 *              rounding in f format implemented
 *              round up when digit not printed is 5
 *              formatting of -0.0f
 *              round up/down when last digits are 50000...
 *          Release 1: Initial release.
 *          Release 2: Asterisk field widths and precisions
 *          %n$ and *m$
 *          Bug fixes
 *          g format fix (2 digits in e form corrupt)
 *          rounding in f format implemented
 *          round up when digit not printed is 5
 *          formatting of -0.0f
 *          round up/down when last digits are 50000...
 */
public final class PrintfFormat
{
    /** Vector of control strings and format literals. */
    /**
     * Vector of control strings and format literals.
     */
    private Vector vFmt = new Vector();
    /** Character position.  Used by the constructor. */
    /**
     * Character position.  Used by the constructor.
     */
    private int cPos = 0;
    /** Character position.  Used by the constructor. */
    /**
     * Character position.  Used by the constructor.
     */
    private DecimalFormatSymbols dfs = null;
    /**
@@ -459,10 +465,11 @@
     * unpaired percent signs.  A pair of successive
     * percent signs designates a single percent sign in
     * the format.
     * @param fmtArg  Control string.
     * @exception IllegalArgumentException if the control
     * string is null, zero length, or otherwise
     * malformed.
     *
     * @param fmtArg Control string.
     * @throws IllegalArgumentException if the control
     *                                  string is null, zero length, or otherwise
     *                                  malformed.
     */
    public PrintfFormat(String fmtArg) throws IllegalArgumentException
    {
@@ -476,18 +483,19 @@
     * unpaired percent signs.  A pair of successive
     * percent signs designates a single percent sign in
     * the format.
     * @param fmtArg  Control string.
     * @exception IllegalArgumentException if the control
     * string is null, zero length, or otherwise
     * malformed.
     *
     * @param fmtArg Control string.
     * @throws IllegalArgumentException if the control
     *                                  string is null, zero length, or otherwise
     *                                  malformed.
     */
    public PrintfFormat(Locale locale, String fmtArg) throws IllegalArgumentException
    {
        dfs = new DecimalFormatSymbols(locale);
        int                     ePos = 0;
        int ePos = 0;
        ConversionSpecification sFmt = null;
        String                  unCS = this.nonControl(fmtArg, 0);
        String unCS = this.nonControl(fmtArg, 0);
        if (unCS != null)
        {
@@ -590,12 +598,13 @@
     * of the String <code>s</code>, the next unpaired
     * percent sign, or at the end of the String if the
     * last character is a percent sign.
     * @param s  Control string.
     *
     * @param s     Control string.
     * @param start Position in the string
     *     <code>s</code> to begin looking for the start
     *     of a control string.
     *              <code>s</code> to begin looking for the start
     *              of a control string.
     * @return the substring from the start position
     *     to the beginning of the control string.
     *         to the beginning of the control string.
     */
    private String nonControl(String s, int start)
    {
@@ -616,21 +625,22 @@
     * Integer, Long, Float, Double, and Character
     * arguments are treated as wrappers for primitive
     * types.
     *
     * @param o The array of objects to format.
     * @return  The formatted String.
     * @return The formatted String.
     */
    public String sprintf(Object[] o)
    {
        Enumeration             e  = vFmt.elements();
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char                    c  = 0;
        int                     i  = 0;
        StringBuffer            sb = new StringBuffer();
        char c = 0;
        int i = 0;
        StringBuffer sb = new StringBuffer();
        while (e.hasMoreElements())
        {
            cs = (ConversionSpecification) e.nextElement();
            c  = cs.getConversionCharacter();
            c = cs.getConversionCharacter();
            if (c == '\0')
            {
@@ -713,19 +723,20 @@
    /**
     * Format nothing.  Just use the control string.
     * @return  the formatted String.
     *
     * @return the formatted String.
     */
    public String sprintf()
    {
        Enumeration             e  = vFmt.elements();
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char                    c  = 0;
        StringBuffer            sb = new StringBuffer();
        char c = 0;
        StringBuffer sb = new StringBuffer();
        while (e.hasMoreElements())
        {
            cs = (ConversionSpecification) e.nextElement();
            c  = cs.getConversionCharacter();
            c = cs.getConversionCharacter();
            if (c == '\0')
            {
@@ -741,23 +752,24 @@
    /**
     * Format an int.
     *
     * @param x The int to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     *     conversion character is f, e, E, g, G, s,
     *     or S.
     * @return The formatted String.
     * @throws IllegalArgumentException if the
     *                                  conversion character is f, e, E, g, G, s,
     *                                  or S.
     */
    public String sprintf(int x) throws IllegalArgumentException
    {
        Enumeration             e  = vFmt.elements();
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char                    c  = 0;
        StringBuffer            sb = new StringBuffer();
        char c = 0;
        StringBuffer sb = new StringBuffer();
        while (e.hasMoreElements())
        {
            cs = (ConversionSpecification) e.nextElement();
            c  = cs.getConversionCharacter();
            c = cs.getConversionCharacter();
            if (c == '\0')
            {
@@ -776,23 +788,24 @@
    /**
     * Format an long.
     *
     * @param x The long to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     *     conversion character is f, e, E, g, G, s,
     *     or S.
     * @return The formatted String.
     * @throws IllegalArgumentException if the
     *                                  conversion character is f, e, E, g, G, s,
     *                                  or S.
     */
    public String sprintf(long x) throws IllegalArgumentException
    {
        Enumeration             e  = vFmt.elements();
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char                    c  = 0;
        StringBuffer            sb = new StringBuffer();
        char c = 0;
        StringBuffer sb = new StringBuffer();
        while (e.hasMoreElements())
        {
            cs = (ConversionSpecification) e.nextElement();
            c  = cs.getConversionCharacter();
            c = cs.getConversionCharacter();
            if (c == '\0')
            {
@@ -811,23 +824,24 @@
    /**
     * Format a double.
     *
     * @param x The double to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     *     conversion character is c, C, s, S,
     *     d, d, x, X, or o.
     * @return The formatted String.
     * @throws IllegalArgumentException if the
     *                                  conversion character is c, C, s, S,
     *                                  d, d, x, X, or o.
     */
    public String sprintf(double x) throws IllegalArgumentException
    {
        Enumeration             e  = vFmt.elements();
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char                    c  = 0;
        StringBuffer            sb = new StringBuffer();
        char c = 0;
        StringBuffer sb = new StringBuffer();
        while (e.hasMoreElements())
        {
            cs = (ConversionSpecification) e.nextElement();
            c  = cs.getConversionCharacter();
            c = cs.getConversionCharacter();
            if (c == '\0')
            {
@@ -846,22 +860,23 @@
    /**
     * Format a String.
     *
     * @param x The String to format.
     * @return  The formatted String.
     * @exception IllegalArgumentException if the
     *   conversion character is neither s nor S.
     * @return The formatted String.
     * @throws IllegalArgumentException if the
     *                                  conversion character is neither s nor S.
     */
    public String sprintf(String x) throws IllegalArgumentException
    {
        Enumeration             e  = vFmt.elements();
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char                    c  = 0;
        StringBuffer            sb = new StringBuffer();
        char c = 0;
        StringBuffer sb = new StringBuffer();
        while (e.hasMoreElements())
        {
            cs = (ConversionSpecification) e.nextElement();
            c  = cs.getConversionCharacter();
            c = cs.getConversionCharacter();
            if (c == '\0')
            {
@@ -885,23 +900,24 @@
     * Strings using an internal formatting method for
     * Strings. Otherwise use the default formatter
     * (use toString).
     *
     * @param x the Object to format.
     * @return  the formatted String.
     * @exception IllegalArgumentException if the
     *    conversion character is inappropriate for
     *    formatting an unwrapped value.
     * @return the formatted String.
     * @throws IllegalArgumentException if the
     *                                  conversion character is inappropriate for
     *                                  formatting an unwrapped value.
     */
    public String sprintf(Object x) throws IllegalArgumentException
    {
        Enumeration             e  = vFmt.elements();
        Enumeration e = vFmt.elements();
        ConversionSpecification cs = null;
        char                    c  = 0;
        StringBuffer            sb = new StringBuffer();
        char c = 0;
        StringBuffer sb = new StringBuffer();
        while (e.hasMoreElements())
        {
            cs = (ConversionSpecification) e.nextElement();
            c  = cs.getConversionCharacter();
            c = cs.getConversionCharacter();
            if (c == '\0')
            {
@@ -946,30 +962,30 @@
    }
    /**
     * <p>
     * <p/>
     * ConversionSpecification allows the formatting of
     * a single primitive or object embedded within a
     * string.  The formatting is controlled by a
     * format string.  Only one Java primitive or
     * object can be formatted at a time.
     * <p>
     * <p/>
     * A format string is a Java string that contains
     * a control string.  The control string starts at
     * the first percent sign (%) in the string,
     * provided that this percent sign
     * <ol>
     * <li>is not escaped protected by a matching % or
     *     is not an escape % character,
     * is not an escape % character,
     * <li>is not at the end of the format string, and
     * <li>precedes a sequence of characters that parses
     *     as a valid control string.
     * as a valid control string.
     * </ol>
     * <p>
     * <p/>
     * A control string takes the form:
     * <pre> % ['-+ #0]* [0..9]* { . [0..9]* }+
     *                { [hlL] }+ [idfgGoxXeEcs]
     * </pre>
     * <p>
     * <p/>
     * The behavior is like printf.  One (hopefully the
     * only) exception is that the minimum number of
     * exponent digits is 3 instead of 2 for e and E
@@ -980,7 +996,9 @@
     */
    private class ConversionSpecification
    {
        /** Default precision. */
        /**
         * Default precision.
         */
        private final static int defaultDigits = 6;
        /**
@@ -1051,7 +1069,7 @@
         * d, i, o, u, x, or X conversions.  The number of
         * digits to appear after the radix character for
         * the e, E, and f conversions.  The maximum number
         *  of significant digits for the g and G
         * of significant digits for the g and G
         * conversions.  The maximum number of bytes to be
         * printed from a string in s and S conversions.
         */
@@ -1070,12 +1088,12 @@
        /*
         */
        private boolean positionalSpecification       = false;
        private int     argumentPosition              = 0;
        private boolean positionalFieldWidth          = false;
        private int     argumentPositionForFieldWidth = 0;
        private boolean positionalPrecision           = false;
        private int     argumentPositionForPrecision  = 0;
        private boolean positionalSpecification = false;
        private int argumentPosition = 0;
        private boolean positionalFieldWidth = false;
        private int argumentPositionForFieldWidth = 0;
        private boolean positionalPrecision = false;
        private int argumentPositionForPrecision = 0;
        /**
         * Flag specifying that a following d, i, o, u, x,
@@ -1098,7 +1116,9 @@
         */
        private boolean optionalL = false;
        /** Control string type. */
        /**
         * Control string type.
         */
        private char conversionCharacter = '\0';
        /**
@@ -1107,7 +1127,9 @@
         */
        private int pos = 0;
        /** Literal or control format string. */
        /**
         * Literal or control format string.
         */
        private String fmt;
        /**
@@ -1123,11 +1145,12 @@
         * The argument must begin with a % and end
         * with the conversion character for the
         * conversion specification.
         *  @param fmtArg  String specifying the
         *     conversion specification.
         *  @exception IllegalArgumentException if the
         *     input string is null, zero length, or
         *     otherwise malformed.
         *
         * @param fmtArg String specifying the
         *               conversion specification.
         * @throws IllegalArgumentException if the
         *                                  input string is null, zero length, or
         *                                  otherwise malformed.
         */
        ConversionSpecification(String fmtArg) throws IllegalArgumentException
        {
@@ -1163,7 +1186,7 @@
                        if (precisionSet && leadingZeros)
                        {
                            if ((conversionCharacter == 'd') || (conversionCharacter == 'i') || (conversionCharacter == 'o')
                                || (conversionCharacter == 'x'))
                                    || (conversionCharacter == 'x'))
                            {
                                leadingZeros = false;
                            }
@@ -1184,6 +1207,7 @@
        /**
         * Set the String for this instance.
         *
         * @param s the String to store.
         */
        void setLiteral(String s)
@@ -1200,7 +1224,7 @@
        String getLiteral()
        {
            StringBuffer sb = new StringBuffer();
            int          i  = 0;
            int i = 0;
            while (i < fmt.length())
            {
@@ -1214,42 +1238,42 @@
                        switch (c)
                        {
                        case 'a' :
                        case 'a':
                            sb.append((char) 0x07);
                            break;
                        case 'b' :
                        case 'b':
                            sb.append('\b');
                            break;
                        case 'f' :
                        case 'f':
                            sb.append('\f');
                            break;
                        case 'n' :
                        case 'n':
                            sb.append(System.getProperty("line.separator"));
                            break;
                        case 'r' :
                        case 'r':
                            sb.append('\r');
                            break;
                        case 't' :
                        case 't':
                            sb.append('\t');
                            break;
                        case 'v' :
                        case 'v':
                            sb.append((char) 0x0b);
                            break;
                        case '\\' :
                        case '\\':
                            sb.append('\\');
                            break;
@@ -1284,9 +1308,10 @@
         * Check whether the specifier has a variable
         * field width that is going to be set by an
         * argument.
         *
         * @return <code>true</code> if the conversion
         *   uses an * field width; otherwise
         *   <code>false</code>.
         *         uses an * field width; otherwise
         *         <code>false</code>.
         */
        boolean isVariableFieldWidth()
        {
@@ -1297,6 +1322,7 @@
         * Set the field width with an argument.  A
         * negative field width is taken as a - flag
         * followed by a positive field width.
         *
         * @param fw the field width.
         */
        void setFieldWidthWithArg(int fw)
@@ -1307,16 +1333,17 @@
            }
            fieldWidthSet = true;
            fieldWidth    = Math.abs(fw);
            fieldWidth = Math.abs(fw);
        }
        /**
         * Check whether the specifier has a variable
         * precision that is going to be set by an
         * argument.
         *
         * @return <code>true</code> if the conversion
         *   uses an * precision; otherwise
         *   <code>false</code>.
         *         uses an * precision; otherwise
         *         <code>false</code>.
         */
        boolean isVariablePrecision()
        {
@@ -1326,21 +1353,23 @@
        /**
         * Set the precision with an argument.  A
         * negative precision will be changed to zero.
         *
         * @param pr the precision.
         */
        void setPrecisionWithArg(int pr)
        {
            precisionSet = true;
            precision    = Math.max(pr, 0);
            precision = Math.max(pr, 0);
        }
        /**
         * Format an int argument using this conversion
         *  specification.
         * specification.
         *
         * @param s the int to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         *     conversion character is f, e, E, g, or G.
         * @throws IllegalArgumentException if the
         *                                  conversion character is f, e, E, g, or G.
         */
        String internalsprintf(int s) throws IllegalArgumentException
        {
@@ -1348,8 +1377,8 @@
            switch (conversionCharacter)
            {
            case 'd' :
            case 'i' :
            case 'd':
            case 'i':
                if (optionalh)
                {
                    s2 = printDFormat((short) s);
@@ -1363,8 +1392,8 @@
                break;
            case 'x' :
            case 'X' :
            case 'x':
            case 'X':
                if (optionalh)
                {
                    s2 = printXFormat((short) s);
@@ -1378,7 +1407,7 @@
                break;
            case 'o' :
            case 'o':
                if (optionalh)
                {
                    s2 = printOFormat((short) s);
@@ -1392,15 +1421,15 @@
                break;
            case 'c' :
            case 'C' :
            case 'c':
            case 'C':
                s2 = printCFormat((char) s);
                break;
            default :
            default:
                throw new IllegalArgumentException("Cannot format a int with a format using a " + conversionCharacter
                                                   + " conversion character.");
                        + " conversion character.");
            }
            return s2;
@@ -1409,10 +1438,11 @@
        /**
         * Format a long argument using this conversion
         * specification.
         *
         * @param s the long to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         *     conversion character is f, e, E, g, or G.
         * @throws IllegalArgumentException if the
         *                                  conversion character is f, e, E, g, or G.
         */
        String internalsprintf(long s) throws IllegalArgumentException
        {
@@ -1420,8 +1450,8 @@
            switch (conversionCharacter)
            {
            case 'd' :
            case 'i' :
            case 'd':
            case 'i':
                if (optionalh)
                {
                    s2 = printDFormat((short) s);
@@ -1435,8 +1465,8 @@
                break;
            case 'x' :
            case 'X' :
            case 'x':
            case 'X':
                if (optionalh)
                {
                    s2 = printXFormat((short) s);
@@ -1450,7 +1480,7 @@
                break;
            case 'o' :
            case 'o':
                if (optionalh)
                {
                    s2 = printOFormat((short) s);
@@ -1464,15 +1494,15 @@
                break;
            case 'c' :
            case 'C' :
            case 'c':
            case 'C':
                s2 = printCFormat((char) s);
                break;
            default :
            default:
                throw new IllegalArgumentException("Cannot format a long with a format using a " + conversionCharacter
                                                   + " conversion character.");
                        + " conversion character.");
            }
            return s2;
@@ -1481,11 +1511,12 @@
        /**
         * Format a double argument using this conversion
         * specification.
         *
         * @param s the double to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         *     conversion character is c, C, s, S, i, d,
         *     x, X, or o.
         * @throws IllegalArgumentException if the
         *                                  conversion character is c, C, s, S, i, d,
         *                                  x, X, or o.
         */
        String internalsprintf(double s) throws IllegalArgumentException
        {
@@ -1493,26 +1524,26 @@
            switch (conversionCharacter)
            {
            case 'f' :
            case 'f':
                s2 = printFFormat(s);
                break;
            case 'E' :
            case 'e' :
            case 'E':
            case 'e':
                s2 = printEFormat(s);
                break;
            case 'G' :
            case 'g' :
            case 'G':
            case 'g':
                s2 = printGFormat(s);
                break;
            default :
            default:
                throw new IllegalArgumentException("Cannot " + "format a double with a format using a " + conversionCharacter
                                                   + " conversion character.");
                        + " conversion character.");
            }
            return s2;
@@ -1521,10 +1552,11 @@
        /**
         * Format a String argument using this conversion
         * specification.
         *
         * @param s the String to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         *   conversion character is neither s nor S.
         * @throws IllegalArgumentException if the
         *                                  conversion character is neither s nor S.
         */
        String internalsprintf(String s) throws IllegalArgumentException
        {
@@ -1536,7 +1568,7 @@
            } else
            {
                throw new IllegalArgumentException("Cannot " + "format a String with a format using a " + conversionCharacter
                                                   + " conversion character.");
                        + " conversion character.");
            }
            return s2;
@@ -1545,10 +1577,11 @@
        /**
         * Format an Object argument using this conversion
         * specification.
         *
         * @param s the Object to format.
         * @return the formatted String.
         * @exception IllegalArgumentException if the
         *     conversion character is neither s nor S.
         * @throws IllegalArgumentException if the
         *                                  conversion character is neither s nor S.
         */
        String internalsprintf(Object s)
        {
@@ -1560,7 +1593,7 @@
            } else
            {
                throw new IllegalArgumentException("Cannot format a String with a format using" + " a " + conversionCharacter
                                                   + " conversion character.");
                        + " conversion character.");
            }
            return s2;
@@ -1578,12 +1611,12 @@
         * is ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the number of digits
         * to appear after the radix character.  Padding is
         * with trailing 0s.
@@ -1591,10 +1624,10 @@
        private char[] fFormatDigits(double x)
        {
            // int defaultDigits=6;
            String  sx, sxOut;
            int     i, j, k;
            int     n1In, n2In;
            int     expon     = 0;
            String sx, sxOut;
            int i, j, k;
            int n1In, n2In;
            int expon = 0;
            boolean minusSign = false;
            if (x > 0.0)
@@ -1602,7 +1635,7 @@
                sx = Double.toString(x);
            } else if (x < 0.0)
            {
                sx        = Double.toString(-x);
                sx = Double.toString(-x);
                minusSign = true;
            } else
            {
@@ -1611,7 +1644,7 @@
                if (sx.charAt(0) == '-')
                {
                    minusSign = true;
                    sx        = sx.substring(1);
                    sx = sx.substring(1);
                }
            }
@@ -1761,7 +1794,7 @@
                    ca4[0] = '1';
                }
                if (alternateForm ||!precisionSet || (precision != 0))
                if (alternateForm || !precisionSet || (precision != 0))
                {
                    ca4[1] = '.';
@@ -1779,7 +1812,7 @@
            {
                if (!carry)
                {
                    if (alternateForm ||!precisionSet || (precision != 0))
                    if (alternateForm || !precisionSet || (precision != 0))
                    {
                        ca4 = new char[n1In + expon + p + 1];
                    } else
@@ -1790,7 +1823,7 @@
                    j = 0;
                } else
                {
                    if (alternateForm ||!precisionSet || (precision != 0))
                    if (alternateForm || !precisionSet || (precision != 0))
                    {
                        ca4 = new char[n1In + expon + p + 2];
                    } else
@@ -1799,7 +1832,7 @@
                    }
                    ca4[0] = '1';
                    j      = 1;
                    j = 1;
                }
                for (i = 0; i < Math.min(n1In + expon, ca3.length); i++, j++)
@@ -1812,7 +1845,7 @@
                    ca4[j] = '0';
                }
                if (alternateForm ||!precisionSet || (precision != 0))
                if (alternateForm || !precisionSet || (precision != 0))
                {
                    ca4[j] = '.';
                    j++;
@@ -1941,7 +1974,7 @@
            if (thousands && (nThousands > 0))
            {
                ca6    = new char[ca5.length + nThousands + lead];
                ca6 = new char[ca5.length + nThousands + lead];
                ca6[0] = ca5[0];
                for (i = lead, k = lead; i < dp; i++)
@@ -1949,9 +1982,9 @@
                    if ((i > 0) && (dp - i) % 3 == 0)
                    {
                        // ca6[k]=',';
                        ca6[k]     = dfs.getGroupingSeparator();
                        ca6[k] = dfs.getGroupingSeparator();
                        ca6[k + 1] = ca5[i];
                        k          += 2;
                        k += 2;
                    } else
                    {
                        ca6[k] = ca5[i];
@@ -1974,13 +2007,14 @@
         * the input double value is an infinity,
         * not-a-number, or a finite double and formats
         * each type of input appropriately.
         *
         * @param x the double value to be formatted.
         * @return the converted double value.
         */
        private String fFormatString(double x)
        {
            boolean noDigits = false;
            char[]  ca6, ca7;
            char[] ca6, ca7;
            if (Double.isInfinite(x))
            {
@@ -2038,16 +2072,16 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear after the radix character.
         * Padding is with trailing 0s.
         *
         * <p/>
         * The behavior is like printf.  One (hopefully the
         * only) exception is that the minimum number of
         * exponent digits is 3 instead of 2 for e and E
@@ -2061,11 +2095,11 @@
            char[] ca1, ca2, ca3;
            // int defaultDigits=6;
            String  sx, sxOut;
            int     i, j, k, p;
            int     n1In, n2In;
            int     expon = 0;
            int     ePos, rPos, eSize;
            String sx, sxOut;
            int i, j, k, p;
            int n1In, n2In;
            int expon = 0;
            int ePos, rPos, eSize;
            boolean minusSign = false;
            if (x > 0.0)
@@ -2073,7 +2107,7 @@
                sx = Double.toString(x);
            } else if (x < 0.0)
            {
                sx        = Double.toString(-x);
                sx = Double.toString(-x);
                minusSign = true;
            } else
            {
@@ -2082,7 +2116,7 @@
                if (sx.charAt(0) == '-')
                {
                    minusSign = true;
                    sx        = sx.substring(1);
                    sx = sx.substring(1);
                }
            }
@@ -2190,7 +2224,7 @@
            }
            boolean carry = false;
            int     i0    = 0;
            int i0 = 0;
            if (ca1[0] != '0')
            {
@@ -2217,7 +2251,7 @@
                if (carry)
                {
                    ca2     = new char[i0 + p + 1];
                    ca2 = new char[i0 + p + 1];
                    ca2[i0] = '1';
                    for (j = 0; j < i0; j++)
@@ -2235,7 +2269,7 @@
                }
            }
            if ((Math.abs(expon) < 100) &&!optionalL)
            if ((Math.abs(expon) < 100) && !optionalL)
            {
                eSize = 4;
            } else
@@ -2243,7 +2277,7 @@
                eSize = 5;
            }
            if (alternateForm ||!precisionSet || (precision != 0))
            if (alternateForm || !precisionSet || (precision != 0))
            {
                ca2 = new char[2 + p + eSize];
            } else
@@ -2254,12 +2288,12 @@
            if (ca1[0] != '0')
            {
                ca2[0] = ca1[0];
                j      = 1;
                j = 1;
            } else
            {
                for (j = 1; j < ((ePos == -1)
                                 ? ca1.length
                                 : ePos); j++)
                        ? ca1.length
                        : ePos); j++)
                {
                    if (ca1[j] != '0')
                    {
@@ -2270,19 +2304,19 @@
                if (((ePos != -1) && (j < ePos)) || ((ePos == -1) && (j < ca1.length)))
                {
                    ca2[0] = ca1[j];
                    expon  -= j;
                    expon -= j;
                    j++;
                } else
                {
                    ca2[0] = '0';
                    j      = 2;
                    j = 2;
                }
            }
            if (alternateForm ||!precisionSet || (precision != 0))
            if (alternateForm || !precisionSet || (precision != 0))
            {
                ca2[1] = '.';
                i      = 2;
                i = 2;
            } else
            {
                i = 1;
@@ -2314,47 +2348,47 @@
            {
                switch (expon / 100)
                {
                case 1 :
                case 1:
                    ca2[i] = '1';
                    break;
                case 2 :
                case 2:
                    ca2[i] = '2';
                    break;
                case 3 :
                case 3:
                    ca2[i] = '3';
                    break;
                case 4 :
                case 4:
                    ca2[i] = '4';
                    break;
                case 5 :
                case 5:
                    ca2[i] = '5';
                    break;
                case 6 :
                case 6:
                    ca2[i] = '6';
                    break;
                case 7 :
                case 7:
                    ca2[i] = '7';
                    break;
                case 8 :
                case 8:
                    ca2[i] = '8';
                    break;
                case 9 :
                case 9:
                    ca2[i] = '9';
                    break;
@@ -2365,52 +2399,52 @@
            switch ((expon % 100) / 10)
            {
            case 0 :
            case 0:
                ca2[i] = '0';
                break;
            case 1 :
            case 1:
                ca2[i] = '1';
                break;
            case 2 :
            case 2:
                ca2[i] = '2';
                break;
            case 3 :
            case 3:
                ca2[i] = '3';
                break;
            case 4 :
            case 4:
                ca2[i] = '4';
                break;
            case 5 :
            case 5:
                ca2[i] = '5';
                break;
            case 6 :
            case 6:
                ca2[i] = '6';
                break;
            case 7 :
            case 7:
                ca2[i] = '7';
                break;
            case 8 :
            case 8:
                ca2[i] = '8';
                break;
            case 9 :
            case 9:
                ca2[i] = '9';
                break;
@@ -2420,52 +2454,52 @@
            switch (expon % 10)
            {
            case 0 :
            case 0:
                ca2[i] = '0';
                break;
            case 1 :
            case 1:
                ca2[i] = '1';
                break;
            case 2 :
            case 2:
                ca2[i] = '2';
                break;
            case 3 :
            case 3:
                ca2[i] = '3';
                break;
            case 4 :
            case 4:
                ca2[i] = '4';
                break;
            case 5 :
            case 5:
                ca2[i] = '5';
                break;
            case 6 :
            case 6:
                ca2[i] = '6';
                break;
            case 7 :
            case 7:
                ca2[i] = '7';
                break;
            case 8 :
            case 8:
                ca2[i] = '8';
                break;
            case 9 :
            case 9:
                ca2[i] = '9';
                break;
@@ -2583,7 +2617,7 @@
            if (thousands && (nThousands > 0))
            {
                ca4    = new char[ca3.length + nThousands + lead];
                ca4 = new char[ca3.length + nThousands + lead];
                ca4[0] = ca3[0];
                for (i = lead, k = lead; i < dp; i++)
@@ -2591,9 +2625,9 @@
                    if ((i > 0) && (dp - i) % 3 == 0)
                    {
                        // ca4[k]=',';
                        ca4[k]     = dfs.getGroupingSeparator();
                        ca4[k] = dfs.getGroupingSeparator();
                        ca4[k + 1] = ca3[i];
                        k          += 2;
                        k += 2;
                    } else
                    {
                        ca4[k] = ca3[i];
@@ -2614,11 +2648,12 @@
         * Check to see if the digits that are going to
         * be truncated because of the precision should
         * force a round in the preceding digits.
         * @param ca1 the array of digits
         *
         * @param ca1    the array of digits
         * @param icarry the index of the first digit that
         *     is to be truncated from the print
         *               is to be truncated from the print
         * @return <code>true</code> if the truncation forces
         *     a round that will change the print
         *         a round that will change the print
         */
        private boolean checkForCarry(char[] ca1, int icarry)
        {
@@ -2646,7 +2681,7 @@
                    if (!carry && (icarry > 0))
                    {
                        carry = ((ca1[icarry - 1] == '1') || (ca1[icarry - 1] == '3') || (ca1[icarry - 1] == '5')
                                 || (ca1[icarry - 1] == '7') || (ca1[icarry - 1] == '9'));
                                || (ca1[icarry - 1] == '7') || (ca1[icarry - 1] == '9'));
                    }
                }
            }
@@ -2659,13 +2694,14 @@
         * is not quite finished because the symbolic
         * carry may change the length of the string and
         * change the exponent (in e format).
         * @param cLast index of the last digit changed
         *     by the round
         *
         * @param cLast  index of the last digit changed
         *               by the round
         * @param cFirst index of the first digit allowed
         *     to be changed by this phase of the round
         *               to be changed by this phase of the round
         * @return <code>true</code> if the carry forces
         *     a round that will change the print still
         *     more
         *         a round that will change the print still
         *         more
         */
        private boolean startSymbolicCarry(char[] ca, int cLast, int cFirst)
        {
@@ -2677,52 +2713,52 @@
                switch (ca[i])
                {
                case '0' :
                case '0':
                    ca[i] = '1';
                    break;
                case '1' :
                case '1':
                    ca[i] = '2';
                    break;
                case '2' :
                case '2':
                    ca[i] = '3';
                    break;
                case '3' :
                case '3':
                    ca[i] = '4';
                    break;
                case '4' :
                case '4':
                    ca[i] = '5';
                    break;
                case '5' :
                case '5':
                    ca[i] = '6';
                    break;
                case '6' :
                case '6':
                    ca[i] = '7';
                    break;
                case '7' :
                case '7':
                    ca[i] = '8';
                    break;
                case '8' :
                case '8':
                    ca[i] = '9';
                    break;
                case '9' :
                case '9':
                    ca[i] = '0';
                    carry = true;
@@ -2739,15 +2775,16 @@
         * the input double value is an infinity,
         * not-a-number, or a finite double and formats
         * each type of input appropriately.
         * @param x the double value to be formatted.
         *
         * @param x     the double value to be formatted.
         * @param eChar an 'e' or 'E' to use in the
         *     converted double value.
         *              converted double value.
         * @return the converted double value.
         */
        private String eFormatString(double x, char eChar)
        {
            boolean noDigits = false;
            char[]  ca4, ca5;
            char[] ca4, ca5;
            if (Double.isInfinite(x))
            {
@@ -2795,8 +2832,9 @@
        /**
         * Apply zero or blank, left or right padding.
         * @param ca4 array of characters before padding is
         *     finished
         *
         * @param ca4      array of characters before padding is
         *                 finished
         * @param noDigits NaN or signed Inf
         * @return a padded array of characters
         */
@@ -2851,8 +2889,8 @@
                    if (nBlanks > 0)
                    {
                        ca5 = new char[ca4.length + nBlanks];
                        i   = 0;
                        j   = 0;
                        i = 0;
                        j = 0;
                        if (ca4[0] == '-')
                        {
@@ -2879,6 +2917,7 @@
        /**
         * Format method for the f conversion character.
         *
         * @param x the double to format.
         * @return the formatted String.
         */
@@ -2890,6 +2929,7 @@
        /**
         * Format method for the e or E conversion
         * character.
         *
         * @param x the double to format.
         * @return the formatted String.
         */
@@ -2906,9 +2946,9 @@
        /**
         * Format method for the g conversion character.
         *
         * <p/>
         * For g format, the flag character '-', means that
         *  the output should be left justified within the
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  '+' character means that the conversion
         * will always begin with a sign (+ or -).  The
@@ -2918,24 +2958,25 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear after the radix character.
         * Padding is with trailing 0s.
         *
         * @param x the double to format.
         * @return the formatted String.
         */
        private String printGFormat(double x)
        {
            String  sx, sy, sz, ret;
            int     savePrecision = precision;
            int     i;
            char[]  ca4, ca5;
            String sx, sy, sz, ret;
            int savePrecision = precision;
            int i;
            char[] ca4, ca5;
            boolean noDigits = false;
            if (Double.isInfinite(x))
@@ -2988,11 +3029,11 @@
                if (conversionCharacter == 'g')
                {
                    sx   = eFormatString(x, 'e').trim();
                    sx = eFormatString(x, 'e').trim();
                    ePos = sx.indexOf('e');
                } else
                {
                    sx   = eFormatString(x, 'E').trim();
                    sx = eFormatString(x, 'E').trim();
                    ePos = sx.indexOf('E');
                }
@@ -3106,7 +3147,7 @@
            }
            // Pad with blanks or zeros.
            ca5       = applyFloatPadding(ca4, false);
            ca5 = applyFloatPadding(ca4, false);
            precision = savePrecision;
            return new String(ca5);
@@ -3115,7 +3156,7 @@
        /**
         * Format method for the d conversion specifer and
         * short argument.
         *
         * <p/>
         * For d format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
@@ -3127,14 +3168,15 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the short to format.
         * @return the formatted String.
         */
@@ -3146,7 +3188,7 @@
        /**
         * Format method for the d conversion character and
         * long argument.
         *
         * <p/>
         * For d format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
@@ -3158,14 +3200,15 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the long to format.
         * @return the formatted String.
         */
@@ -3177,7 +3220,7 @@
        /**
         * Format method for the d conversion character and
         * int argument.
         *
         * <p/>
         * For d format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
@@ -3189,14 +3232,15 @@
         * ignored.  The '0' flag character implies that
         * padding to the field width will be done with
         * zeros instead of blanks.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the int to format.
         * @return the formatted String.
         */
@@ -3208,19 +3252,20 @@
        /**
         * Utility method for formatting using the d
         * conversion character.
         *
         * @param sx the String to format, the result of
         *     converting a short, int, or long to a
         *     String.
         *           converting a short, int, or long to a
         *           String.
         * @return the formatted String.
         */
        private String printDFormat(String sx)
        {
            int     nLeadingZeros = 0;
            int     nBlanks       = 0,
                    n             = 0;
            int     i             = 0,
                    jFirst        = 0;
            boolean neg           = sx.charAt(0) == '-';
            int nLeadingZeros = 0;
            int nBlanks = 0,
                    n = 0;
            int i = 0,
                    jFirst = 0;
            boolean neg = sx.charAt(0) == '-';
            if (sx.equals("0") && precisionSet && (precision == 0))
            {
@@ -3291,8 +3336,8 @@
                char[] csx = sx.toCharArray();
                jFirst = neg
                         ? 1
                         : 0;
                        ? 1
                        : 0;
                for (int j = 0; j < nLeadingZeros; i++, j++)
                {
@@ -3354,8 +3399,8 @@
                char[] csx = sx.toCharArray();
                jFirst = neg
                         ? 1
                         : 0;
                        ? 1
                        : 0;
                for (int j = jFirst; j < csx.length; j++, i++)
                {
@@ -3369,20 +3414,21 @@
        /**
         * Format method for the x conversion character and
         * short argument.
         *
         * <p/>
         * For x format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means to lead with
         * '0x'.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the short to format.
         * @return the formatted String.
         */
@@ -3412,55 +3458,55 @@
                switch (t.length())
                {
                case 1 :
                case 1:
                    sx = "800" + t;
                    break;
                case 2 :
                case 2:
                    sx = "80" + t;
                    break;
                case 3 :
                case 3:
                    sx = "8" + t;
                    break;
                case 4 :
                case 4:
                    switch (t.charAt(0))
                    {
                    case '1' :
                    case '1':
                        sx = "9" + t.substring(1, 4);
                        break;
                    case '2' :
                    case '2':
                        sx = "a" + t.substring(1, 4);
                        break;
                    case '3' :
                    case '3':
                        sx = "b" + t.substring(1, 4);
                        break;
                    case '4' :
                    case '4':
                        sx = "c" + t.substring(1, 4);
                        break;
                    case '5' :
                    case '5':
                        sx = "d" + t.substring(1, 4);
                        break;
                    case '6' :
                    case '6':
                        sx = "e" + t.substring(1, 4);
                        break;
                    case '7' :
                    case '7':
                        sx = "f" + t.substring(1, 4);
                        break;
@@ -3479,20 +3525,21 @@
        /**
         * Format method for the x conversion character and
         * long argument.
         *
         * <p/>
         * For x format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means to lead with
         * '0x'.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the long to format.
         * @return the formatted String.
         */
@@ -3509,115 +3556,115 @@
                switch (t.length())
                {
                case 1 :
                case 1:
                    sx = "800000000000000" + t;
                    break;
                case 2 :
                case 2:
                    sx = "80000000000000" + t;
                    break;
                case 3 :
                case 3:
                    sx = "8000000000000" + t;
                    break;
                case 4 :
                case 4:
                    sx = "800000000000" + t;
                    break;
                case 5 :
                case 5:
                    sx = "80000000000" + t;
                    break;
                case 6 :
                case 6:
                    sx = "8000000000" + t;
                    break;
                case 7 :
                case 7:
                    sx = "800000000" + t;
                    break;
                case 8 :
                case 8:
                    sx = "80000000" + t;
                    break;
                case 9 :
                case 9:
                    sx = "8000000" + t;
                    break;
                case 10 :
                case 10:
                    sx = "800000" + t;
                    break;
                case 11 :
                case 11:
                    sx = "80000" + t;
                    break;
                case 12 :
                case 12:
                    sx = "8000" + t;
                    break;
                case 13 :
                case 13:
                    sx = "800" + t;
                    break;
                case 14 :
                case 14:
                    sx = "80" + t;
                    break;
                case 15 :
                case 15:
                    sx = "8" + t;
                    break;
                case 16 :
                case 16:
                    switch (t.charAt(0))
                    {
                    case '1' :
                    case '1':
                        sx = "9" + t.substring(1, 16);
                        break;
                    case '2' :
                    case '2':
                        sx = "a" + t.substring(1, 16);
                        break;
                    case '3' :
                    case '3':
                        sx = "b" + t.substring(1, 16);
                        break;
                    case '4' :
                    case '4':
                        sx = "c" + t.substring(1, 16);
                        break;
                    case '5' :
                    case '5':
                        sx = "d" + t.substring(1, 16);
                        break;
                    case '6' :
                    case '6':
                        sx = "e" + t.substring(1, 16);
                        break;
                    case '7' :
                    case '7':
                        sx = "f" + t.substring(1, 16);
                        break;
@@ -3636,20 +3683,21 @@
        /**
         * Format method for the x conversion character and
         * int argument.
         *
         * <p/>
         * For x format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means to lead with
         * '0x'.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the int to format.
         * @return the formatted String.
         */
@@ -3666,75 +3714,75 @@
                switch (t.length())
                {
                case 1 :
                case 1:
                    sx = "8000000" + t;
                    break;
                case 2 :
                case 2:
                    sx = "800000" + t;
                    break;
                case 3 :
                case 3:
                    sx = "80000" + t;
                    break;
                case 4 :
                case 4:
                    sx = "8000" + t;
                    break;
                case 5 :
                case 5:
                    sx = "800" + t;
                    break;
                case 6 :
                case 6:
                    sx = "80" + t;
                    break;
                case 7 :
                case 7:
                    sx = "8" + t;
                    break;
                case 8 :
                case 8:
                    switch (t.charAt(0))
                    {
                    case '1' :
                    case '1':
                        sx = "9" + t.substring(1, 8);
                        break;
                    case '2' :
                    case '2':
                        sx = "a" + t.substring(1, 8);
                        break;
                    case '3' :
                    case '3':
                        sx = "b" + t.substring(1, 8);
                        break;
                    case '4' :
                    case '4':
                        sx = "c" + t.substring(1, 8);
                        break;
                    case '5' :
                    case '5':
                        sx = "d" + t.substring(1, 8);
                        break;
                    case '6' :
                    case '6':
                        sx = "e" + t.substring(1, 8);
                        break;
                    case '7' :
                    case '7':
                        sx = "f" + t.substring(1, 8);
                        break;
@@ -3753,15 +3801,16 @@
        /**
         * Utility method for formatting using the x
         * conversion character.
         *
         * @param sx the String to format, the result of
         *     converting a short, int, or long to a
         *     String.
         *           converting a short, int, or long to a
         *           String.
         * @return the formatted String.
         */
        private String printXFormat(String sx)
        {
            int nLeadingZeros = 0;
            int nBlanks       = 0;
            int nBlanks = 0;
            if (sx.equals("0") && precisionSet && (precision == 0))
            {
@@ -3805,7 +3854,7 @@
            n += nBlanks;
            char[] ca = new char[n];
            int    i  = 0;
            int i = 0;
            if (leftJustify)
            {
@@ -3881,21 +3930,22 @@
        /**
         * Format method for the o conversion character and
         * short argument.
         *
         * <p/>
         * For o format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means that the
         * output begins with a leading 0 and the precision
         * is increased by 1.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the short to format.
         * @return the formatted String.
         */
@@ -3912,27 +3962,27 @@
                switch (t.length())
                {
                case 1 :
                case 1:
                    sx = "10000" + t;
                    break;
                case 2 :
                case 2:
                    sx = "1000" + t;
                    break;
                case 3 :
                case 3:
                    sx = "100" + t;
                    break;
                case 4 :
                case 4:
                    sx = "10" + t;
                    break;
                case 5 :
                case 5:
                    sx = "1" + t;
                    break;
@@ -3948,21 +3998,22 @@
        /**
         * Format method for the o conversion character and
         * long argument.
         *
         * <p/>
         * For o format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means that the
         * output begins with a leading 0 and the precision
         * is increased by 1.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the long to format.
         * @return the formatted String.
         */
@@ -3979,107 +4030,107 @@
                switch (t.length())
                {
                case 1 :
                case 1:
                    sx = "100000000000000000000" + t;
                    break;
                case 2 :
                case 2:
                    sx = "10000000000000000000" + t;
                    break;
                case 3 :
                case 3:
                    sx = "1000000000000000000" + t;
                    break;
                case 4 :
                case 4:
                    sx = "100000000000000000" + t;
                    break;
                case 5 :
                case 5:
                    sx = "10000000000000000" + t;
                    break;
                case 6 :
                case 6:
                    sx = "1000000000000000" + t;
                    break;
                case 7 :
                case 7:
                    sx = "100000000000000" + t;
                    break;
                case 8 :
                case 8:
                    sx = "10000000000000" + t;
                    break;
                case 9 :
                case 9:
                    sx = "1000000000000" + t;
                    break;
                case 10 :
                case 10:
                    sx = "100000000000" + t;
                    break;
                case 11 :
                case 11:
                    sx = "10000000000" + t;
                    break;
                case 12 :
                case 12:
                    sx = "1000000000" + t;
                    break;
                case 13 :
                case 13:
                    sx = "100000000" + t;
                    break;
                case 14 :
                case 14:
                    sx = "10000000" + t;
                    break;
                case 15 :
                case 15:
                    sx = "1000000" + t;
                    break;
                case 16 :
                case 16:
                    sx = "100000" + t;
                    break;
                case 17 :
                case 17:
                    sx = "10000" + t;
                    break;
                case 18 :
                case 18:
                    sx = "1000" + t;
                    break;
                case 19 :
                case 19:
                    sx = "100" + t;
                    break;
                case 20 :
                case 20:
                    sx = "10" + t;
                    break;
                case 21 :
                case 21:
                    sx = "1" + t;
                    break;
@@ -4095,21 +4146,22 @@
        /**
         * Format method for the o conversion character and
         * int argument.
         *
         * <p/>
         * For o format, the flag character '-', means that
         * the output should be left justified within the
         * field.  The default is to pad with blanks on the
         * left.  The '#' flag character means that the
         * output begins with a leading 0 and the precision
         * is increased by 1.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is to
         * add no padding.  Padding is with blanks by
         * default.
         *
         * <p/>
         * The precision, if set, is the minimum number of
         * digits to appear.  Padding is with leading 0s.
         *
         * @param x the int to format.
         * @return the formatted String.
         */
@@ -4126,57 +4178,57 @@
                switch (t.length())
                {
                case 1 :
                case 1:
                    sx = "2000000000" + t;
                    break;
                case 2 :
                case 2:
                    sx = "200000000" + t;
                    break;
                case 3 :
                case 3:
                    sx = "20000000" + t;
                    break;
                case 4 :
                case 4:
                    sx = "2000000" + t;
                    break;
                case 5 :
                case 5:
                    sx = "200000" + t;
                    break;
                case 6 :
                case 6:
                    sx = "20000" + t;
                    break;
                case 7 :
                case 7:
                    sx = "2000" + t;
                    break;
                case 8 :
                case 8:
                    sx = "200" + t;
                    break;
                case 9 :
                case 9:
                    sx = "20" + t;
                    break;
                case 10 :
                case 10:
                    sx = "2" + t;
                    break;
                case 11 :
                case 11:
                    sx = "3" + t.substring(1);
                    break;
@@ -4192,15 +4244,16 @@
        /**
         * Utility method for formatting using the o
         * conversion character.
         *
         * @param sx the String to format, the result of
         *     converting a short, int, or long to a
         *     String.
         *           converting a short, int, or long to a
         *           String.
         * @return the formatted String.
         */
        private String printOFormat(String sx)
        {
            int nLeadingZeros = 0;
            int nBlanks       = 0;
            int nBlanks = 0;
            if (sx.equals("0") && precisionSet && (precision == 0))
            {
@@ -4232,9 +4285,9 @@
                nBlanks = 0;
            }
            int    n  = nLeadingZeros + sx.length() + nBlanks;
            int n = nLeadingZeros + sx.length() + nBlanks;
            char[] ca = new char[n];
            int    i;
            int i;
            if (leftJustify)
            {
@@ -4289,24 +4342,25 @@
        /**
         * Format method for the c conversion character and
         * char argument.
         *
         * <p/>
         * The only flag character that affects c format is
         * the '-', meaning that the output should be left
         * justified within the field.  The default is to
         * pad with blanks on the left.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  Padding is with
         * blanks by default.  The default width is 1.
         *
         * <p/>
         * The precision, if set, is ignored.
         *
         * @param x the char to format.
         * @return the formatted String.
         */
        private String printCFormat(char x)
        {
            int nPrint = 1;
            int width  = fieldWidth;
            int width = fieldWidth;
            if (!fieldWidthSet)
            {
@@ -4314,7 +4368,7 @@
            }
            char[] ca = new char[width];
            int    i  = 0;
            int i = 0;
            if (leftJustify)
            {
@@ -4340,30 +4394,31 @@
        /**
         * Format method for the s conversion character and
         * String argument.
         *
         * <p/>
         * The only flag character that affects s format is
         * the '-', meaning that the output should be left
         * justified within the field.  The default is to
         * pad with blanks on the left.
         *
         * <p/>
         * The field width is treated as the minimum number
         * of characters to be printed.  The default is the
         * smaller of the number of characters in the the
         * input and the precision.  Padding is with blanks
         * by default.
         *
         * <p/>
         * The precision, if set, specifies the maximum
         * number of characters to be printed from the
         * string.  A null digit string is treated
         * as a 0.  The default is not to set a maximum
         * number of characters to be printed.
         *
         * @param x the String to format.
         * @return the formatted String.
         */
        private String printSFormat(String x)
        {
            int nPrint = x.length();
            int width  = fieldWidth;
            int width = fieldWidth;
            if (precisionSet && (nPrint > precision))
            {
@@ -4391,7 +4446,7 @@
            }
            char[] ca = new char[n];
            int    i  = 0;
            int i = 0;
            if (leftJustify)
            {
@@ -4449,9 +4504,10 @@
        /**
         * Check for a conversion character.  If it is
         * there, store it.
         *
         * @return <code>true</code> if the conversion
         *     character is there, and
         *     <code>false</code> otherwise.
         *         character is there, and
         *         <code>false</code> otherwise.
         */
        private boolean setConversionCharacter()
        {
@@ -4465,7 +4521,7 @@
                char c = fmt.charAt(pos);
                if ((c == 'i') || (c == 'd') || (c == 'f') || (c == 'g') || (c == 'G') || (c == 'o') || (c == 'x') || (c == 'X')
                    || (c == 'e') || (c == 'E') || (c == 'c') || (c == 's') || (c == '%'))
                        || (c == 'e') || (c == 'E') || (c == 'c') || (c == 's') || (c == '%'))
                {
                    conversionCharacter = c;
                    pos++;
@@ -4531,7 +4587,7 @@
                    if (!setPrecisionArgPosition())
                    {
                        variablePrecision = true;
                        precisionSet      = true;
                        precisionSet = true;
                    }
                    return;
@@ -4554,7 +4610,7 @@
                    {
                        String sz = fmt.substring(firstPos + 1, pos);
                        precision    = Integer.parseInt(sz);
                        precision = Integer.parseInt(sz);
                        precisionSet = true;
                    }
                }
@@ -4568,7 +4624,7 @@
        {
            int firstPos = pos;
            fieldWidth    = 0;
            fieldWidth = 0;
            fieldWidthSet = false;
            if ((pos < fmt.length()) && (fmt.charAt(pos) == '*'))
@@ -4578,7 +4634,7 @@
                if (!setFieldWidthArgPosition())
                {
                    variableFieldWidth = true;
                    fieldWidthSet      = true;
                    fieldWidthSet = true;
                }
            } else
            {
@@ -4599,7 +4655,7 @@
                {
                    String sz = fmt.substring(firstPos, pos);
                    fieldWidth    = Integer.parseInt(sz);
                    fieldWidth = Integer.parseInt(sz);
                    fieldWidthSet = true;
                }
            }
@@ -4625,8 +4681,8 @@
                if (fmt.charAt(xPos) == '$')
                {
                    positionalSpecification = true;
                    argumentPosition        = Integer.parseInt(fmt.substring(pos, xPos));
                    pos                     = xPos + 1;
                    argumentPosition = Integer.parseInt(fmt.substring(pos, xPos));
                    pos = xPos + 1;
                }
            }
        }
@@ -4637,7 +4693,7 @@
        private boolean setFieldWidthArgPosition()
        {
            boolean ret = false;
            int     xPos;
            int xPos;
            for (xPos = pos; xPos < fmt.length(); xPos++)
            {
@@ -4651,10 +4707,10 @@
            {
                if (fmt.charAt(xPos) == '$')
                {
                    positionalFieldWidth          = true;
                    positionalFieldWidth = true;
                    argumentPositionForFieldWidth = Integer.parseInt(fmt.substring(pos, xPos));
                    pos                           = xPos + 1;
                    ret                           = true;
                    pos = xPos + 1;
                    ret = true;
                }
            }
@@ -4667,7 +4723,7 @@
        private boolean setPrecisionArgPosition()
        {
            boolean ret = false;
            int     xPos;
            int xPos;
            for (xPos = pos; xPos < fmt.length(); xPos++)
            {
@@ -4681,10 +4737,10 @@
            {
                if (fmt.charAt(xPos) == '$')
                {
                    positionalPrecision          = true;
                    positionalPrecision = true;
                    argumentPositionForPrecision = Integer.parseInt(fmt.substring(pos, xPos));
                    pos                          = xPos + 1;
                    ret                          = true;
                    pos = xPos + 1;
                    ret = true;
                }
            }
@@ -4727,12 +4783,12 @@
        private void setFlagCharacters()
        {
            /* '-+ #0 */
            thousands     = false;
            leftJustify   = false;
            leadingSign   = false;
            leadingSpace  = false;
            thousands = false;
            leftJustify = false;
            leadingSign = false;
            leadingSpace = false;
            alternateForm = false;
            leadingZeros  = false;
            leadingZeros = false;
            for (; pos < fmt.length(); pos++)
            {
@@ -4743,11 +4799,11 @@
                    thousands = true;
                } else if (c == '-')
                {
                    leftJustify  = true;
                    leftJustify = true;
                    leadingZeros = false;
                } else if (c == '+')
                {
                    leadingSign  = true;
                    leadingSign = true;
                    leadingSpace = false;
                } else if (c == ' ')
                {