astro
Class Convert

java.lang.Object
  extended by java.text.Format
      extended by java.text.NumberFormat
          extended by astro.Convert
All Implemented Interfaces:
Serializable, Cloneable

public class Convert
extends NumberFormat

Class containing several conversion routines often used in astronomical context.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.NumberFormat
NumberFormat.Field
 
Field Summary
static String[] CONST
           
private  int digit
           
private  String dstr
           
private  String mstr
           
private  double mult
           
private  String sstr
           
 
Fields inherited from class java.text.NumberFormat
FRACTION_FIELD, INTEGER_FIELD
 
Constructor Summary
Convert()
           
Convert(boolean hours)
           
Convert(String h, String m, String s, int dig, boolean hour)
           
 
Method Summary
static double convertDec(String dec)
          Transforms ggdmm'ss" into the appropriate double value.
static double convertHour(String hour)
          Converts a xxhxxmxx.xs String into a double of the approbiate value.
static double convertSexagesimal(String angle, String d, String m, String s)
          Converts a string from sexagesimal notation into a fractional angle.
 StringBuffer format(double angle, StringBuffer append, FieldPosition pos)
          Formats the angle.
 StringBuffer format(long angle, StringBuffer append, FieldPosition pos)
          Formats the angle.
static String get99Catalog(int cat)
           
static int get99Catalog(String name)
           
static String getDec(double de)
          Converts a double declination value into a xxdxx'xx.x" String.
static String getHour(double rah)
          Converts a double ra-h value into a xxhxxmxx.xs String.
static String getSexagesimal(double ang, String d, String m, String s, int digit)
          Converts an angle into the sexagesimal format.
static String getSexagesimal(double ang, String d, String m, String s, int digit, boolean full)
          Converts an angle into the sexagesimal format.
static void main(String[] arg)
           
 Number parse(String source, ParsePosition parsePosition)
          Parses according to separators.
 
Methods inherited from class java.text.NumberFormat
clone, equals, format, format, format, getAvailableLocales, getCurrency, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, getRoundingMode, hashCode, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setCurrency, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setParseIntegerOnly, setRoundingMode
 
Methods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dstr

private String dstr

mstr

private String mstr

sstr

private String sstr

digit

private int digit

mult

private double mult

CONST

public static final String[] CONST
Constructor Detail

Convert

public Convert()

Convert

public Convert(boolean hours)

Convert

public Convert(String h,
               String m,
               String s,
               int dig,
               boolean hour)
Method Detail

parse

public Number parse(String source,
                    ParsePosition parsePosition)
Parses according to separators. Always returns Double.

Specified by:
parse in class NumberFormat

format

public StringBuffer format(long angle,
                           StringBuffer append,
                           FieldPosition pos)
Formats the angle.

Specified by:
format in class NumberFormat

format

public StringBuffer format(double angle,
                           StringBuffer append,
                           FieldPosition pos)
Formats the angle.

Specified by:
format in class NumberFormat

getHour

public static String getHour(double rah)
Converts a double ra-h value into a xxhxxmxx.xs String.

Parameters:
rah -
Returns:
String

getDec

public static String getDec(double de)
Converts a double declination value into a xxdxx'xx.x" String.


getSexagesimal

public static String getSexagesimal(double ang,
                                    String d,
                                    String m,
                                    String s,
                                    int digit)
Converts an angle into the sexagesimal format. This format uses integer degrees, followed by the degree-String, then integer arcminutes followed by the minute-String, then fractional seconds followed by the seconds-String. Any of these Strings can be empty.

Parameters:
angle - The angle to be converted into sexagesimal.
d - The degree-to-minute separator.
m - The minutes-to-seconds separator.
s - The String following the seconds.
digit - The number of digits in the seconds, zero for integer.

getSexagesimal

public static String getSexagesimal(double ang,
                                    String d,
                                    String m,
                                    String s,
                                    int digit,
                                    boolean full)
Converts an angle into the sexagesimal format. This format uses integer degrees, followed by the degree-String, then integer arcminutes followed by the minute-String, then fractional seconds followed by the seconds-String. Any of these Strings can be empty.

Parameters:
angle - The angle to be converted into sexagesimal.
d - The degree-to-minute separator.
m - The minutes-to-seconds separator.
s - The String following the seconds.
digit - The number of digits in the seconds, zero for integer.
full - If true, minutes and seconds are added even if zero.

convertHour

public static double convertHour(String hour)
Converts a xxhxxmxx.xs String into a double of the approbiate value.

Parameters:
hour - A string of format ##h##m##.####s
Returns:
The fractional value of the hour

convertDec

public static double convertDec(String dec)
Transforms ggdmm'ss" into the appropriate double value.

Returns:
The fractional value of the degrees.

convertSexagesimal

public static final double convertSexagesimal(String angle,
                                              String d,
                                              String m,
                                              String s)
Converts a string from sexagesimal notation into a fractional angle.

Parameters:
angle - The angle in sexagesimal notation.
d - The separator string between degrees and minutes.
m - The separator string between minutes and seconds.
s - The last character, if any.

get99Catalog

public static int get99Catalog(String name)
Parameters:
name -
Returns:
int

get99Catalog

public static String get99Catalog(int cat)
Parameters:
cat -
Returns:
String

main

public static void main(String[] arg)
Parameters:
arg -