cds.util
Class FieldFormat

java.lang.Object
  extended bycds.util.FieldFormat

class FieldFormat
extends java.lang.Object

Specifies a single, complete, percent-style format. FieldFormat contains the specification of a complete single field format, e.g. "%#+5.*f" The constructor parses the prefix of a string. The sprintf() method prints a value according to this format.

Author:
Tony Plate tplate@attglobal.net Copyright 1999,2000 Tony Plate

Nested Class Summary
(package private)  class FieldFormat.ExpNotationStrings
           
(package private)  class FieldFormat.IntContainer
           
 
Field Summary
(package private)  boolean alternate
           
(package private) static java.text.DecimalFormatSymbols decimalFormatSymbols
           
(package private) static char decimalSeparatorSymbol
           
(package private)  java.text.NumberFormat gfnf
           
(package private) static java.lang.String infinitySymbol
           
(package private)  boolean longType
           
(package private)  boolean minus
           
(package private) static char minusSymbol
           
(package private) static java.lang.String nanSymbol
           
(package private)  java.text.DecimalFormat nf
           
(package private)  boolean plus
           
(package private)  int precision
           
(package private)  boolean precisionInArg
           
(package private)  boolean precisionSpecified
           
(package private)  boolean space
           
(package private)  char type
           
(package private)  int width
           
(package private)  boolean widthInArg
           
(package private)  boolean widthSpecified
           
(package private)  boolean zero
           
(package private) static char zeroSymbol
           
 
Constructor Summary
(package private) FieldFormat(java.io.StreamTokenizer tokenizer)
          Creator -- parses part of a format string, and removes what it uses
 
Method Summary
private  java.lang.String convert_b(java.lang.Byte value, int precision)
           
private  java.lang.String convert_b(java.lang.Integer value, int precision)
           
private  java.lang.String convert_b(java.lang.Long value, int precision)
           
private  java.lang.String convert_b(java.lang.Short value, int precision)
           
private  java.lang.String convert_c(java.lang.Character value, int precision)
           
private  java.lang.String convert_d(java.lang.Byte value, int width)
           
private  java.lang.String convert_d(java.lang.Integer value, int width)
           
private  java.lang.String convert_d(java.lang.Long value, int width)
           
private  java.lang.String convert_d(java.lang.Short value, int width)
           
private  java.lang.String convert_e(java.lang.Double value, int precision)
           
private  FieldFormat.ExpNotationStrings convert_e(java.lang.Double value, int precision, boolean alternate, FieldFormat.IntContainer exp)
           
private  java.lang.String convert_f(java.lang.Double value, int precision)
           
private  java.lang.String convert_g(java.lang.Double value, int precision)
           
private  java.lang.String convert_o(java.lang.Byte value, int width)
           
private  java.lang.String convert_o(java.lang.Integer value, int width)
           
private  java.lang.String convert_o(java.lang.Long value, int width)
           
private  java.lang.String convert_o(java.lang.Short value, int width)
           
private  java.lang.String convert_s(java.lang.String str, int precision)
           
private  java.lang.String convert_x(java.lang.Byte value, int width)
           
private  java.lang.String convert_x(java.lang.Integer value, int width)
           
private  java.lang.String convert_x(java.lang.Long value, int width)
           
private  java.lang.String convert_x(java.lang.Short value, int width)
           
private  boolean isDigit(int c)
           
private  java.lang.String pad(java.lang.String prefix, java.lang.String convertedValue, int width)
           
(package private) static java.lang.String padLeadingZeros(java.lang.String convertedValue, int width)
           
(package private) static java.lang.String padTrailingZeros(java.lang.String convertedValue, int width)
           
private  java.lang.String prefix_b(int sign)
           
private  java.lang.String prefix_c(int sign)
           
private  java.lang.String prefix_d(int sign)
           
private  java.lang.String prefix_e(int sign)
           
private  java.lang.String prefix_f(int sign)
           
private  java.lang.String prefix_g(int sign)
           
private  java.lang.String prefix_o(int sign)
           
private  java.lang.String prefix_s(java.lang.String str)
           
private  java.lang.String prefix_x(int sign)
           
private  java.lang.String sign_prefix(int sign)
          Work out the appropriate sign prefix for this sign value in this format Have an extra type of sign modifier in addition to the ANSI standards (which are "+" and " "): have both "+" and " " no mods space plus space+plus +ve "" " " "+" "+" zero "" " " "+" " " -ve "-" "-" "-" "-"
(package private)  java.lang.String sprintf(java.util.Iterator argIterator, VarArgs args)
          sprintf(Iterator argIterator, CParams args) Print the args according to the format.
(package private) static java.lang.String stripTrailingZeros(java.lang.String str)
           
 java.lang.String toString()
           
private  void wrongType(java.lang.Object obj, java.lang.String wanted, VarArgs args, boolean throwIt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

char type

alternate

boolean alternate

zero

boolean zero

plus

boolean plus

space

boolean space

minus

boolean minus

widthInArg

boolean widthInArg

widthSpecified

boolean widthSpecified

width

int width

precisionInArg

boolean precisionInArg

precisionSpecified

boolean precisionSpecified

precision

int precision

longType

boolean longType

nf

java.text.DecimalFormat nf

gfnf

java.text.NumberFormat gfnf

decimalFormatSymbols

static java.text.DecimalFormatSymbols decimalFormatSymbols

decimalSeparatorSymbol

static char decimalSeparatorSymbol

zeroSymbol

static char zeroSymbol

minusSymbol

static char minusSymbol

nanSymbol

static java.lang.String nanSymbol

infinitySymbol

static java.lang.String infinitySymbol
Constructor Detail

FieldFormat

FieldFormat(java.io.StreamTokenizer tokenizer)
      throws java.io.IOException,
             CFormatSyntaxException
Creator -- parses part of a format string, and removes what it uses

Method Detail

toString

public java.lang.String toString()

isDigit

private boolean isDigit(int c)

wrongType

private void wrongType(java.lang.Object obj,
                       java.lang.String wanted,
                       VarArgs args,
                       boolean throwIt)
                throws CFormatArgException
Throws:
CFormatArgException

sprintf

java.lang.String sprintf(java.util.Iterator argIterator,
                         VarArgs args)
sprintf(Iterator argIterator, CParams args) Print the args according to the format. The VarArgs list is passed as an argument purely to allow us to print out the index of the arg in case of an error.


sign_prefix

private java.lang.String sign_prefix(int sign)
Work out the appropriate sign prefix for this sign value in this format Have an extra type of sign modifier in addition to the ANSI standards (which are "+" and " "): have both "+" and " " no mods space plus space+plus +ve "" " " "+" "+" zero "" " " "+" " " -ve "-" "-" "-" "-"


convert_d

private java.lang.String convert_d(java.lang.Long value,
                                   int width)

convert_d

private java.lang.String convert_d(java.lang.Integer value,
                                   int width)

convert_d

private java.lang.String convert_d(java.lang.Short value,
                                   int width)

convert_d

private java.lang.String convert_d(java.lang.Byte value,
                                   int width)

prefix_d

private java.lang.String prefix_d(int sign)

convert_b

private java.lang.String convert_b(java.lang.Long value,
                                   int precision)

convert_b

private java.lang.String convert_b(java.lang.Integer value,
                                   int precision)

convert_b

private java.lang.String convert_b(java.lang.Short value,
                                   int precision)

convert_b

private java.lang.String convert_b(java.lang.Byte value,
                                   int precision)

prefix_b

private java.lang.String prefix_b(int sign)

convert_x

private java.lang.String convert_x(java.lang.Long value,
                                   int width)

convert_x

private java.lang.String convert_x(java.lang.Integer value,
                                   int width)

convert_x

private java.lang.String convert_x(java.lang.Short value,
                                   int width)

convert_x

private java.lang.String convert_x(java.lang.Byte value,
                                   int width)

prefix_x

private java.lang.String prefix_x(int sign)

convert_o

private java.lang.String convert_o(java.lang.Long value,
                                   int width)

convert_o

private java.lang.String convert_o(java.lang.Integer value,
                                   int width)

convert_o

private java.lang.String convert_o(java.lang.Short value,
                                   int width)

convert_o

private java.lang.String convert_o(java.lang.Byte value,
                                   int width)

prefix_o

private java.lang.String prefix_o(int sign)

convert_c

private java.lang.String convert_c(java.lang.Character value,
                                   int precision)

prefix_c

private java.lang.String prefix_c(int sign)

convert_e

private java.lang.String convert_e(java.lang.Double value,
                                   int precision)

convert_e

private FieldFormat.ExpNotationStrings convert_e(java.lang.Double value,
                                                 int precision,
                                                 boolean alternate,
                                                 FieldFormat.IntContainer exp)

prefix_e

private java.lang.String prefix_e(int sign)

convert_f

private java.lang.String convert_f(java.lang.Double value,
                                   int precision)

prefix_f

private java.lang.String prefix_f(int sign)

convert_g

private java.lang.String convert_g(java.lang.Double value,
                                   int precision)

prefix_g

private java.lang.String prefix_g(int sign)

convert_s

private java.lang.String convert_s(java.lang.String str,
                                   int precision)

prefix_s

private java.lang.String prefix_s(java.lang.String str)

stripTrailingZeros

static java.lang.String stripTrailingZeros(java.lang.String str)

padLeadingZeros

static java.lang.String padLeadingZeros(java.lang.String convertedValue,
                                        int width)

padTrailingZeros

static java.lang.String padTrailingZeros(java.lang.String convertedValue,
                                         int width)

pad

private java.lang.String pad(java.lang.String prefix,
                             java.lang.String convertedValue,
                             int width)