org.jscience.ml.om
Class Observer

java.lang.Object
  extended by org.jscience.ml.om.SchemaElement
      extended by org.jscience.ml.om.Observer
All Implemented Interfaces:
IObserver, ISchemaElement

public class Observer
extends SchemaElement
implements IObserver

An Observer describes person, who does astronomical observations.
The Observer class provides access to at least the name and surname of the person. Additionally address informations may be stored here.

Since:
1.0

Field Summary
 
Fields inherited from interface org.jscience.ml.om.IObserver
XML_ELEMENT_CONTACT, XML_ELEMENT_DSL, XML_ELEMENT_NAME, XML_ELEMENT_OBSERVER, XML_ELEMENT_SURNAME
 
Fields inherited from interface org.jscience.ml.om.ISchemaElement
XML_ELEMENT_ATTRIBUTE_ID
 
Constructor Summary
Observer(org.w3c.dom.Node observer)
          Constructs a new Observer instance from a given XML Schema Node.
Observer(java.lang.String name, java.lang.String surname)
          Constructs a new instance of an Observer.
 
Method Summary
 org.w3c.dom.Element addAsLinkToXmlElement(org.w3c.dom.Element element, java.lang.String NameOfLinkElement)
          Adds a Observer link to an given XML DOM Element.
 boolean addContact(java.lang.String newContact)
          Adds a new contact information to the observer.
 org.w3c.dom.Element addToXmlElement(org.w3c.dom.Element element)
          Adds this Observer to a given parent XML DOM Element.
 boolean equals(java.lang.Object obj)
          Overwrittes equals(Object) method from java.lang.Object.
 java.util.List getContacts()
          Returns a List with contact information of the observer
The returned List may contain e-Mail address, phone number, fax number, postal adress, webpage....whatever.
 java.lang.String getDisplayName()
          Returns a display name for this element.
 java.lang.String getDSLCode()
          Returns the DeepSkyList (DSL) Code of the observer
Might return NULL if observer has no DSL code
 java.lang.String getName()
          Returns the name of the observer
The name (and the surname) are the only mandatory fields this interface requires.
 java.lang.String getSurname()
          Returns the surname of the observer
The surname (and the name) are the only mandatory fields this interface requires.
 int hashCode()
          Overwrittes hashCode() method from java.lang.Object.
 boolean setContacts(java.util.List newContacts)
          Sets the contact information to the observer.
 void setDSLCode(java.lang.String DSLCode)
          Sets the DeepSkyList (DSL) Code of the observer
 void setName(java.lang.String name)
          Sets a new name to the observer.
 void setSurname(java.lang.String surname)
          Sets a new surname to the observer.
 java.lang.String toString()
          Overwrittes toString() method from java.lang.Object.
 
Methods inherited from class org.jscience.ml.om.SchemaElement
getID, setID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jscience.ml.om.ISchemaElement
getID
 

Constructor Detail

Observer

public Observer(org.w3c.dom.Node observer)
         throws SchemaException,
                java.lang.IllegalArgumentException
Constructs a new Observer instance from a given XML Schema Node. Normally this constructor is only used by org.jscience.ml.om.util.SchemaLoader

Parameters:
observer - The XML Schema Node that represents this Observer object
Throws:
java.lang.IllegalArgumentException - if the given parameter is null
SchemaException - if the given Node does not match the XML Schema specifications

Observer

public Observer(java.lang.String name,
                java.lang.String surname)
         throws java.lang.IllegalArgumentException
Constructs a new instance of an Observer.

Parameters:
name - The observers name
surname - The observers surname
Throws:
java.lang.IllegalArgumentException - if one of the given parameters is 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();

toString

public java.lang.String toString()
Overwrittes toString() method from java.lang.Object.
Returns the name, surname and contact informations of this observer.

Overrides:
toString in class java.lang.Object
Returns:
This observers name, surname and contact informations
See Also:
Object

hashCode

public int hashCode()
Overwrittes hashCode() method from java.lang.Object.
Returns a hashCode for the string returned from toString() method.

Overrides:
hashCode in class java.lang.Object
Returns:
a hashCode value
See Also:
Object

equals

public boolean equals(java.lang.Object obj)
Overwrittes equals(Object) method from java.lang.Object.
Checks if this Observer and the given Object are equal. The given object is equal with this Observer, if it implements the IObserver interface and if its name, surname and contact informations equals this Observers data.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The Object to compare this Observer with.
Returns:
true if the given Object is an instance of IObserver and its name, surname and contact informations are equal to this Observers data.
(Name, surname comparism is not casesensitive)
See Also:
Object

addToXmlElement

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

Specified by:
addToXmlElement in interface IObserver
Parameters:
parent - The parent element for this Observer
Returns:
Returns the element given as parameter with this Observer 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,
                                                 java.lang.String NameOfLinkElement)
Adds a Observer link to an given XML DOM Element. The Observer element itself will be attached to given elements ownerDocument. If the ownerDocument has no observer container, it will be created.
It might look a little odd that observers addAsLinkToXmlElement() method takes two parameters, but it is nessary as IObserver is once used as (under ) and used as under other elements. This is why the name of the link element has to be specified. The link element will be created under the passed parameter element. Example:
<parameterElement>
<linkNameElement>123</linkNameElement>
</parameterElement>
More stuff of the xml document goes here
<observerContainer>
<observer id="123">
Observer description goes here
</observer>
</observerContainer>

Specified by:
addAsLinkToXmlElement in interface IObserver
Parameters:
element - The element at which the Observer link will be created.
NameOfLinkElement - The name of the link element, which is set under the passed element
Returns:
Returns the Element given as parameter with the Observer as linked child element, and the elements ownerDocument with the additional Observer element Might return null if element was null.
See Also:
Element

getContacts

public java.util.List getContacts()
Returns a List with contact information of the observer
The returned List may contain e-Mail address, phone number, fax number, postal adress, webpage....whatever. No garantee is given what the list should/may contain, or in which order the elements are placed.
If no contact informations where given, the method might return null

Specified by:
getContacts in interface IObserver
Returns:
a List with contact information of the observer, or null if not informations are given.

addContact

public boolean addContact(java.lang.String newContact)
Adds a new contact information to the observer.

Specified by:
addContact in interface IObserver
Parameters:
newContact - the additional contact information
Returns:
true if the new contact information could be added successfully. false if the new contact information could not be added.

setContacts

public boolean setContacts(java.util.List newContacts)
Sets the contact information to the observer.
All current contacts will be deleted!
If you want to add a contact use addContact(String)

Specified by:
setContacts in interface IObserver
Parameters:
newContacts - new list of contact informations
Returns:
true if the new contact information could be set successfully. false if the new contact information could not be set.

getName

public java.lang.String getName()
Returns the name of the observer
The name (and the surname) are the only mandatory fields this interface requires.

Specified by:
getName in interface IObserver
Returns:
the name of the observer

getDSLCode

public java.lang.String getDSLCode()
Returns the DeepSkyList (DSL) Code of the observer
Might return NULL if observer has no DSL code

Specified by:
getDSLCode in interface IObserver
Returns:
the DeepSkyList (DSL) Code of the observer, or NULL if DSL was never set

getSurname

public java.lang.String getSurname()
Returns the surname of the observer
The surname (and the name) are the only mandatory fields this interface requires.

Specified by:
getSurname in interface IObserver
Returns:
the surname of the observer

setDSLCode

public void setDSLCode(java.lang.String DSLCode)
Sets the DeepSkyList (DSL) Code of the observer

Specified by:
setDSLCode in interface IObserver
Parameters:
DSLCode - the DeepSkyList (DSL) Code of the observer

setName

public void setName(java.lang.String name)
             throws java.lang.IllegalArgumentException
Sets a new name to the observer.
As the name is mandatory it cannot be null

Specified by:
setName in interface IObserver
Parameters:
name - the new name of the observer
Throws:
java.lang.IllegalArgumentException - if the given name is null

setSurname

public void setSurname(java.lang.String surname)
Sets a new surname to the observer.
As the surname is mandatory it cannot be null

Specified by:
setSurname in interface IObserver
Parameters:
surname - the new surname of the observer
Throws:
java.lang.IllegalArgumentException - if the given surname is null