fr.cnes.sirius.patrius.events
Class CodedEvent

java.lang.Object
  extended by fr.cnes.sirius.patrius.events.CodedEvent
All Implemented Interfaces:
Comparable<CodedEvent>, TimeStamped

public final class CodedEvent
extends Object
implements TimeStamped, Comparable<CodedEvent>

This class represents an event occurrence.
An event is identified by a code (its name), the date of occurrence, a string representing a comment and a flag that indicates if the event is a "starting" event (i.e. an event that starts a phenomenon, like an eclipse) or an "ending" event.
Coded events are built by the CodingEventDetector during propagation using the buildCodedEvent method.

Since:
1.1
Version:
$Id: CodedEvent.java 17586 2017-05-10 13:29:16Z bignon $
Author:
Pierre Cardoso, Tiziana Sabatini
See Also:
CodingEventDetector, CodedEventsList
Concurrency :
immutable

Constructor Summary
CodedEvent(String codeIn, String commentIn, AbsoluteDate dateIn, boolean startingEventIn)
          Constructor for the coded event.
 
Method Summary
static CodedEvent buildUndefinedEvent(AbsoluteDate date, boolean isStarting)
          Factory method for an undefined event, that still has a valid date.
 int compareTo(CodedEvent event)
          Compares two CodedEvent instances.
The ordering for CodedEvent is consistent with equals, so that a CodedEvent can be used in any SortedSet or SortedMap.
The ordering is : the ordering of the events' dates if they differ. if not, the alphabetical ordering of the code is used if they differ. if not, the alphabetical ordering of the comment is used if they differ. if not, the starting boolean is used (the starting event is "before").
 boolean equals(Object event)
          Checks if the instance represents the same CodedEvent as another instance.
 String getCode()
           
 String getComment()
           
 AbsoluteDate getDate()
          Get the date.
 int hashCode()
           
 boolean isStartingEvent()
           
 String toString()
          Provides a String representation, based on this pattern : "<date> - <(Beg) or (End)> - <code> : <comment>".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CodedEvent

public CodedEvent(String codeIn,
                  String commentIn,
                  AbsoluteDate dateIn,
                  boolean startingEventIn)
Constructor for the coded event.

Parameters:
codeIn - code identifying the event.
commentIn - comment for the event.
dateIn - the AbsoluteDate of the event.
startingEventIn - true if the event is a "starting" event, false if it is an "ending" event.
Method Detail

getCode

public String getCode()
Returns:
the code of the event.

getComment

public String getComment()
Returns:
the comment of the event.

getDate

public AbsoluteDate getDate()
Description copied from interface: TimeStamped
Get the date.

Specified by:
getDate in interface TimeStamped
Returns:
the AbsoluteDate of the event.
See Also:
TimeStamped.getDate()

isStartingEvent

public boolean isStartingEvent()
Returns:
true if the event is a "starting" event or false if the event is a "ending" event.

compareTo

public int compareTo(CodedEvent event)
Compares two CodedEvent instances.
The ordering for CodedEvent is consistent with equals, so that a CodedEvent can be used in any SortedSet or SortedMap.
The ordering is :

Specified by:
compareTo in interface Comparable<CodedEvent>
Parameters:
event - the CodedEvent to compare to
Returns:
a negative integer, zero, or a positive integer as the CodedEvent is before, simultaneous, or after the specified event.
See Also:
Comparable.compareTo(java.lang.Object)

buildUndefinedEvent

public static CodedEvent buildUndefinedEvent(AbsoluteDate date,
                                             boolean isStarting)
Factory method for an undefined event, that still has a valid date.

Parameters:
date - the AbsoluteDate of the event, needed even for an undefined event.
isStarting - true when the event is a "starting" event.
Returns:
a new CodedEvent.

toString

public String toString()
Provides a String representation, based on this pattern : "<date> - <(Beg) or (End)> - <code> : <comment>".
(Beg) is for a starting event, (End) for an ending event.

Overrides:
toString in class Object
Returns:
the String representation
See Also:
Object.toString()

equals

public boolean equals(Object event)
Checks if the instance represents the same CodedEvent as another instance.

Overrides:
equals in class Object
Parameters:
event - other event
Returns:
true if the instance and the other event are equals

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2017 CNES. All Rights Reserved.