org.jscience.ml.om
Class Session

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

public class Session
extends SchemaElement
implements ISession

A Session can be used to link several observations together. Typically a session would describe an observation night, where several observations took place. Therefore an Session requires two mandatory fields: a start date and an end date. All observations of the session should have a start date that is inbetween the sessions start and end date.

Since:
1.0

Field Summary
 
Fields inherited from interface org.jscience.ml.om.ISession
XML_ELEMENT_BEGIN, XML_ELEMENT_COMMENTS, XML_ELEMENT_COOBSERVER, XML_ELEMENT_END, XML_ELEMENT_EQUIPMENT, XML_ELEMENT_SESSION, XML_ELEMENT_SITE, XML_ELEMENT_WEATHER
 
Fields inherited from interface org.jscience.ml.om.ISchemaElement
XML_ELEMENT_ATTRIBUTE_ID
 
Constructor Summary
Session(java.util.Calendar begin, java.util.Calendar end, ISite site)
          Constructs a new instance of a Session.
Session(org.w3c.dom.Node session, IObserver[] observers, ISite[] sites)
          Constructs a new Session instance from a given XML Schema Node.
 
Method Summary
 org.w3c.dom.Element addAsLinkToXmlElement(org.w3c.dom.Element element)
          Adds the session link to an given XML DOM Element The session element itself will be attached to given elements ownerDocument.
 boolean addCoObserver(IObserver coObserver)
          Adds a single coobserver to this session.
 boolean addCoObservers(java.util.List coObservers)
          Adds a List of coobservers to this session.
 org.w3c.dom.Element addToXmlElement(org.w3c.dom.Element element)
          Adds this Session to a given parent XML DOM Element.
 boolean equals(java.lang.Object obj)
          Overwrittes equals(Object) method from java.lang.Object.
 java.util.Calendar getBegin()
          Returns the start date of the session.
 java.lang.String getComments()
          Returns a comment about this session.
 java.util.List getCoObservers()
          Returns a List of coobservers who joined this session.
 java.lang.String getDisplayName()
          Returns a display name for this element.
 java.util.Calendar getEnd()
          Returns the end date of the session.
 java.lang.String getEquipment()
          Returns a string describing equipment which was used during this session.
 ISite getSite()
          Returns the site of the session.
 java.lang.String getWeather()
          Returns a describtion of the weather conditions during the session.
 void setBegin(java.util.Calendar begin)
          Sets the start date of the session.
 void setComments(java.lang.String comments)
          Sets a comment to the session.
 boolean setCoObservers(java.util.List coObservers)
          Sets a new List of coobservers to this session.
 void setEnd(java.util.Calendar end)
          Sets the end date of the session.
 void setEquipment(java.lang.String equipment)
          Sets a equipment description to the session.
 void setSite(ISite site)
          Sets a site (location) where the session took place.
 void setWeather(java.lang.String weather)
          Sets the weather conditions of the session.
 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, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jscience.ml.om.ISchemaElement
getID
 

Constructor Detail

Session

public Session(org.w3c.dom.Node session,
               IObserver[] observers,
               ISite[] sites)
        throws SchemaException,
               java.lang.IllegalArgumentException
Constructs a new Session instance from a given XML Schema Node. Normally this constructor is only used by org.jscience.ml.om.util.SchemaLoader
Please mind: As a Session can have elements that link to elements somewhere else in the xml, this method requires an array of IObservers to check whether the elements link to existing s. If a Session Node has no elements, the second parameter can be null

Parameters:
session - the XML Schema Node that represents this Session object
observers - Needed if the Session Node has elements.
Throws:
java.lang.IllegalArgumentException - if parameter session is null or Node has elements, but no observer array way passed (or array was empty)
SchemaException - if the given Node does not match the XML Schema specifications

Session

public Session(java.util.Calendar begin,
               java.util.Calendar end,
               ISite site)
        throws java.lang.IllegalArgumentException
Constructs a new instance of a Session.

Parameters:
begin - The start date of the session
end - The end date of the session
end - The site of the session
Throws:
java.lang.IllegalArgumentException - if site, begin or end date 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 field values of this Session.

Overrides:
toString in class java.lang.Object
Returns:
This Sessions field values
See Also:
Object

equals

public boolean equals(java.lang.Object obj)
Overwrittes equals(Object) method from java.lang.Object.
Checks if this Session and the given Object are equal. The given object is equal with this Session, if it derives from ISession and if its start and end date equals this Sessions start and end date.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The Object to compare this Session with.
Returns:
true if the given Object is an instance of ISession and its start and end date equals this Sessions start and end date.
*
See Also:
Object

addToXmlElement

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

Specified by:
addToXmlElement in interface ISession
Parameters:
element - The parent element for this Session
Returns:
Returns the element given as parameter with this Session 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 session link to an given XML DOM Element The session element itself will be attached to given elements ownerDocument. If the ownerDocument has no session container, it will be created.
Example:
<parameterElement>
<sessionLink>123</sessionLink>
</parameterElement>
More stuff of the xml document goes here
<sessionContainer>
<session id="123">
session description goes here
</session>
</sessionContainer>

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

getBegin

public java.util.Calendar getBegin()
Returns the start date of the session.

Specified by:
getBegin in interface ISession
Returns:
Returns the start date of the session

getComments

public java.lang.String getComments()
Returns a comment about this session.
Might return null if no comment was set to this session.

Specified by:
getComments in interface ISession
Returns:
Returns a comment about this session or null if no comment was set at all.

getEnd

public java.util.Calendar getEnd()
Returns the end date of the session.

Specified by:
getEnd in interface ISession
Returns:
Returns the end date of the session

getSite

public ISite getSite()
Returns the site of the session.

Specified by:
getSite in interface ISession
Returns:
Returns the site of the session

getEquipment

public java.lang.String getEquipment()
Returns a string describing equipment which was used during this session.
Typically one should add non optical equipment here like "Radio and a warm bottle of Tea."
Might return null if no equipment was set to this session.

Specified by:
getEquipment in interface ISession
Returns:
Returns string describing some equipment which was used during the session or null if no additional equipment was used at all.

getWeather

public java.lang.String getWeather()
Returns a describtion of the weather conditions during the session.
Might return null if no weather conditions were addedt to this session.

Specified by:
getWeather in interface ISession
Returns:
Returns a describtion of the weather conditions during the session or null if no weather conditions were added at all.

setBegin

public void setBegin(java.util.Calendar begin)
              throws java.lang.IllegalArgumentException
Sets the start date of the session.

Specified by:
setBegin in interface ISession
Parameters:
begin - The new start date of the session.
Throws:
java.lang.IllegalArgumentException - if new start date is null

setComments

public void setComments(java.lang.String comments)
Sets a comment to the session.
The old comment will be overwritten.

Specified by:
setComments in interface ISession
Parameters:
comments - A new comment for the session

setEnd

public void setEnd(java.util.Calendar end)
            throws java.lang.IllegalArgumentException
Sets the end date of the session.

Specified by:
setEnd in interface ISession
Parameters:
end - The new end date of the session.
Throws:
java.lang.IllegalArgumentException - if new end date is null

setEquipment

public void setEquipment(java.lang.String equipment)
Sets a equipment description to the session.
Typically non optical equipment will should be stored here, e.g. "Red LED light and bottle of hot tea."
The old equipment will be overwritten.

Specified by:
setEquipment in interface ISession
Parameters:
equipment - The new equipment of the session

setSite

public void setSite(ISite site)
             throws java.lang.IllegalArgumentException
Sets a site (location) where the session took place.
A session can only took place at one site.

Specified by:
setSite in interface ISession
Parameters:
site - The site where the session took place.
Throws:
java.lang.IllegalArgumentException - if site is null

setCoObservers

public boolean setCoObservers(java.util.List coObservers)
Sets a new List of coobservers to this session.
The old List of coobservers will be overwritten. If you want to add one ore more coobservers to the existing list use addCoObservers(java.util.List) or addCoObserver(IObserver) instead.

Specified by:
setCoObservers in interface ISession
Parameters:
coObservers - The new List of coobservers of the session
Returns:
true if the list could be set successfully, false if the operation fails, because e.g. one of the lists elements does not implement the IObserver interface. If false is returned the existing list is not changed at all.

addCoObservers

public boolean addCoObservers(java.util.List coObservers)
Adds a List of coobservers to this session.
The old List of coobservers will be extended by the new List of coobservers.

Specified by:
addCoObservers in interface ISession
Parameters:
coObservers - A List of coobservers which will be added to the existing List of coobservers which is stored in the session
Returns:
true if the list could be added to the existing list, false if the operation fails, because e.g. one of the lists elements does not implement the IObserver interface. If false is returned the existing list is not changed at all.

addCoObserver

public boolean addCoObserver(IObserver coObserver)
Adds a single coobserver to this session.

Specified by:
addCoObserver in interface ISession
Parameters:
coObserver - A new coobserver who will be addded to the List of coobservers
Returns:
true if the new coobserver could be added, false if the operation fails, because e.g. the given IObserver is null

getCoObservers

public java.util.List getCoObservers()
Returns a List of coobservers who joined this session.
Might return null if no coobservers were added to this session.

Specified by:
getCoObservers in interface ISession
Returns:
Returns a List of coobserver or null if coobservers were never added.

setWeather

public void setWeather(java.lang.String weather)
Sets the weather conditions of the session.
The weather conditions string should explain in some short sentences, how the weather conditions were like during the session. E.g. "Small clouds at the first hour but then totally clear and cool, at about 4�C."

Specified by:
setWeather in interface ISession
Parameters:
weather - A string describing the weather conditions during the session