|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PropertyContainer
util.PropertyResources
util.PropertyBundles
stella.xml.TypeHelper
public class TypeHelper
A type helper knows how to match a special object type on a given telescope
to default setups. It knows how to construct the following items using
ElementHelpers:
KEY_REQUIRES key points to
a simple string, that is a parsable boolean expression at run-time. The
KEY_CONSTRAINTS key is a list of properties that define all
required constraints for the target. The KEY_TIMESLOTS and
KEY_GAINS lists are properties of the target-specific
merits. Merits that need certain constants know their names, but the
values must be filled in at run-time.KEY_EXCEPTIONS are properties
to element helpersKEY_ABSTRACT,
provided the telescope halper has been set.KEY_FITSHEADERS key. Each entry are properties of an
ElementHelper
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class util.PropertyResources |
|---|
PropertyResources.URLResource |
| Field Summary | |
|---|---|
private Map |
constraints
The constraints as a map of element helpers to their variables. |
private List |
daughters
The list of daughter targets. |
private static String |
DEFABSTRACT
The default abstract. |
private static String |
DEFACCESS
The default access. |
private static String |
DEFPROPOSAL
The default abstract. |
private static String |
DEFREQUIRES
The default roof-open condition. |
private static String |
DEFURLRESOURCES
The default path. |
private Map |
exceptions
The exceptions, if any, a mapping of element helpers to 'for'. |
private Map |
fitsheaders
The mapping of fits-headers, as element headers, to fits IDs. |
private Map |
gains
The gains, a map of element helpers to their classes. |
static String |
KEY_ABSTRACT
The abstract section. |
static String |
KEY_ACCESS
The access to this target. |
static String |
KEY_CONSTRAINTS
A list of constraints properties, as ElementHelpers. |
static String |
KEY_DAUGHTERS
The list of daughters. |
static String |
KEY_EXCEPTIONS
A list of setup properties, as ElementHelpers. |
static String |
KEY_FITSHEADERS
A list of fitsheader properties, as ElementHelpers. |
static String |
KEY_GAINS
A list of gain properties, as ElementHelpers. |
static String |
KEY_HELPERCLASS
The key mapping to the type helper class name. |
static String |
KEY_OBJECTS
A list of object IDs. |
static String |
KEY_PROPOSAL
The proposal section, an attribute to abstract. |
static String |
KEY_RATEHOW
A list of constraints properties, as ElementHelpers. |
static String |
KEY_RATEWHEN
The requirement in the select section. |
static String |
KEY_REQUIRES
The requirement in the select section. |
static String |
KEY_SEQUENCE
The observing sequence this type requires. |
static String |
KEY_SETUPS
A list of setup properties, as ElementHelpers. |
static String |
KEY_SUCCESSOR
The successor target. |
static String |
KEY_TIMESLOTS
A list of timeslot properties, as ElementHelpers. |
static String |
KEY_TYPE
The type of object this helper is bound to. |
private Map |
objects
The mapping of object, as object helpers to object IDs. |
private Map |
rate
The rating constraints as a map of element helpers to variables. |
private Map |
setups
The mapping of instrument setups, as element helpers, to setup ID. |
private Map |
timeslots
The time-slots, a map of element helpers to their classes. |
| 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 | |
|---|---|
TypeHelper(Map prop)
Constructs a new type helper. |
|
| Method Summary | |
|---|---|
boolean |
addAbstractFragment(Map xml)
Adds the abstract section as a part of a TargetFactory
mapping. |
boolean |
addConstraint(String file)
Add a constraint by a named resource. |
boolean |
addDaughterFragment(Map xml)
Adds the daughters to the target fragments of the TargetFactory
mapping. |
boolean |
addExceptionFragment(Map xml)
Adds the exception maps as a part of a TargetFactory mapping. |
boolean |
addFitsHeaderFragment(Map xml)
Adds the fits headers sections to the target fragments. |
boolean |
addObjectFragment(Map xml)
Adds the object helpers as object-fagements to the TargetFactory
mapping. |
boolean |
addRateFragment(Map xml)
Adds the rate criterium as a part of a TargetFactory mapping. |
boolean |
addRating(String file)
Add a rating by a named resource. |
boolean |
addSelectFragment(Map xml)
Adds the select criterium as a part of a TargetFactory mapping. |
boolean |
addSetupFragment(Map xml)
Adds the setup sections as a part of a TargetFactory mapping. |
boolean |
addSuccessorFragment(Map xml)
Adds the successor to the target fragment of the TargetFactory
mapping. |
private static List |
createConstraintElements(Collection constraints)
Converts ElementHelpers into constraint elements. |
private List |
createElementHelpers(String props)
Converts a comma-separated list of property files into a list of ElementHelpers by reading the properties and passing them to
the element helper constructor. |
private Map |
createHelperMap(String props)
Converts a comma-separted list of proprty files into a mapping of { ElementHelpers to keys queried from the helpers by asking their
property named according to the second argument. |
private static List |
createMeritElements(String tag,
Collection merit)
Converts ElementHelpers into Merit elements. |
protected void |
error(String warn)
Issues an error message. |
private ElementHelper |
fromResourceName(String file)
Creates a single element helper from a specified named resource, normally a properties file. |
String |
getAbstract()
Returns the abstract. |
String |
getAccess()
Returns the access flag of the target. |
Collection |
getAllConstraints()
Returns the list of constraints as a list of ElementHelpers. |
Collection |
getAllExceptions()
Returns a collection of all exceptions as a collection of ElementHelpers. |
Collection |
getAllFitsHeaders()
Returns the fits headers as a collections of ElementHelpers. |
Collection |
getAllGains()
Returns the list of gains as a list of ElementHelpers. |
Collection |
getAllObjects()
Returns the objects as a collections of ObjectHelpers. |
Collection |
getAllRatings()
Returns the list of rating constraints as a collection of ElementHelpers. |
Collection |
getAllSetups()
Returns the setups as a collection of ElementHelpers. |
Collection |
getAllTimeslots()
Returns the list of timeslots as a list of ElementHelpers. |
ElementHelper |
getConstraintByID(Object whom)
Returns the constraint which applies to the variable of the given name. |
List |
getDaughters()
Returns a string-list of daughter targets or null. |
ElementHelper |
getExceptionByID(String whom)
Returns the exception element helper with the given 'for' attribute. |
ElementHelper |
getFitsHeaderByID(String id)
Returns the fitsheader element helper with the given ID attribute. |
ElementHelper |
getGainByID(Object clname)
Returns the gain with has the specified class. |
ObjectHelper |
getObjectByID(String id)
Returns the object helper with the given ID attribute. |
String |
getProposal()
Returns the proposal. |
String |
getRateWhen()
Returns the requirement for object selection as a string. |
ElementHelper |
getRatingByID(Object whom)
Returns the rating constraint which applies to the variable of the given name. |
String |
getRequirement()
Returns the requirement for object selection as a string. |
String |
getSequence()
Returns the observing sequence for this type. |
ElementHelper |
getSetupByID(String id)
Returns the setup element helper with the given ID attribute. |
String |
getSuccessor()
Returns the successor target or null. |
ElementHelper |
getTimeslotByID(Object clname)
Returns the timeslot with has the specified class. |
String |
getType()
Returns the type this helper is bound to. |
protected void |
info(String warn)
Issues an info message. |
void |
init()
Uses the property files provided for the KEY_CONSTRAINTS,
KEY_TIMESLOTS, KEY_GAINS, KEY_EXCEPTIONS,
KEY_SETUPS, KEY_OBJECTS, and KEY_FITSHEADERS
to construct the specified lists of element helpers. |
void |
setAbstract(String abstr)
Sets the abstract. |
void |
setAccess(String newacc)
Sets the access flag. |
void |
setDaughters(List dau)
Sets the list of daughters. |
void |
setProposal(String abstr)
Sets the abstract. |
void |
setRateWhen(String req)
Sets the requirement for object selection. |
void |
setRequirement(String req)
Sets the requirement for object selection. |
void |
setSequence(String seq)
Sets the sequence type. |
void |
setSuccessor(String succ)
Sets the successor target. |
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 |
|---|
public static final String KEY_HELPERCLASS
public static final String KEY_TYPE
public static final String KEY_SEQUENCE
public static final String KEY_ACCESS
public static final String KEY_ABSTRACT
public static final String KEY_PROPOSAL
public static final String KEY_REQUIRES
public static final String KEY_CONSTRAINTS
ElementHelpers.
public static final String KEY_RATEWHEN
public static final String KEY_RATEHOW
ElementHelpers.
public static final String KEY_TIMESLOTS
ElementHelpers.
public static final String KEY_GAINS
ElementHelpers.
public static final String KEY_EXCEPTIONS
ElementHelpers.
public static final String KEY_SETUPS
ElementHelpers.
public static final String KEY_OBJECTS
public static final String KEY_FITSHEADERS
ElementHelpers.
public static final String KEY_DAUGHTERS
public static final String KEY_SUCCESSOR
private static final String DEFURLRESOURCES
private static final String DEFACCESS
private static final String DEFABSTRACT
private static final String DEFPROPOSAL
private static final String DEFREQUIRES
private Map constraints
private Map timeslots
private Map gains
private Map rate
private Map exceptions
private Map setups
private Map fitsheaders
private Map objects
private List daughters
| Constructor Detail |
|---|
public TypeHelper(Map prop)
KEY_ABSTRACT and the KEY_REQUIRES are defaulted.
| Method Detail |
|---|
public void init()
KEY_CONSTRAINTS,
KEY_TIMESLOTS, KEY_GAINS, KEY_EXCEPTIONS,
KEY_SETUPS, KEY_OBJECTS, and KEY_FITSHEADERS
to construct the specified lists of element helpers.
init in interface Initializableinit in class PropertyResourcespublic boolean addAbstractFragment(Map xml)
TargetFactory
mapping. The text of the abstract is submitted to the
TargetFactory#createAbstract} method, if the abstract text is
defined.
public boolean addSelectFragment(Map xml)
TargetFactory mapping.
This requires that the KEY_REQUIRES is set, that all
constraints are valid, and that all timeslots and gains are defined and
valid. The constrains are converted from ElementHelpers to
a list of ParsedTarget.Constraints by passing all variables,
which are present as doubles, to the ParsedTarget.Constraint
constructor. The merits are converted into lists of merits using
the TargetFactory.createMerit(java.lang.String, java.lang.String, java.lang.String, java.util.Map) method.
public boolean addRateFragment(Map xml)
TargetFactory mapping.
This allows that the KEY_RATEWHEN is set and that all
constraints specified are valid. The constrains are converted from
ElementHelpers to
a list of ParsedTarget.Constraints by passing all variables,
which are present as doubles, to the ParsedTarget.Constraint
constructor.
public boolean addExceptionFragment(Map xml)
TargetFactory mapping.
All exception elements are non-obligatory, thus no validity checking
is done.
public boolean addSetupFragment(Map xml)
TargetFactory mapping.
First, the setups are tested for validity, then they are added to
the target factory.
public boolean addFitsHeaderFragment(Map xml)
TargetFactory.createFitsHeader(java.lang.String, java.util.List, java.util.Map) method, the list added to
the document fragment must already be a list of FITSheader
elements. These are constructed with the
TargetFactory.createInternFitsHeader(java.lang.String, java.lang.String, java.lang.String) method.ElementHelpers, but here the keys in the
UserAdjustable.getVariables()-returned map are already the fits
keys, the values linked to them are the variable names. If comments
should be added, they are merged into the user-adjustable map with
keys ending as ElementHelper.KEY_APPENDIX.
public boolean addObjectFragment(Map xml)
TargetFactory
mapping. If any object is not valid, no object is added.
public boolean addDaughterFragment(Map xml)
TargetFactory
mapping.
public boolean addSuccessorFragment(Map xml)
TargetFactory
mapping.
public String getType()
public String getAccess()
public void setAccess(String newacc)
public String getSequence()
public void setSequence(String seq)
public String getAbstract()
public void setAbstract(String abstr)
public String getProposal()
public void setProposal(String abstr)
public String getRequirement()
public void setRequirement(String req)
public String getRateWhen()
public void setRateWhen(String req)
public List getDaughters()
public void setDaughters(List dau)
public String getSuccessor()
public void setSuccessor(String succ)
public Collection getAllConstraints()
ElementHelpers.
Can be null.
public ElementHelper getConstraintByID(Object whom)
public boolean addConstraint(String file)
public Collection getAllRatings()
ElementHelpers. Can be null.
public ElementHelper getRatingByID(Object whom)
public boolean addRating(String file)
public Collection getAllTimeslots()
ElementHelpers.
Can be null.
public ElementHelper getTimeslotByID(Object clname)
public Collection getAllGains()
ElementHelpers.
Can be null.
public ElementHelper getGainByID(Object clname)
public Collection getAllExceptions()
ElementHelpers. Can be null.
public ElementHelper getExceptionByID(String whom)
public Collection getAllSetups()
ElementHelpers. Always
defined if object survived initialization.
public ElementHelper getSetupByID(String id)
public Collection getAllFitsHeaders()
ElementHelpers.
Can be null.
public ElementHelper getFitsHeaderByID(String id)
public Collection getAllObjects()
ObjectHelpers.
Can be null.
public ObjectHelper getObjectByID(String id)
protected void error(String warn)
protected void warn(String warn)
protected void info(String warn)
private ElementHelper fromResourceName(String file)
private List createElementHelpers(String props)
ElementHelpers by reading the properties and passing them to
the element helper constructor.
private Map createHelperMap(String props)
ElementHelpers to keys queried from the helpers by asking their
property named according to the second argument. A warning is issued if
two identical mappings exist, in which case only the later on is kept.
Note that this method can only work correctly if the value of the
ID-field is already set after initialization, i.e. it must be
specified in the ElementHelper.KEY_INIT section.
private static List createConstraintElements(Collection constraints)
ElementHelpers into constraint elements. This is done
by constructing ParsedTarget#Constraints on fully-qulified
element helpers. The validity of those has been checked, thus no
further tests are commenced.
private static List createMeritElements(String tag,
Collection merit)
ElementHelpers into Merit elements. This is done by
invoking the TargetFactory.createMerit(java.lang.String, java.lang.String, java.lang.String, java.util.Map) method on fully-qulified
element helpers. The validity of those has been check, thus no further
test are commenced.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||