tribble.text
Class PictureFormat

java.lang.Object
  extended bytribble.text.PictureFormat

public class PictureFormat
extends java.lang.Object

Picture-string format.

Picture Specifications

    (n)     ---     Repeat factor
    0       ANE     Insert '0'
    9       AN      Digit
    A       A       Alphabetic character or space
    B       ANE     Space (blank)
    CR       NE     Sign, 'CR' is negative, else spaces
    DB       NE     Sign, 'DB' is negative, else spaces
    E        NEF    Floating exponent
    G       A  W    Wide (16-bit) alphanumeric character
    P        N      Implied digit
    S        N      Implied sign
    V        N      Implied decimal point
    X       A       Alphanumeric character
    Z        NE     Floating leading digit
    *        NE     Leading '*' fill character or digit
    -        NE     Sign
    +        NE     Sign, '+' or '-'
    /       ANE     Insert '/'
    .        NE     Decimal point
    ,        NE     Digit group separator
    $        NE     Floating '$'
 

Version:
$Revision: 1.1 $ $Date: 2005/09/03 16:42:42 $
Author:
David R. Tribble (
Field Summary
static short FL_ALNUM
           
static short FL_ALPHA
           
static short FL_EDITED
           
static short FL_FLOAT
           
static short FL_NUM
           
static char PIC_ALNUM
           
static char PIC_ALPHA
           
static char PIC_CR
           
static char PIC_CR2
           
static char PIC_CURRENCY
           
static char PIC_DASH
           
static char PIC_DB
           
static char PIC_DB2
           
static char PIC_DIGIT
           
static char PIC_FILL
           
static char PIC_FL_DIGIT
           
static char PIC_PLUS
           
static char PIC_POINT
           
static char PIC_REP_L
           
static char PIC_REP_R
           
static char PIC_SEP
           
static char PIC_SLASH
           
static char PIC_SPACE
           
static char PIC_ZERO
           
 
Constructor Summary
PictureFormat(java.lang.String pic)
          Constructor.
 
Method Summary
 int format(long n, char[] buf, int off)
          Format a numeric value.
 int format(java.lang.Object obj, java.lang.StringBuffer buf, java.text.FieldPosition pos)
          Format an object into a string.
 int format(java.lang.String s, char[] buf, int off)
          Format a character string value.
 int getInputLength()
          Determine the length of the source value required by this format.
 int getOutputLength()
          Determine the formatted length produced by this format.
static void main(java.lang.String[] args)
          Test driver.
 java.lang.String parseObject(java.lang.String src, java.text.ParsePosition pos)
           
 char setFillChar(char ch)
          Establish the fill character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PIC_ALNUM

public static final char PIC_ALNUM
See Also:
Constant Field Values

PIC_ALPHA

public static final char PIC_ALPHA
See Also:
Constant Field Values

PIC_CURRENCY

public static final char PIC_CURRENCY
See Also:
Constant Field Values

PIC_CR

public static final char PIC_CR
See Also:
Constant Field Values

PIC_CR2

public static final char PIC_CR2
See Also:
Constant Field Values

PIC_DB

public static final char PIC_DB
See Also:
Constant Field Values

PIC_DB2

public static final char PIC_DB2
See Also:
Constant Field Values

PIC_DIGIT

public static final char PIC_DIGIT
See Also:
Constant Field Values

PIC_FL_DIGIT

public static final char PIC_FL_DIGIT
See Also:
Constant Field Values

PIC_FILL

public static final char PIC_FILL
See Also:
Constant Field Values

PIC_POINT

public static final char PIC_POINT
See Also:
Constant Field Values

PIC_REP_L

public static final char PIC_REP_L
See Also:
Constant Field Values

PIC_REP_R

public static final char PIC_REP_R
See Also:
Constant Field Values

PIC_SEP

public static final char PIC_SEP
See Also:
Constant Field Values

PIC_DASH

public static final char PIC_DASH
See Also:
Constant Field Values

PIC_PLUS

public static final char PIC_PLUS
See Also:
Constant Field Values

PIC_SLASH

public static final char PIC_SLASH
See Also:
Constant Field Values

PIC_SPACE

public static final char PIC_SPACE
See Also:
Constant Field Values

PIC_ZERO

public static final char PIC_ZERO
See Also:
Constant Field Values

FL_NUM

public static final short FL_NUM
See Also:
Constant Field Values

FL_ALPHA

public static final short FL_ALPHA
See Also:
Constant Field Values

FL_ALNUM

public static final short FL_ALNUM
See Also:
Constant Field Values

FL_EDITED

public static final short FL_EDITED
See Also:
Constant Field Values

FL_FLOAT

public static final short FL_FLOAT
See Also:
Constant Field Values
Constructor Detail

PictureFormat

public PictureFormat(java.lang.String pic)
              throws FormatException
Constructor.

Parameters:
pic - Picture specification string.
Throws:
FormatException - Thrown if pic is malformed.
java.lang.NullPointerException - (unchecked) Thrown if pic is null.
Since:
1.1, 2005-08-29
Method Detail

main

public static void main(java.lang.String[] args)
Test driver.

Since:
1.2, 2005-09-03

getOutputLength

public int getOutputLength()
Determine the formatted length produced by this format.

Returns:
The number of characters resulting from the output of this format object.
Since:
1.2, 2005-09-03

getInputLength

public int getInputLength()
Determine the length of the source value required by this format.

Returns:
The number of characters or digits required from the input source for this format object.
Since:
1.2, 2005-09-03

setFillChar

public char setFillChar(char ch)
Establish the fill character. By default, the fill character is the space ( ).

Parameters:
ch - Fill character.
Returns:
The previous fill character setting.
Since:
1.1, 2005-08-31

format

public int format(java.lang.Object obj,
                  java.lang.StringBuffer buf,
                  java.text.FieldPosition pos)
Format an object into a string.

Parameters:
obj - An object to format.
buf - Target buffer to be filled with the formatted result.
Returns:
The number of formatted characters written into buf.
Throws:
FormatException - Thrown if an error occurs while formatting the value.
Since:
1.1, 2005-08-30

parseObject

public java.lang.String parseObject(java.lang.String src,
                                    java.text.ParsePosition pos)

format

public int format(java.lang.String s,
                  char[] buf,
                  int off)
           throws FormatException
Format a character string value.

Parameters:
s - Character string value to format.
buf - Target buffer to be filled with the formatted result.
off - Index of the first character within buf to write to.
Returns:
The number of formatted characters written into buf.
Throws:
FormatException - Thrown if an error occurs while formatting the value.
Since:
1.1, 2005-08-30

format

public int format(long n,
                  char[] buf,
                  int off)
           throws FormatException
Format a numeric value.

Parameters:
n - Numeric value to format.
buf - Target buffer to be filled with the formatted result.
off - Index of the first character within buf to write to.
Returns:
The number of formatted characters written into buf.
Throws:
FormatException - Thrown if an error occurs while formatting the value.
Since:
1.1, 2005-08-29