org.jscience.ml.om
Class Target

java.lang.Object
  extended by org.jscience.ml.om.SchemaElement
      extended by org.jscience.ml.om.Target
All Implemented Interfaces:
IExtendableSchemaElement, ISchemaElement, ITarget
Direct Known Subclasses:
DeepSkyTarget, SolarSystemTarget

public abstract class Target
extends SchemaElement
implements ITarget

The abstract class Target provides some common features that may be used by the subclasses of an org.jscience.ml.om.ITarget.
The Target class stores the name, alias names and the position of an astronomical object. It also provides some basic access methods for these attributes. Additionally It implements a basic XML DOM helper method that may be used by all subclasses that have to implement the ITarget interface.

Since:
1.0

Field Summary
 
Fields inherited from interface org.jscience.ml.om.ITarget
XML_ELEMENT_ALIASNAME, XML_ELEMENT_CONSTELLATION, XML_ELEMENT_DATASOURCE, XML_ELEMENT_NAME, XML_ELEMENT_TARGET, XML_XSI_TYPE
 
Fields inherited from interface org.jscience.ml.om.ISchemaElement
XML_ELEMENT_ATTRIBUTE_ID
 
Constructor Summary
protected Target(org.w3c.dom.Node targetElement, IObserver[] observers)
          Constructs a new instance of a Target from a given DOM target Element.
protected Target(java.lang.String name, IObserver observer)
          Protected Constructor used by subclasses construction.
protected Target(java.lang.String name, java.lang.String datasource)
          Protected Constructor used by subclasses construction.
 
Method Summary
 boolean addAliasName(java.lang.String newAliasName)
          Adds a new alias name to the Target e.g. name = M42 ; alias name = "Great Orion Nebulae"
 boolean addAliasNames(java.lang.String aliasNames)
          Adds a comma seperated list of new alias names to the Target.
 org.w3c.dom.Element addAsLinkToXmlElement(org.w3c.dom.Element element)
          Adds the target link to an given XML DOM Element The target element itself will be attached to given elements ownerDocument.
abstract  org.w3c.dom.Element addToXmlElement(org.w3c.dom.Element element)
          Adds this Target to a given parent XML DOM Element.
protected  org.w3c.dom.Element createXmlTargetElement(org.w3c.dom.Element parent)
          Creates an XML DOM Element for the Target.
 java.lang.String[] getAliasNames()
          Returns all alias names.
 java.lang.String getConstellation()
          Returns the celestial constellation, where the target can be found.
 java.lang.String getDatasource()
          Returns the datasource which is the origin of the target.
 java.lang.String getDisplayName()
          Returns a display name for this element.
 java.lang.String getName()
          Returns the name of the target.
 IObserver getObserver()
          Returns the observer who is the originator of the target.
 EquPosition getPosition()
          Returns the position of the target.
 boolean removeAliasName(java.lang.String aliasName)
          Removes a alias name from the target.
 void setAliasNames(java.lang.String[] newAliasNames)
          Sets an array of new alias names to this target.
 void setConstellation(java.lang.String constellation)
          Sets the celestial constellation, where the target can be found.
 void setDatasource(java.lang.String datasource)
          Sets the datasource of the target.
 void setName(java.lang.String name)
          Sets the name of the target.
 void setObserver(IObserver observer)
          Sets the observer who is the originator of the target.
 void setPosition(EquPosition position)
          Sets the position of the target.
 
Methods inherited from class org.jscience.ml.om.SchemaElement
getID, setID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jscience.ml.om.ISchemaElement
getID
 
Methods inherited from interface org.jscience.ml.om.IExtendableSchemaElement
getXSIType
 

Constructor Detail

Target

protected Target(org.w3c.dom.Node targetElement,
                 IObserver[] observers)
          throws SchemaException
Constructs a new instance of a Target from a given DOM target Element.
Normally this constructor is called by a child class which itself was called by org.jscience.ml.om.util.SchemaLoader. Please mind that Target has to have a element, or a element. If a element is set, a array with Observers must be passed to check, whether the link is valid.

Parameters:
observers - Array of IObserver that might be linked from this observation, can be NULL if datasource element is set
targetElement - The origin XML DOM Element
Throws:
SchemaException - if given targetElement was null

Target

protected Target(java.lang.String name,
                 java.lang.String datasource)
          throws java.lang.IllegalArgumentException
Protected Constructor used by subclasses construction.

Parameters:
name - The name of the astronomical object
datasource - The datasource which is the origin of the astronomical object
Throws:
java.lang.IllegalArgumentException - if name or datasource was null

Target

protected Target(java.lang.String name,
                 IObserver observer)
          throws java.lang.IllegalArgumentException
Protected Constructor used by subclasses construction.

Parameters:
name - The name of the astronomical object
observer - The observer which is the originator of the astronomical object
Throws:
java.lang.IllegalArgumentException - if name or observer was null
Method Detail

getDisplayName

public java.lang.String getDisplayName()
Returns a display name for this element.
The method differs from the toString() method as toString() shows more technical information about the element. Also the formating of toString() can spread over several lines.
This method returns a string (in one line) that can be used as displayname in e.g. a UI dropdown box.

Specified by:
getDisplayName in interface ISchemaElement
Specified by:
getDisplayName in class SchemaElement
Returns:
Returns a String with a one line display name
See Also:
java.lang.Object.toString();

addToXmlElement

public abstract org.w3c.dom.Element addToXmlElement(org.w3c.dom.Element element)
Adds this Target to a given parent XML DOM Element. The Target element will be set as a child element of the passed element.

Specified by:
addToXmlElement in interface ITarget
Parameters:
parent - The parent element for this Target
Returns:
Returns the element given as parameter with this Target as child element.
Might return null if parent was null.
See Also:
Element

addAsLinkToXmlElement

public org.w3c.dom.Element addAsLinkToXmlElement(org.w3c.dom.Element element)
Adds the target link to an given XML DOM Element The target element itself will be attached to given elements ownerDocument. If the ownerDocument has no target container, it will be created.
Example:
<parameterElement>
<targetLink>123</targetLink>
</parameterElement>
More stuff of the xml document goes here
<targetContainer>
<target id="123">
target description goes here
</target>
</targetContainer>

Specified by:
addAsLinkToXmlElement in interface ITarget
Parameters:
parent - The element under which the the target link is created
Returns:
Returns the Element given as parameter with a additional target link, and the target element under the target container of the ownerDocument Might return null if element was null.
See Also:
Element

addAliasName

public boolean addAliasName(java.lang.String newAliasName)
Adds a new alias name to the Target e.g. name = M42 ; alias name = "Great Orion Nebulae"

Specified by:
addAliasName in interface ITarget
Parameters:
newAliasName - A new alias name
Returns:
Returns true if the alias name could be added. If false is returned the new alias was null or an empty String.

setAliasNames

public void setAliasNames(java.lang.String[] newAliasNames)
Sets an array of new alias names to this target.
All current aliasNames will be deleted! If you want to add alias names without deleting the existing ones, please use Target.addAliasNames(String) or Target.addAliasName(String).
If null is passed, the given alias names are deleted.

Specified by:
setAliasNames in interface ITarget
Parameters:
newAliasNames - An arry with new alias name

getAliasNames

public java.lang.String[] getAliasNames()
Returns all alias names.

Specified by:
getAliasNames in interface ITarget
Returns:
Returns a String array with all alias names. If no alias names were set null is returned.

removeAliasName

public boolean removeAliasName(java.lang.String aliasName)
Removes a alias name from the target.

Specified by:
removeAliasName in interface ITarget
Parameters:
aliasName - The alias name that should be removed
Returns:
Returns true if the alias name could be removed from the target. If false is returned the given alias name could not be found in the targets alias name list or the parameter was null or contained a empty string.

getName

public java.lang.String getName()
Returns the name of the target.
The name should clearly identify the astronomical object. Use alias names for colloquial names of the object.

Specified by:
getName in interface ITarget
Returns:
Returns the name of the astronomical object

getConstellation

public java.lang.String getConstellation()
Returns the celestial constellation, where the target can be found.
Might return NULL if constellation was never set

Specified by:
getConstellation in interface ITarget
Returns:
The celestial constellation

setConstellation

public void setConstellation(java.lang.String constellation)
Sets the celestial constellation, where the target can be found.

Specified by:
setConstellation in interface ITarget
Parameters:
constellation - The celestial constellation of the target

setName

public void setName(java.lang.String name)
             throws java.lang.IllegalArgumentException
Sets the name of the target.
The name should clearly identify the astronomical object. For alternative names of the object add a new alias name.
If a name is already set to the target, the old name will be overwritten with new new name.

Specified by:
setName in interface ITarget
Parameters:
name - DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - if name was null

getPosition

public EquPosition getPosition()
Returns the position of the target.
The position of the target describes the location of the astronomical object in any popular celestial coordination system.

Specified by:
getPosition in interface ITarget
Returns:
The celestial position of the astronomical object Might return null if position was never set.

getObserver

public IObserver getObserver()
Returns the observer who is the originator of the target.

Specified by:
getObserver in interface ITarget
Returns:
The observer who is the originator of this target. Might return null if observer was never set. (In this case a dataSource must exist)

getDatasource

public java.lang.String getDatasource()
Returns the datasource which is the origin of the target.

Specified by:
getDatasource in interface ITarget
Returns:
The datasource which is the origin of this target Might return null if datasource was never set. (In this case a observer must exist)

setPosition

public void setPosition(EquPosition position)
Sets the position of the target.
The position of the target describes the location of the astronomical object in a popular celestial coordination system.

Specified by:
setPosition in interface ITarget
Parameters:
position - The position of the astronomical object in a popular coordination system

setDatasource

public void setDatasource(java.lang.String datasource)
Sets the datasource of the target.

Specified by:
setDatasource in interface ITarget
Parameters:
datasource - The datasource of the astronomical object

setObserver

public void setObserver(IObserver observer)
Sets the observer who is the originator of the target.

Specified by:
setObserver in interface ITarget
Parameters:
observer - The observer who is the originator of this target

createXmlTargetElement

protected org.w3c.dom.Element createXmlTargetElement(org.w3c.dom.Element parent)
Creates an XML DOM Element for the Target. The new Target element will be added as child element to an given parent element. The given parent element should be the target container. All specialised subclasses may use this method to create a Target element under which they may store their addition data.
Example:
<targetContainer>
<target>
More specialised stuff goes here
</target>
</targetContainer>

Parameters:
parent - The target container element
Returns:
Returns the new created target element (which is a child of the passed container element) Might return null if parent was null.
See Also:
Element

addAliasNames

public boolean addAliasNames(java.lang.String aliasNames)
Adds a comma seperated list of new alias names to the Target.

Parameters:
aliasNames - Comma seperated list with alternative names of the astronomical object
Returns:
Returns true if all alias names of the list could be added. If false is returned the new alias was null.