cds.astro
Class Otype

java.lang.Object
  extended by cds.astro.Otype
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Otype
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

The Otype is a classification of the astronomical objects in a hierarchical structure.

See Also:
Serialized Form

Field Summary
static boolean DEBUG
           
protected static int[] Nlev
           
protected static cds.astro.Otable otable
           
protected  int otype
           
static int UNKNOWN
           
 
Constructor Summary
Otype()
          Define the default Otype (object of unknown nature)
Otype(int ot)
          Define the Otype from an otype code (integer)
Otype(Otype ot)
          Copy constructor
Otype(java.lang.String text)
          Define the Otype from a String
 
Method Summary
 boolean agrees(Otype ot1)
          Check if the 2 Otypes are compatible
 java.lang.Object clone()
          Copy values parameters
 void dump()
          Dump contents to stdout
protected static void edit(java.lang.StringBuffer buf, int otype)
          Edit the otype as xx.xx.xx.xx
 boolean equals(java.lang.Object o)
          MOD-BB 21-01-04 Ajout de cette methode.
 java.lang.String get()
           
 int getBinType()
          Get the binary type
 java.util.ArrayList getCompatibleTypes()
          For the current type, get all compatible types in other branches
static java.lang.String getDescription()
          Get the description text to display in the web page
 int getLevel()
          Compute the level of the curent object type in the hierarchy
 java.lang.String[] getList()
          Gives all explanation string of otypes
 java.lang.String getName()
           
 int getQueryMask()
          Get the querymask corresponding to the level of the current otype
 int getQueryMask(int level)
          Get the querymask of a given level
 int getQueryValue()
          Get the query value (= the binary value of the current type)
 java.lang.String getQueryValueList()
          Build the where part of an SQL query corresponding to a given type extended to its compatible types.
 java.lang.String[] getShortList()
           
 int getValue(int level)
          Get the value of a particular level (0-4)
static java.lang.String getVersion()
          Get the version information. it is the last .VERSION entry in the otype.def file
static java.lang.String getVersionDate()
          Get the version date.
 int hashCode()
          Compute the hashcode (overrides the Object method).
 boolean hasValue()
          Check if this type has a value.
static java.lang.String hexaToNumeric(java.lang.String strHex)
          Methode qui transforme une chaine de caractere hexadecimale en otype sous forme numerique
 boolean implies(Otype t1)
          Check if is a subtype (in same branch)
static void init(java.lang.String filepath)
          Initialisation.
 boolean isUnknown()
          Check if the object type is unknown
static java.util.Iterator iterator()
          Get an iterator on the object types
static int level(int ot)
          Compute the level of the submitted object type in the hierarchy
 java.util.Enumeration list()
          List in an enumeration all Otypes belonging to a class.
 Otype merge(Otype ot1)
          Choose the most accurate Otype: the deepest one ine the hierarchy.
 Otype mergepl(Otype ot2)
           
static int ntype(java.lang.String s)
          Interpret the 4 numbers as an Otype class.
 java.lang.String numericToHexa()
          Methode qui permet de transformer un otype decimal en hexadecimal
 int parse(java.lang.String s)
          Parse a string containing otype sting name
 int parse(java.lang.String s, int offset)
          Parse a string containing otype sting name
static void reload()
          Reload the otype description file
 void reset()
          Reset this object type to its NODATA value.
protected  void set(int o)
          Convert an integer into an Otype
 void set(java.lang.String text)
          Convert a text into an object type
 java.lang.String toString()
          Default Edition of the Otype value
 java.lang.String toString(char cc)
          Edition with options
 java.lang.String toString(int choice)
          Default Edition of the Otype value
 java.lang.String toString(java.lang.String opt)
          Edition with options
 void truncate(int lev)
          Truncate the otype to some upper level (e.g.
 void upperLevel()
          Set the object type to one level higher.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values

DEBUG

public static boolean DEBUG

Nlev

protected static final int[] Nlev

otable

protected static cds.astro.Otable otable

otype

protected int otype
Constructor Detail

Otype

public Otype()
Define the default Otype (object of unknown nature)


Otype

public Otype(java.lang.String text)
      throws java.text.ParseException
Define the Otype from a String

Parameters:
text - the Otype as a string
Throws:
java.text.ParseException - when otype is not understandable

Otype

public Otype(int ot)
      throws java.text.ParseException
Define the Otype from an otype code (integer)

Parameters:
ot - the Otype as a coded integer
Throws:
java.text.ParseException - when otype is not understandable

Otype

public Otype(Otype ot)
Copy constructor

Parameters:
ot - Otype object to copy
Method Detail

hasValue

public boolean hasValue()
Check if this type has a value. An unknown type is different from nodata.

Returns:
true if it has a value, false otherwise.

reset

public void reset()
Reset this object type to its NODATA value. The NODATA value is different from the type 'unknown'.


getBinType

public final int getBinType()
Get the binary type

Returns:
the integer value

init

public static void init(java.lang.String filepath)
                 throws java.lang.Exception
Initialisation. It will be executed only once in an application.

Parameters:
filepath - full path of the file describing the Object Types. It can be a remote file (rfile:...)
Throws:
java.lang.Exception - e.g. IOException if file not existing, parsing...

reload

public static void reload()
                   throws java.lang.Exception
Reload the otype description file

Throws:
java.lang.Exception - in case of error

getLevel

public int getLevel()
Compute the level of the curent object type in the hierarchy

Returns:
the level (0 1 2 3 4)

level

public static final int level(int ot)
Compute the level of the submitted object type in the hierarchy

Parameters:
ot - an object type
Returns:
the level (0 1 2 3 4)

edit

protected static void edit(java.lang.StringBuffer buf,
                           int otype)
Edit the otype as xx.xx.xx.xx

Parameters:
buf - the buffer to which the ascii equivalent of otype is appended.
otype - the object type

ntype

public static final int ntype(java.lang.String s)
Interpret the 4 numbers as an Otype class.

Parameters:
s - the text to interpret
Returns:
The object type / -1 when error

getValue

public int getValue(int level)
Get the value of a particular level (0-4)

Parameters:
level - from 1 (main level) to 4 (today lowest one), 0 => nodata and returns value 0
Returns:
the level value

truncate

public final void truncate(int lev)
Truncate the otype to some upper level (e.g. Algol --> V*)

Parameters:
lev - the level (between 1 and 4)

upperLevel

public final void upperLevel()
Set the object type to one level higher.


implies

public final boolean implies(Otype t1)
Check if is a subtype (in same branch)

Parameters:
t1 - the other Otype
Returns:
true t1 is an upper class

agrees

public final boolean agrees(Otype ot1)
Check if the 2 Otypes are compatible

Parameters:
ot1 - the other Otype
Returns:
true t1 is compatible

getCompatibleTypes

public java.util.ArrayList getCompatibleTypes()
For the current type, get all compatible types in other branches

Returns:
an array list of all compatible types. The first item is the current type

merge

public final Otype merge(Otype ot1)
Choose the most accurate Otype: the deepest one ine the hierarchy.

Parameters:
ot1 - a second otype
Returns:
the 'most accurate' otype

mergepl

public final Otype mergepl(Otype ot2)
                    throws java.text.ParseException
Throws:
java.text.ParseException

set

protected final void set(int o)
                  throws java.text.ParseException
Convert an integer into an Otype

Parameters:
o - a number representing an otype
Throws:
java.text.ParseException - when the text can' be interpreted.

set

public final void set(java.lang.String text)
               throws java.text.ParseException
Convert a text into an object type

Parameters:
text - the text representing the otype, either in numeric, or as one of the available abbreviations
Throws:
java.text.ParseException - when the text can' be interpreted.

iterator

public static java.util.Iterator iterator()
Get an iterator on the object types

Returns:
an iterator browssing through the object types

list

public java.util.Enumeration list()
List in an enumeration all Otypes belonging to a class. Including bridges betwenn types

Returns:
An enumeration of Otypes in subtree

toString

public final java.lang.String toString()
Default Edition of the Otype value

Overrides:
toString in class java.lang.Object
Returns:
the "standard" explanation of the object type

toString

public java.lang.String toString(char cc)
Edition with options

Parameters:
cc - Option char. It can be:
N=numeric, S=standard, V=verbose, 3=3-letter
Returns:
the edited object

toString

public final java.lang.String toString(int choice)
Default Edition of the Otype value

Parameters:
choice - 0=numeric, 1=standard, 2=verbose, 3=3-letter
Returns:
the meaning of the Object Type

toString

public java.lang.String toString(java.lang.String opt)
Edition with options

Parameters:
opt - Option string. It can contain:
'N'=numeric, 'S'=standard, 'V'=verbose, '3'=3-letter
These options can be followed by '(level)', displaying only the corresponding level of otype.
Any other character will be displayed as a regular character
Returns:
the edited object type

dump

public final void dump()
Dump contents to stdout


numericToHexa

public java.lang.String numericToHexa()
Methode qui permet de transformer un otype decimal en hexadecimal

Returns:
chaine representant la valeur de otype en hexadecimal

hexaToNumeric

public static java.lang.String hexaToNumeric(java.lang.String strHex)
Methode qui transforme une chaine de caractere hexadecimale en otype sous forme numerique

Parameters:
strHex - chaine representant un otype sous forme hexadecimale
Returns:
otype sous forme numerique

equals

public boolean equals(java.lang.Object o)
MOD-BB 21-01-04 Ajout de cette methode. Test d'egalite de Otype.

Overrides:
equals in class java.lang.Object
Parameters:
o - Objet a comparer.
Returns:
Vrai si o est identique a this, faux sinon.

isUnknown

public boolean isUnknown()
Check if the object type is unknown

Returns:
true if it is unknown, false otherwise

clone

public java.lang.Object clone()
Copy values parameters

Overrides:
clone in class java.lang.Object
Returns:
a copy of the object

getList

public java.lang.String[] getList()
Gives all explanation string of otypes

Returns:
array of first level strings
See Also:
list()

getShortList

public java.lang.String[] getShortList()
See Also:
cds.util.ValueList#getShortList()

parse

public int parse(java.lang.String s)
          throws java.text.ParseException
Parse a string containing otype sting name

Parameters:
s - string to parse
Returns:
index of first char not used in the string
Throws:
java.text.ParseException
See Also:
set(java.lang.String)

parse

public int parse(java.lang.String s,
                 int offset)
          throws java.text.ParseException
Parse a string containing otype sting name

Parameters:
s - string to parse
offset - first char to parse in the string
Returns:
index of first char not used in the string
Throws:
java.text.ParseException
See Also:
set(java.lang.String)

getName

public java.lang.String getName()
Returns:
String object type

get

public java.lang.String get()
Returns:
String object type

getQueryMask

public int getQueryMask()
Get the querymask corresponding to the level of the current otype

Returns:
the query mask

getQueryMask

public int getQueryMask(int level)
Get the querymask of a given level

Parameters:
level - level to use to build the mask
Returns:
the query mask

getQueryValue

public int getQueryValue()
Get the query value (= the binary value of the current type)

Returns:
the binary value of the type

getQueryValueList

public java.lang.String getQueryValueList()
Build the where part of an SQL query corresponding to a given type extended to its compatible types. This is used by the criterion 'otypes'

Returns:
a where part between parenthesis which can be inserted in a SQL statement

hashCode

public int hashCode()
Compute the hashcode (overrides the Object method). The hashcode is the integer object type code

Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode value for the otype

getVersion

public static java.lang.String getVersion()
Get the version information. it is the last .VERSION entry in the otype.def file

Returns:
the version text

getVersionDate

public static java.lang.String getVersionDate()
Get the version date. It is in the last .VERSION entry in the otype.def file

Returns:
the version date

getDescription

public static java.lang.String getDescription()
Get the description text to display in the web page

Returns:
the description text