cds.astro
Class Editing

java.lang.Object
  extended by cds.astro.Astroformat
      extended by cds.astro.Editing

public class Editing
extends Astroformat

Class for 'nice' edition of numbers. This class contains options for the edition of integer / float numbers; the edited value is appended to the StringBuffer generally specified as the first argument.
This class is used in the various astronomical editions.


Field Summary
static boolean DEBUG
          Debugging option
 java.lang.String inf_string
          How the Infinite is represented -- default is Inf
 
Fields inherited from class cds.astro.Astroformat
DATE, DATE_alpha, DATE_COMP, DATE_DIFF, DATE_DMY, DATE_DY, DATE_MDY, DATE_MY, DATE_MYD, DATE_YD, DATE_YM, DATE_YMD, DECIMAL, EFORMAT, FACTOR, month_list, nulls, pic1, pic1_explain, SEXA1d, SEXA1h, SEXA1o, SEXA2, SEXA2c, SEXA2d, SEXA2h, SEXA2o, SEXA3, SEXA3c, SEXA3d, SEXA3h, SEXA3o, SIGN_EDIT, TRUNCATE, ZERO_FILL
 
Constructor Summary
Editing()
          The basic constructor: default NaN edition is "-".
Editing(java.lang.String null_text)
          Constructor specifying the NaN representation, and default options.
 
Method Summary
 java.lang.StringBuffer edit(java.lang.StringBuffer buf, int value, int width)
          Edition of an integer number, right-aligned, with default options.
 java.lang.StringBuffer editComplex(java.lang.StringBuffer buf, double mjd, java.lang.String pic)
          Edit a complex number (date, time, angle).
 java.lang.StringBuffer editDate(java.lang.StringBuffer buf, double mjd, int time_prec, int option)
          Edition of a MJD date into an ISO-8601 date YYYY-MM-DDThh:mm:ss[...]
 java.lang.StringBuffer editDate(java.lang.StringBuffer buf, int mjd)
          Edition of a MJD date into an ISO-8601 date YYYY-MM-DD
 java.lang.StringBuffer editDate(java.lang.StringBuffer buf, int mjd, int option)
          Edition of a MJD date into an ISO-8601 date YYYY-MM-DD
 java.lang.StringBuffer editDecimal(java.lang.StringBuffer buf, double value, int nint, int nd, int option)
          Edition of a single floating-point number (%f).
 java.lang.StringBuffer editDouble(java.lang.StringBuffer buf, double value, int option)
          Edition of a single floating-point number (%g or %e).
 java.lang.StringBuffer editDouble(java.lang.StringBuffer buf, double value, int ndig, int nexp, int option)
          Edition of a single floating-point number (%g or %e).
 java.lang.StringBuffer editFlags(java.lang.StringBuffer buf, int flags, java.lang.String[] symbols)
          Edit a number considered as a set of bits.
 java.lang.StringBuffer editInfinite(java.lang.StringBuffer buf, int width, int sign)
          Assignment to Infinity represention, right-aligned.
 java.lang.StringBuffer editInt(java.lang.StringBuffer buf, int value, int width, int option)
          Edition of an integer number, right-aligned, with user-specified options.
 java.lang.StringBuffer editLong(java.lang.StringBuffer buf, long value, int width, int option)
          Edition of a long integer number, right-aligned, with user-specified options.
 java.lang.StringBuffer editNaN(java.lang.StringBuffer buf, int width)
          Assignment to NaN represention.
 java.lang.StringBuffer editSexa(java.lang.StringBuffer buf, double value, int nint, int ndec, int option)
          Edition of a single floating-point number in Sexagesimal.
 void setInfinite(java.lang.String text)
          Define the Infinite representation
 java.lang.String toString()
          The conversion to string
 
Methods inherited from class cds.astro.Astroformat
acceptAsNaN, explain, explainComplex, isAngle, isDate, isDays, isSexa, isTime, setNaN
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inf_string

public java.lang.String inf_string
How the Infinite is represented -- default is Inf


DEBUG

public static boolean DEBUG
Debugging option

Constructor Detail

Editing

public Editing()
The basic constructor: default NaN edition is "-".


Editing

public Editing(java.lang.String null_text)
Constructor specifying the NaN representation, and default options.

Parameters:
null_text - what to write in case of NULL (NaN) value.
Method Detail

setInfinite

public void setInfinite(java.lang.String text)
Define the Infinite representation

Parameters:
text - the choice for Infinity

editFlags

public java.lang.StringBuffer editFlags(java.lang.StringBuffer buf,
                                        int flags,
                                        java.lang.String[] symbols)
Edit a number considered as a set of bits. The bits set are edited from a table; list separated with commas.

Parameters:
buf - the buffer to which the flags are appended
flags - the list of flags.
symbols - the table of symbols

editNaN

public java.lang.StringBuffer editNaN(java.lang.StringBuffer buf,
                                      int width)
Assignment to NaN represention. Just appends the NULL string representation, right-aligned.

Parameters:
buf - the buffer to which the string representation is appended
width - the total width

editInfinite

public java.lang.StringBuffer editInfinite(java.lang.StringBuffer buf,
                                           int width,
                                           int sign)
Assignment to Infinity represention, right-aligned. Just appends the Infinite string representation, right-aligned.

Parameters:
buf - the buffer to which the string representation is appended
width - the total width
sign - positive(add +sign), negative(add -sign), or zero.

editLong

public java.lang.StringBuffer editLong(java.lang.StringBuffer buf,
                                       long value,
                                       int width,
                                       int option)
Edition of a long integer number, right-aligned, with user-specified options. A long having the MIN_VALUE (0x8000000000000000L) is considered as NaN. A long having ±MAX_VALUE (0x7fffffffffffffffL) is considered as Infty

Parameters:
buf - the buffer to which the string representation is appended
value - the number to edit
width - the total width
option - a mixture of options like Astroformat.ZERO_FILL, Astroformat.SIGN_EDIT, ...
Returns:
the edited buffer

editInt

public java.lang.StringBuffer editInt(java.lang.StringBuffer buf,
                                      int value,
                                      int width,
                                      int option)
Edition of an integer number, right-aligned, with user-specified options. An integer having the MIN_VALUE (0x80000000) is considered as NaN. An integer having ±MAX_VALUE (0x7fffffff) is considered as Infty.

Parameters:
buf - the buffer to which the string representation is appended
value - the number to edit
width - the total width
option - a mixture of options like Astroformat.ZERO_FILL, Astroformat.SIGN_EDIT, ...
Returns:
the edited buffer

edit

public java.lang.StringBuffer edit(java.lang.StringBuffer buf,
                                   int value,
                                   int width)
Edition of an integer number, right-aligned, with default options. An integer having the MIN_VALUE (0x80000000) is considered as NaN.

Parameters:
buf - the buffer to which the string representation is appended
value - the number to edit
width - the total width
Returns:
the edited buffer

editDecimal

public java.lang.StringBuffer editDecimal(java.lang.StringBuffer buf,
                                          double value,
                                          int nint,
                                          int nd,
                                          int option)
Edition of a single floating-point number (%f). The width of the edited number is nint+nd+1 The number is truncated when the option includes TRUNCATE; it is rounded by default.
Negative number of decimals nd follow the following conventions:

Parameters:
buf - the buffer to which the string representation is appended
value - the number to edit
nint - the number of characters for the integer part. If nint==0 a value in range ]0..1[ starts by a decimal point (e.g. .123)
nd - the number of decimals -- use -1 to remove the decimal point -2 to -15 to remove the non-significant zeroes.
option - a combination of Astroformat.ZERO_FILL / Astroformat.SIGN_EDIT / Astroformat.TRUNCATE
Returns:
the editing buffer.

editDouble

public java.lang.StringBuffer editDouble(java.lang.StringBuffer buf,
                                         double value,
                                         int ndig,
                                         int nexp,
                                         int option)
Edition of a single floating-point number (%g or %e). The standard edition is decimal in range [0.1, 1000[, E-format otherwise. The %e format can be forced with the EFORMAT option.
Remark: the number is truncated (instead of the default rounding) if the TRUNCATE option is specified.
The total width used for the edition is 3+ndig+nexp or 5+ndig+nexp depending on the FACTOR option.

Parameters:
buf - buffer to which the string representation is appended
value - number to edit
ndig - number of significant digits (do the best if ndig<=0)
nexp - number of characters for the exponent value (3 recommended)
option - a combination of Astroformat.EFORMAT / Astroformat.SIGN_EDIT
Returns:
the editing buffer.

editDouble

public java.lang.StringBuffer editDouble(java.lang.StringBuffer buf,
                                         double value,
                                         int option)
Edition of a single floating-point number (%g or %e). The standard edition is decimal in range [0.1, 1000[, E-format otherwise. Edits in the best possible way.

Parameters:
buf - buffer to which the string representation is appended
value - number to edit
option - a combination of Astroformat.EFORMAT / Astroformat.SIGN_EDIT
Returns:
the editing buffer.

editSexa

public java.lang.StringBuffer editSexa(java.lang.StringBuffer buf,
                                       double value,
                                       int nint,
                                       int ndec,
                                       int option)
Edition of a single floating-point number in Sexagesimal. Remark: the number is truncated -- not rounded.

Parameters:
buf - buffer to which the string representation is appended
value - number to edit
nint - number of characters for the integer part (degrees)
ndec - number of 'decimals' (2=arcmin, 4=arcsec, ...) use a negative number to specify the "maximal" number of decimals.
option - a combination of Astroformat.SEXA1d (and other SEXAxx possibilities) / Astroformat.ZERO_FILL / Astroformat.SIGN_EDIT ...
Returns:
the editing buffer.

editDate

public java.lang.StringBuffer editDate(java.lang.StringBuffer buf,
                                       int mjd)
Edition of a MJD date into an ISO-8601 date YYYY-MM-DD

Parameters:
buf - buffer to which the string representation is appended
mjd - the date to edit
Returns:
the editing buffer.

editDate

public java.lang.StringBuffer editDate(java.lang.StringBuffer buf,
                                       int mjd,
                                       int option)
Edition of a MJD date into an ISO-8601 date YYYY-MM-DD

Parameters:
buf - buffer to which the string representation is appended
mjd - the date to edit
option - the option for date editing (e.g. Astroformat.DATE_YMD)
Returns:
the editing buffer.

editDate

public java.lang.StringBuffer editDate(java.lang.StringBuffer buf,
                                       double mjd,
                                       int time_prec,
                                       int option)
Edition of a MJD date into an ISO-8601 date YYYY-MM-DDThh:mm:ss[...]

Parameters:
buf - buffer to which the string representation is appended
mjd - the date to edit
time_prec - the precision in the time edition. Values are 0=no time, 2=hr, 4=min, 6=sec, 9=ms, etc. Negative values indicate a maximal precision.
option - the option for date editing (e.g. Astroformat.DATE_YMD)
Returns:
the editing buffer.

editComplex

public java.lang.StringBuffer editComplex(java.lang.StringBuffer buf,
                                          double mjd,
                                          java.lang.String pic)
Edit a complex number (date, time, angle).

Parameters:
buf - buffer to which the string representation is appended
mjd - the value to edit (MJD in case of date/time)
pic - the 'picture' to use, includes Y=year, M=month, D=day, h=hour, m=min, s=sec, d=deg f=fraction
Returns:
the editing buffer.

toString

public java.lang.String toString()
The conversion to string

Overrides:
toString in class java.lang.Object