stella.xml
Class DOMTools

java.lang.Object
  extended by stella.xml.DOMTools
All Implemented Interfaces:
DTDConstants

public class DOMTools
extends Object
implements DTDConstants

A helper class consisting only of static methods that are used to convert DOM Nodes to java classes. Provides also very specific methods only useful for DOMTargets.

See Also:
DOMHelper

Field Summary
static String KEY_DEF
          The key-header to the default position elements.
 
Fields inherited from interface stella.xml.DTDConstants
ABORT, ABOVE, ABSTRACT, ABSTRACTPROPOSAL, ADDRESS, BELOW, BLOCK, BROADCAST, BROADCASTWITH, BV, CHANGE, CLASS, COMMAND, COMMANDID, COMMANDINIT, COMMANDLAST, COMMANDPARAMETER, COMMANDREF, COMMENT, COMPLETE, CONDITION, CONSTANT, CONSTANTNAME, CONSTANTVALUE, CONSTRAINT, CONSTRAINTOVERDUE, CONSTRAINTRELAX, DATA, DAUGHTER, DEC, DELAY, DELAYMAX, DELAYTIME, DISABLED, DOCPATH, DURATION, ELAPSED, EMAIL, ENABLED, EPOCH, EQUINOX, EXCEPTION, EXCEPTIONDAUGHTER, EXCEPTIONFOR, EXCEPTIONSUCCESSOR, EXCEPTIONTHIS, FALSE, FIELDOFVIEW, FILE, FITSHEADER, FITSHEADERID, FORMATCLASS, FORMATPATTERN, FROM, GAIN, HISTORY, HISTORYCOMPLETE, HISTORYDB, HISTORYMAX, HISTORYREAD, IGNORE, IMAGETYPE, INIT, INSTITUTION, INSTRUMENT, INTERN, KEY, MAX, MERIT, MIN, NOTIFY, OBJECT, OBJECTID, OBJECTNAME, OBSERVSTART, PICK, PICKMERIT, PICKSUCCESS, PMDEC, PMRA, POSITION, RA, RATE, REC, REQUIRES, RETRY, RETRYMAX, SELECT, SENDING, SEQUENCE, SEQUENCETYPE, SET, SETNAME, SETUP, SETUPID, STEP, STEPCOUNTER, STEPWHILE, SUCCESSOR, TARGET, TARGETACCESS, TARGETDB, TARGETNAME, TARGETNAMEPROPOSAL, TARGETREAD, TARGETSUBMITTED, TARGETTYPE, TASK, TASKDONE, TASKID, TEAM, TIMESLOT, TITLE, TO, TRUE, USER, V, VARIABLE
 
Constructor Summary
DOMTools()
           
 
Method Summary
static Element addClassAttribute(Element to, Object instance)
          Adds an attribute stating the class name to the given element.
static Element addConstantToElement(Element src, Map constant)
          Appends several constants sections as child nodes to the target element.
static List createMerit(NodeList nl)
          Scans a node-list of merits into actual living merit references.
static Element fillMerit(Element src, Meriting merit)
          Fills a merit definition in the element.
static Element fillPosition(Element src, StarDescription star)
          Adds position data from a {link @StarDescription} into the container element provided.
static Class getClassFromElement(Element check)
          Returns the class specified as a DTDConstants.CLASS attribute to an element.
static List getConstantFromTable(Document builder, Map con)
          Converts the content of a map into a list of elements constituted of DTDConstants.CONSTANT elements, where the keys are specified with DTDConstants.CONSTANTNAME and the values with DTDConstants.CONSTANTVALUE.
static Object getInstanceFromElement(Element cls, String init)
          Returns a new instance of a class specified as a DTDConstants.CLASS attribute to an element.
static StarDescription getStarFromElement(Element star)
          Converts a position or field of view star sub section into a StarDescription object.
static Map getTableFromConstant(Element constant)
          Converts DTDConstants.CONSTANT sub-nodes of the given element into a mapping of names to values.
static Element insert(StarDescription entry, Element container, Node anchor, Map prop)
          Appends astrometrical star data to the given element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_DEF

public static final String KEY_DEF
The key-header to the default position elements.

See Also:
Constant Field Values
Constructor Detail

DOMTools

public DOMTools()
Method Detail

getTableFromConstant

public static final Map getTableFromConstant(Element constant)
Converts DTDConstants.CONSTANT sub-nodes of the given element into a mapping of names to values. If the DTDConstants.CLASS attribute is specified, the values found are parsed into objects of that type.

Returns:
A map with constant names as key or an empty map.

getConstantFromTable

public static final List getConstantFromTable(Document builder,
                                              Map con)
Converts the content of a map into a list of elements constituted of DTDConstants.CONSTANT elements, where the keys are specified with DTDConstants.CONSTANTNAME and the values with DTDConstants.CONSTANTVALUE. The instant type of the value enters the DTDConstants.CONSTANT section as a DTDConstants.CLASS attribute.

Parameters:
builder - The root document to create the required DOM-nodes.
con - The name-to-value mapping to convert.
Returns:
An list of DTDConstants.CONSTANT elements.

addConstantToElement

public static final Element addConstantToElement(Element src,
                                                 Map constant)
Appends several constants sections as child nodes to the target element. This method first builds a list of constant elements from the argument map, getConstantFromTable(org.w3c.dom.Document, java.util.Map), then adds this element-by-element as child to the target element.


getClassFromElement

public static final Class getClassFromElement(Element check)
Returns the class specified as a DTDConstants.CLASS attribute to an element. If no such attribute is given, null is returned.


getInstanceFromElement

public static final Object getInstanceFromElement(Element cls,
                                                  String init)
Returns a new instance of a class specified as a DTDConstants.CLASS attribute to an element. The string passed as the initial value is used in the constructor of the class to create the new instance.

Parameters:
cls - The element that carries the class attribute.
init - The string used in initialization in the single-string constructor.
Returns:
A new instance of the specified class or null if instantiation failed.

addClassAttribute

public static final Element addClassAttribute(Element to,
                                              Object instance)
Adds an attribute stating the class name to the given element. The second argument handed over is queried for its class.


getStarFromElement

public static StarDescription getStarFromElement(Element star)
Converts a position or field of view star sub section into a StarDescription object. At least ra and dec must be present. The name of the star is never set because it is not part of a DTDConstants.POSITION element.


insert

public static Element insert(StarDescription entry,
                             Element container,
                             Node anchor,
                             Map prop)
Appends astrometrical star data to the given element. The data was previously fetched from a tycho2-database lookup and is handed over as a primitive StarDescription type. The stated DOM element must support theses fields in the stated sequence as the childs immediately before the given anchor.: Fields not found in the database query are either filled with default values (see list), or, if the element is a required one, the star description is not inserted at all. Fields found in the database but already set in the containing element are discarded.

If the StarDescription argument is null this method acts like a test for completeness of the required elements.

Parameters:
entry - The tycho-database query result to be inserted.
container - The element where the database results should be inserted
anchor - The child node before which the database results should be inserted. If null, values are appended.
Returns:
The container with the new elements inserted

createMerit

public static final List createMerit(NodeList nl)
Scans a node-list of merits into actual living merit references.


fillMerit

public static final Element fillMerit(Element src,
                                      Meriting merit)
Fills a merit definition in the element. The source element is provided to allow the caller to specify different tag names for merits, e.g. DTDConstants.GAIN or DTDConstants.TIMESLOT


fillPosition

public static final Element fillPosition(Element src,
                                         StarDescription star)
Adds position data from a {link @StarDescription} into the container element provided.