scheduler
Class ConnectionsFinderTask

java.lang.Object
  extended byscheduler.ConnectionsFinderTask
All Implemented Interfaces:
java.lang.Cloneable

public final class ConnectionsFinderTask
extends java.lang.Object
implements java.lang.Cloneable

A class used to store a single task in the tasks list

Author:
Piotrek

Field Summary
private  int changesCount
          A number of changes in the list of the connection chunks.
 Connection connection
          A current real connection the work is done upon.
private  java.util.ArrayList currentConnectionChunks
          A list of currently so far added connection chunks within the current travel part.
 Station currentStation
          A current work station (within the current connection).
 char dayOfWeek
          A day of week the current connection starts on.
 int extraTimeBeforeDeparture
          An extra time in minutes the traveler is at the station before the departure (after the change).
 boolean fDirect
          Indicates whether the connection is a direct connection to the destination station.
 double historyBasedJudgement
          This parameter might be set by the judgement module basing on the history.
 Station startStation
          A starting station used to remember the station where the new connection chunk should start.
 java.util.Date startStationDepartureDate
          A date of departure from the start station.
private  java.util.ArrayList unsetDatesChunksIndecies
          A list of idecies of the chunks with at least one of the start and end dates being unset.
private  java.util.ArrayList usedMeansOfTransportation
          A current list of used means of transportation.
private  java.util.ArrayList visitedStations
          A list of visited stations used to detect the cycles.
 
Constructor Summary
ConnectionsFinderTask()
          Constructor
 
Method Summary
 void AddConnectionChunk(TravelPartConnectionChunk connectionChunk)
          Adds a new connection chunk at the end of the current list of connection chunks.
 void AddVisitedStation(Station station)
          Adds a station to the list of visited stations.
 void ClearVisitedStations()
          Clears the list of visited stations.
 java.lang.Object clone()
          A clone has the reference to the same connection chunks except for the chunks with at least one unset date (those are new copies).
 int GetAverageChangeDuration()
          Gets a duration of the average change.
 int GetChangesCount()
          Gets a number of changes in the list of the connection chunks.
 TravelPartConnectionChunk GetChunk(int chunkIndex)
          Gets the connection chunk with the given index.
 java.util.Iterator GetConnectionChunks()
          Gets a current list of connection chunks.
 int GetConnectionChunksCount()
          Gets a number of connection chunks contained by this task at the moment.
 TravelPartConnectionChunk GetFirstConnectionChunk()
          Gets the first connection chunk in the list.
 TravelPartConnectionChunk GetLastConnectionChunk()
          Gets the last connection chunk in the list.
 TravelPartConnectionChunk GetLastConnectionChunkWithEndDate()
          Gets the last connection chunk in the list with the end date set.
 int GetMaxChangeDuration()
          Gets a duration of the longest change.
 double GetTotalDistance()
          Gets the total distance of the travel described by this task.
 int GetTotalDuration()
          Gets a total duration of the travel stored in this task.
 java.util.Iterator GetUnsetDatesChunksIndecies()
          Gets an iterator to the list of chunks with the unset dates.
 java.util.ArrayList GetUsedMeansOfTransportation()
          Gets a list of used means of transportation.
 boolean HasUnsetDatesChunks()
          Gets a boolean value indicating whether this task has some connection chunks with unset dates.
 boolean HasVisitedStation(Station station)
          Checks whether the given station has been visited before.
 boolean IsSimilar(ConnectionsFinderTask otherTask)
          Checks whether this task is similar to the given one.
 void SetCurrentWorkingData(ConnectionsFinderTask otherTask)
          Sets the current connection, day of week, current station and the start station to the same values as of the other one's.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

visitedStations

private java.util.ArrayList visitedStations
A list of visited stations used to detect the cycles.


currentConnectionChunks

private java.util.ArrayList currentConnectionChunks
A list of currently so far added connection chunks within the current travel part.


unsetDatesChunksIndecies

private java.util.ArrayList unsetDatesChunksIndecies
A list of idecies of the chunks with at least one of the start and end dates being unset. It holds indecies as the Integers.


connection

public Connection connection
A current real connection the work is done upon.


currentStation

public Station currentStation
A current work station (within the current connection).


startStation

public Station startStation
A starting station used to remember the station where the new connection chunk should start.


dayOfWeek

public char dayOfWeek
A day of week the current connection starts on.

See Also:
Connection.MONDAY, Connection.TUESDAY, Connection.WEDNESDAY, Connection.THURSDAY, Connection.FRIDAY, Connection.SATURDAY, Connection.SUNDAY

startStationDepartureDate

public java.util.Date startStationDepartureDate
A date of departure from the start station. Null value means there is no date availble at the moment.


changesCount

private int changesCount
A number of changes in the list of the connection chunks.


fDirect

public boolean fDirect
Indicates whether the connection is a direct connection to the destination station.


usedMeansOfTransportation

private java.util.ArrayList usedMeansOfTransportation
A current list of used means of transportation.


extraTimeBeforeDeparture

public int extraTimeBeforeDeparture
An extra time in minutes the traveler is at the station before the departure (after the change). For example, this might be a time one need to be at the airport before the flight - assuming one got to the airport by bus, there is a change time after getting out of the bus for a walk to the airport and just then there is this extra time.


historyBasedJudgement

public double historyBasedJudgement
This parameter might be set by the judgement module basing on the history. It is provided only for the convinience.

Constructor Detail

ConnectionsFinderTask

public ConnectionsFinderTask()
Constructor

Method Detail

AddVisitedStation

public void AddVisitedStation(Station station)
Adds a station to the list of visited stations.

Parameters:
station - A station to be added.

HasVisitedStation

public boolean HasVisitedStation(Station station)
Checks whether the given station has been visited before.

Parameters:
station - A station to be tested.
Returns:
A boolean value indicating whether the given station has been visited before.

GetUnsetDatesChunksIndecies

public java.util.Iterator GetUnsetDatesChunksIndecies()
Gets an iterator to the list of chunks with the unset dates. The indecies are in the decreasing order.

Returns:
An iterator to the list of chunks with the unset dates. The indecies are in the decreasing order.

HasUnsetDatesChunks

public boolean HasUnsetDatesChunks()
Gets a boolean value indicating whether this task has some connection chunks with unset dates.

Returns:
A boolean value indicating whether this task has some connection chunks with unset dates.

GetChunk

public TravelPartConnectionChunk GetChunk(int chunkIndex)
Gets the connection chunk with the given index.

Parameters:
chunkIndex - An index of the connection chunk to be returned.
Returns:
A connection chunk with the given index.

AddConnectionChunk

public void AddConnectionChunk(TravelPartConnectionChunk connectionChunk)
Adds a new connection chunk at the end of the current list of connection chunks. If it has at least one of the start and the end dates unset, its index is added to the special list of indecies of chunks with unset dates.

Parameters:
connectionChunk - A connection chunk to be added.

GetConnectionChunks

public java.util.Iterator GetConnectionChunks()
Gets a current list of connection chunks.

Returns:
An iterator for the current list of connection chunks.

GetFirstConnectionChunk

public TravelPartConnectionChunk GetFirstConnectionChunk()
Gets the first connection chunk in the list.

Returns:
The first connection chunk in the list or null value if there is none.

GetLastConnectionChunk

public TravelPartConnectionChunk GetLastConnectionChunk()
Gets the last connection chunk in the list.

Returns:
The last connection chunk in the list or null value if there is none.

GetLastConnectionChunkWithEndDate

public TravelPartConnectionChunk GetLastConnectionChunkWithEndDate()
Gets the last connection chunk in the list with the end date set.

Returns:
The last connection chunk in the list with the end date set or null value if there is none.

clone

public java.lang.Object clone()
A clone has the reference to the same connection chunks except for the chunks with at least one unset date (those are new copies).

See Also:
Object.clone()

GetChangesCount

public int GetChangesCount()
Gets a number of changes in the list of the connection chunks.

Returns:
A number of changes in the list of the connection chunks.

ClearVisitedStations

public void ClearVisitedStations()
Clears the list of visited stations.


SetCurrentWorkingData

public void SetCurrentWorkingData(ConnectionsFinderTask otherTask)
Sets the current connection, day of week, current station and the start station to the same values as of the other one's.

Parameters:
otherTask - A source of settings.

GetConnectionChunksCount

public int GetConnectionChunksCount()
Gets a number of connection chunks contained by this task at the moment.

Returns:
A number of connection chunks contained by this task at the moment.

GetTotalDuration

public int GetTotalDuration()
Gets a total duration of the travel stored in this task.

Returns:
Duration in minutes or -1 if not all dates are set.

IsSimilar

public boolean IsSimilar(ConnectionsFinderTask otherTask)
Checks whether this task is similar to the given one. Tasks are similar if they have the same connection chunks. Only dates may differ (except for the start and the end dates). All chunks must have all the dates set. This method does not check if it is so.

Parameters:
otherTask - The other task this one is to be compared.
Returns:
A value indicating whether this task is similar to the given one.

GetMaxChangeDuration

public int GetMaxChangeDuration()
Gets a duration of the longest change.

Returns:
A duration of the longest change in minutes or -1 if there is no change and/or if there is any unset date.

GetAverageChangeDuration

public int GetAverageChangeDuration()
Gets a duration of the average change.

Returns:
A duration of the average change in minutes or -1 if there is no change and/or if there is any unset date.

GetTotalDistance

public double GetTotalDistance()
Gets the total distance of the travel described by this task.

Returns:
A total distance of the travel.

GetUsedMeansOfTransportation

public java.util.ArrayList GetUsedMeansOfTransportation()
Gets a list of used means of transportation.

Returns:
A list of used means of transportation. Each element on the list is an Integer bocing the symbol of a mean of transportation.
See Also:
MeanOfTransportation.AIRPLANE, MeanOfTransportation.BUS, MeanOfTransportation.SHIP, MeanOfTransportation.TAXI, MeanOfTransportation.TRAIN, MeanOfTransportation.WALK