stella.xml
Class TargetHelper

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.xml.TargetHelper
All Implemented Interfaces:
Cloneable, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying
Direct Known Subclasses:
JTargetHelper

public class TargetHelper
extends PropertyBundles
implements Initializable

This class holds all STELLA-near implementations to help other classes to easily build xml-based TargetDefinitions. While the TargetFactory deals with more generic methods, this class contains all the work needed to construct default merits, constraints, object and guide star sections as well as necessary setup sections.
This class can be instantiated. Its properties are used to construct different TelescopeHelpers, which, in turn, provide access to type-specifiec properties via selecting a proper TypeHelper.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static String DEFTELESCOPE
          The default telescope properties.
private static String DEFURLRESOURCES
          The default path.
static String KEY_DURATION
          The duration of the observation.
static String KEY_FILE
          The key to the target-xml file name.
static String KEY_TARGETNAME
          The key to the object name.
static String KEY_TELESCOPE
          The key to the known telescope helper properties.
private  TelescopeHelper stella
          The telescope helper used.
private  Map telescopes
          The look-up table linking telescope names to telescope helpers.
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
TargetHelper(Map prop)
          Creates a new target helper with the specified properties.
 
Method Summary
 boolean addDurationFragment(Map xml)
          Adds the duration section as a part of a TargetFactory mapping.
 boolean addFileFragment(Map xml)
          Adds the file as a part of a TargetFactory mapping.
 boolean addTargetNameFragment(Map xml)
          Adds the target name as a part of a TargetFactory mapping.
static ElementHelper createElementHelper(Map prop)
          Creates a ElementHelper using the provided properties.
static ObjectHelper createObjectHelper(Map prop)
          Creates a ElementHelper using the provided properties.
static TelescopeHelper createTelescopeHelper(Map prop)
          Creates a TelescopeHelper using the provided properties.
static TypeHelper createTypeHelper(Map prop)
          Creates a TypeHelper using the provided properties.
protected  void error(String warn)
          Issues an error message.
 double getDuration()
          Returns the duration as a double.
 String getFile()
          Returns the target name.
 Map getKnownTelescopes()
          Returns all known telescope as a mapping of telescope names to telescope helpers.
 String getTargetName()
          Returns the target name.
 TelescopeHelper getTelescopeHelper()
          Returns the telescope helper in use.
protected  void info(String warn)
          Issues an info message.
 void init()
          Initlaizes the TelescopeHelpers known.
private static Object instantiate(String cname, Map prop)
          Searches the properties for the class entry.
 Document makeTarget()
          Sums up all information and constructs a new DOM target.
 boolean selectTelescope(String name)
          Select the telescope helper to use.
 void setDuration(double dur)
          Sets the duration.
 void setFile(String target)
          Sets the xml-file.
 void setTargetName(String target)
          Sets the target name.
protected  void warn(String warn)
          Issues a warning message.
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

KEY_TELESCOPE

public static final String KEY_TELESCOPE
The key to the known telescope helper properties.

See Also:
Constant Field Values

KEY_TARGETNAME

public static final String KEY_TARGETNAME
The key to the object name.

See Also:
Constant Field Values

KEY_FILE

public static final String KEY_FILE
The key to the target-xml file name.

See Also:
Constant Field Values

KEY_DURATION

public static final String KEY_DURATION
The duration of the observation.

See Also:
Constant Field Values

DEFURLRESOURCES

private static final String DEFURLRESOURCES
The default path.

See Also:
Constant Field Values

DEFTELESCOPE

private static final String DEFTELESCOPE
The default telescope properties.

See Also:
Constant Field Values

telescopes

private Map telescopes
The look-up table linking telescope names to telescope helpers.


stella

private TelescopeHelper stella
The telescope helper used.

Constructor Detail

TargetHelper

public TargetHelper(Map prop)
Creates a new target helper with the specified properties.

Method Detail

init

public void init()
Initlaizes the TelescopeHelpers known.

Specified by:
init in interface Initializable
Overrides:
init in class PropertyResources

getKnownTelescopes

public Map getKnownTelescopes()
Returns all known telescope as a mapping of telescope names to telescope helpers.


selectTelescope

public boolean selectTelescope(String name)
Select the telescope helper to use.

Returns:
True, if telescope helper is defined.

getTelescopeHelper

public TelescopeHelper getTelescopeHelper()
Returns the telescope helper in use.


setTargetName

public void setTargetName(String target)
Sets the target name. This is not equal to the ObjectHelper.resolveObjectName(java.lang.String) method, though it might take the same argument.


getTargetName

public String getTargetName()
Returns the target name. If the target name was not set, a warning is issued.


setFile

public void setFile(String target)
Sets the xml-file.


getFile

public String getFile()
Returns the target name. If the file name was not set, an info message is issued and the name returned is constructed from the target name.


getDuration

public double getDuration()
Returns the duration as a double.


setDuration

public void setDuration(double dur)
Sets the duration.


addTargetNameFragment

public boolean addTargetNameFragment(Map xml)
Adds the target name as a part of a TargetFactory mapping. If target name was not set, a warning is issued.


addFileFragment

public boolean addFileFragment(Map xml)
Adds the file as a part of a TargetFactory mapping. If the file-name is missing it is constructed from the target name, if the latter one is missing, a warning is issued.


addDurationFragment

public boolean addDurationFragment(Map xml)
Adds the duration section as a part of a TargetFactory mapping.


makeTarget

public Document makeTarget()
Sums up all information and constructs a new DOM target. It uses the factory methods of TargetFactory to first create all neccessarry target fragment and then convert it into an DOM object.


error

protected void error(String warn)
Issues an error message. This class pipes directly to Syslog.error.


warn

protected void warn(String warn)
Issues a warning message. This class pipes directly to Syslog.warning.


info

protected void info(String warn)
Issues an info message. This class pipes directly to Syslog.info.


createTelescopeHelper

public static TelescopeHelper createTelescopeHelper(Map prop)
Creates a TelescopeHelper using the provided properties. If the properties do not contain a PropertySupplying.KEY_CLASS property the standard TelescopeHelper class is used. If one wants to create daughter classes of the TelescopeHelper, e.g. to provide GUI-enhanced functionality, the properties should contain a class entry of this telescope helper subclass.


createTypeHelper

public static TypeHelper createTypeHelper(Map prop)
Creates a TypeHelper using the provided properties. If the properties do not contain a PropertySupplying.KEY_CLASS property the standard TypeHelper class is used. If one wants to create daughter classes of the TypeHelper, e.g. to provide GUI-enhanced functionality, the properties should contain a class entry of this telescope helper subclass.


createElementHelper

public static ElementHelper createElementHelper(Map prop)
Creates a ElementHelper using the provided properties. If the properties do not contain a PropertySupplying.KEY_CLASS property the standard ElementHelper class is used. If one wants to create daughter classes of the ElementHelper, e.g. to provide GUI-enhanced functionality, the properties should contain a class entry of this telescope helper subclass.


createObjectHelper

public static ObjectHelper createObjectHelper(Map prop)
Creates a ElementHelper using the provided properties. If the properties do not contain a PropertySupplying.KEY_CLASS property the standard ElementHelper class is used. If one wants to create daughter classes of the ElementHelper, e.g. to provide GUI-enhanced functionality, the properties should contain a class entry of this telescope helper subclass.


instantiate

private static final Object instantiate(String cname,
                                        Map prop)
Searches the properties for the class entry. This class is then located by name, a constructor taking a single map as argument is searched and the properties handed over are then used to instantiate a new object of this class. If this new object implements the Initializable interface, its Initializable.init() method is called.