astro.fits
Class HeaderCardDescriptor

java.lang.Object
  extended by astro.fits.HeaderCardDescriptor
All Implemented Interfaces:
Serializable

public class HeaderCardDescriptor
extends Object
implements Serializable

A helper class that bundles FITS-header cards into descriptors that can then be resolved at run-time to provide true header cards.

See Also:
Serialized Form

Nested Class Summary
static class HeaderCardDescriptor.Type
          How the string descriptor should be converted into a value.
 
Field Summary
private  String describe
           
private static DateFormat FITSDATE
          The formatter for fits dates.
private  HeaderCardDescriptor.Type how
           
private  String key
           
private  String rem
           
 
Constructor Summary
HeaderCardDescriptor(String k, String value, String comment)
           
HeaderCardDescriptor(String k, String value, String comment, HeaderCardDescriptor.Type parse)
           
 
Method Summary
 boolean equals(Object that)
          Equal, key, descriptor and how.
static List<HeaderCardDescriptor> fromProperty(String t)
          Convenience method that parses a property string into a list of header card descriptos.
static List<HeaderCardDescriptor> fromProperty(String t, HeaderCardDescriptor.Type def)
          Convenience method that parses a property string into a list of header card descriptos.
 String getComment()
          Returns the comment, if any.
 String getDescription()
          Returns the value descriptor part of this object.
 String getKey()
          Returns the key, not trimmed to any required length.
 int hashCode()
          Hash code of key.
static HeaderCardDescriptor parse(String p)
          Parses a header card description from a single string.
static HeaderCardDescriptor parse(String p, HeaderCardDescriptor.Type deftype)
          Parses a header card description from a single string.
private static Object probe(Object value)
          Tries to convert a string value into a fits-header key understandable object.
 nom.tam.fits.HeaderCard toCard(ParameterClustering set, Map<String,Object> extern)
          Converts the header card descriptor to a valid herader card reference at run-time, allowing filling in of values for sysmbols.
 String toString()
          Reveresers the parse operation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FITSDATE

private static final DateFormat FITSDATE
The formatter for fits dates.


key

private String key

describe

private String describe

rem

private String rem

how

private HeaderCardDescriptor.Type how
Constructor Detail

HeaderCardDescriptor

public HeaderCardDescriptor(String k,
                            String value,
                            String comment)

HeaderCardDescriptor

public HeaderCardDescriptor(String k,
                            String value,
                            String comment,
                            HeaderCardDescriptor.Type parse)
Method Detail

getDescription

public String getDescription()
Returns the value descriptor part of this object. This is either a parameter name in a parameter set, a key name in an external map or the value itself in string form.


getKey

public String getKey()
Returns the key, not trimmed to any required length.


getComment

public String getComment()
Returns the comment, if any.


toCard

public nom.tam.fits.HeaderCard toCard(ParameterClustering set,
                                      Map<String,Object> extern)
                               throws nom.tam.fits.HeaderCardException
Converts the header card descriptor to a valid herader card reference at run-time, allowing filling in of values for sysmbols. The actual replacement is done as follows: If the Descriptor is of type PARAMETER, the parameter cluster is scanned for a parameter of the getDescription() part of the descriptor. If this parameter is found, and has a none-null value, we probe(java.lang.Object) for its run-time class before converting the parameter value to the header card. If the type is EXTERNAL, the external map is used to find a value according to the descriptors name. Again, the return value is probed for its type. A PROBE type means the the string descriptor itself is probed for conversion to any of the HeaderCard supported classes Long, Double, or Boolean (fallback is String), a type of NONE always returns the desriptor as a string value header card.

Throws:
nom.tam.fits.HeaderCardException

probe

private static Object probe(Object value)
Tries to convert a string value into a fits-header key understandable object. If argument is not a string, return the arguemtn.


hashCode

public int hashCode()
Hash code of key.

Overrides:
hashCode in class Object

equals

public boolean equals(Object that)
Equal, key, descriptor and how. If comments are both there, they must be equal, too.

Overrides:
equals in class Object

toString

public String toString()
Reveresers the parse operation.

Overrides:
toString in class Object

parse

public static HeaderCardDescriptor parse(String p)
                                  throws ParseException
Parses a header card description from a single string.

Throws:
ParseException

parse

public static HeaderCardDescriptor parse(String p,
                                         HeaderCardDescriptor.Type deftype)
                                  throws ParseException
Parses a header card description from a single string.

Throws:
ParseException

fromProperty

public static List<HeaderCardDescriptor> fromProperty(String t)
Convenience method that parses a property string into a list of header card descriptos. Parts that cannot be parsed are silently ignored.


fromProperty

public static List<HeaderCardDescriptor> fromProperty(String t,
                                                      HeaderCardDescriptor.Type def)
Convenience method that parses a property string into a list of header card descriptos. Parts that cannot be parsed are silently ignored.