cds.simbad
Class MFormatElement

java.lang.Object
  extended bycds.simbad.MFormatElement
All Implemented Interfaces:
java.io.Serializable

class MFormatElement
extends java.lang.Object
implements java.io.Serializable

Class defining format elements for the measurements. A format element is kept by a CFormat object. It can be either a part of regular text, or a compiled version of a format element having the following syntax:

 ... %[+|-][0]mmm[.nn]s|c|d{fieldname} ...
 
which is a C-like format syntax:
 [] means a optional field
 |  means an alternative
 -----
 '+' : forces to display the plus sign for positive numbers
 '-' : left justifies the data item in its field ('+' and '-' can be
       combined for numbers).
 '0' : before the 'mmm' length triggers the number to be filled with
       zeroes if it is right justified.
 mmm : total length of the field.
 nn  : number of decimal digits for a numerical item. As these items are
       already strings, dd helps also to align on the decimal point.
 's' : a string
 'c' : a unique char
 'd' : a number (with decimal digits, if '.dd' is present. Otherwise
       an integer.
 {fieldname} defines the fieldname of the measurement, and is not really part
             of the format definition.

Version:
1.0 May 2002
Author:
Marc Wenger/CDS

Field Summary
protected  int dec
           
protected  boolean displaysign
           
protected  java.lang.String fieldname
           
protected  int fieldnum
           
protected  boolean headingZero
           
protected  boolean leftjustified
           
protected  int len
           
protected  java.lang.String text
           
protected  char type
           
 
Constructor Summary
protected MFormatElement(java.lang.String text)
          Constructor for a regular text string.
protected MFormatElement(java.lang.String format, java.lang.String fieldname)
          Constructor for a format element.
 
Method Summary
private  boolean belongsToNumber(char c)
           
private  java.lang.String fill(char c, int nb)
           
protected  java.lang.String format(java.lang.String text)
          Formats the string according to the parameters of this format element
protected  java.lang.String getFieldname()
          Returns the field name
protected  java.lang.String getText()
           
protected  boolean isText()
           
private  java.lang.String justify(java.lang.String str, int maxlen, boolean left)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

text

protected java.lang.String text

displaysign

protected boolean displaysign

leftjustified

protected boolean leftjustified

headingZero

protected boolean headingZero

len

protected int len

dec

protected int dec

type

protected char type

fieldname

protected java.lang.String fieldname

fieldnum

protected int fieldnum
Constructor Detail

MFormatElement

protected MFormatElement(java.lang.String text)
Constructor for a regular text string. The text parameter is a regular text.

Parameters:
text - simple text string

MFormatElement

protected MFormatElement(java.lang.String format,
                         java.lang.String fieldname)
Constructor for a format element.

Parameters:
format - format definition %[+-]0999.99[sdc]
fieldname - name of the field
Method Detail

fill

private java.lang.String fill(char c,
                              int nb)

belongsToNumber

private final boolean belongsToNumber(char c)

justify

private java.lang.String justify(java.lang.String str,
                                 int maxlen,
                                 boolean left)

format

protected java.lang.String format(java.lang.String text)
Formats the string according to the parameters of this format element

Parameters:
text - text to format
Returns:
the formatted text

getText

protected java.lang.String getText()

isText

protected boolean isText()

getFieldname

protected java.lang.String getFieldname()
Returns the field name

Returns:
field name