de.upb.swtpra05.group03.plugin
Class DataHolder

java.lang.Object
  extended byde.upb.swtpra05.group03.plugin.DataHolder
All Implemented Interfaces:
PluginModelInterface

public class DataHolder
extends java.lang.Object
implements PluginModelInterface

This class contains all data the plugin will ever need, its designed as a singleton.

Version:
$Revision: 1.3 $

Field Summary
private  java.util.LinkedList accountExpensesLinkedList
          A LinkedList containing all expense account informations received from shuttle
private  java.util.LinkedList accountIncomeLinkedList
          A LinkedList containing all income account informations received from shuttle
private  EfficientBitSet bS
          No comment provided by developer, please add a comment to improve documentation.
private static DataHolder dh
          The global DataHolder object
private  java.util.Vector extendedOrderVector
          A container for all orders we have.
private  java.util.Vector routingVector
          A container for Names of the Stations on the route
private  ShuttleStatus shuttleStatus
          A container class for data concerning the shuttle
 
Constructor Summary
private DataHolder()
          Constructor for class DataHolder
 
Method Summary
private  void addAccountComponent(java.util.LinkedList l, AccountData aD)
          Adds a AccountData object to the LinkedList if its not already inserted.
 void addAccountData(AccountData aD)
          Adds a AccountData object to the DataHolder.
private  void addOrder(ExtendedOrder newEO)
          This method will add a single ExtendedOrder, if it isn't already known.
 void addOrder(java.util.LinkedList newList)
          This will add a list of ExtendedOrder objects and delete those we have and that aren't in the new list, in terms of mathematics we delete all elements, that are not in the new list and update those which are in both lists.
 void clear()
          This method will clear all data in the DataHolder.
 void clearAccountData(int smallerThanID)
          Tests if elements of both LinkedLists, which governs account data, are smaller than the parameter and if yes, removes them
 java.util.LinkedList getAccountExpensesLinkedList()
          Gets the LinkedList of the expense AccountData
 java.util.LinkedList getAccountIncomeLinkedList()
          Gets the LinkedList of the income AccountData
static DataHolder getDH()
          Get a reference to the global DataHolder object
 java.util.Vector getExtendedOrderVector()
          Get all ExtendedOrders as a Vector
 int getNrOfExpenses()
          Gets the number of expenses account entries
 int getNrOfIncome()
          Gets the number of income account entries
 int getNrOfStations()
          Get the number of stations on the route
 ShuttleStatus getShuttleStatus()
          Get the ShuttleStatus
 java.lang.String getStationName(int index)
          Get the name of the Station at position index
 void setRoute(RoutingData route)
          Sets the route of the shuttle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dh

private static DataHolder dh
The global DataHolder object


routingVector

private java.util.Vector routingVector
A container for Names of the Stations on the route


extendedOrderVector

private java.util.Vector extendedOrderVector
A container for all orders we have. Orders will be stores as ExtendedOrder-Objects


shuttleStatus

private ShuttleStatus shuttleStatus
A container class for data concerning the shuttle


accountIncomeLinkedList

private java.util.LinkedList accountIncomeLinkedList
A LinkedList containing all income account informations received from shuttle


accountExpensesLinkedList

private java.util.LinkedList accountExpensesLinkedList
A LinkedList containing all expense account informations received from shuttle


bS

private EfficientBitSet bS
No comment provided by developer, please add a comment to improve documentation.

Constructor Detail

DataHolder

private DataHolder()
Constructor for class DataHolder

Method Detail

getDH

public static DataHolder getDH()
Get a reference to the global DataHolder object

Returns:
a Reference to the global DataHolder object

addOrder

private void addOrder(ExtendedOrder newEO)
This method will add a single ExtendedOrder, if it isn't already known. If it is, it will update the old ExtendedOrder.

Parameters:
newEO - The ExtendedOrder to be updated or added to the ExtendedOrderVector

addOrder

public void addOrder(java.util.LinkedList newList)
This will add a list of ExtendedOrder objects and delete those we have and that aren't in the new list, in terms of mathematics we delete all elements, that are not in the new list and update those which are in both lists. New elements (only in the new list) will get added to our own list.

Parameters:
newList - The objects added.

getExtendedOrderVector

public java.util.Vector getExtendedOrderVector()
Get all ExtendedOrders as a Vector

Returns:
The extendedOrders Vector

setRoute

public void setRoute(RoutingData route)
Sets the route of the shuttle

Parameters:
route - The new route

getShuttleStatus

public ShuttleStatus getShuttleStatus()
Get the ShuttleStatus

Returns:
ShuttleStatus

getNrOfStations

public int getNrOfStations()
Get the number of stations on the route

Returns:
The number of stations on the route

getStationName

public java.lang.String getStationName(int index)
Get the name of the Station at position index

Parameters:
index - the position of the station
Returns:
the name of the Station at position index

getNrOfIncome

public int getNrOfIncome()
Gets the number of income account entries

Returns:
The number of income account entries

getNrOfExpenses

public int getNrOfExpenses()
Gets the number of expenses account entries

Returns:
The number of expense account entries

addAccountData

public void addAccountData(AccountData aD)
Adds a AccountData object to the DataHolder. The DataHolder will place the AccountData into the correct LinkedList according to its character. If the AccoundData is of type ORDERPROFIT, it will be added to the income list, otherwise it will be added to the expenses (its either TOLL, PENALTY or SERVICE).

Parameters:
aD - The AccountData to be added

clearAccountData

public void clearAccountData(int smallerThanID)
Tests if elements of both LinkedLists, which governs account data, are smaller than the parameter and if yes, removes them

Parameters:
smallerThanID - smallest ID which should be listed after the clean up

addAccountComponent

private void addAccountComponent(java.util.LinkedList l,
                                 AccountData aD)
Adds a AccountData object to the LinkedList if its not already inserted. If the LinkedList contains more than 4 elements, the first element gets removed. That means that the LinkedList is a sort of FIFO.

Parameters:
l - The LinkedList to which the AccountData is to be added
aD - The AccountData to add to the LinkedList

getAccountIncomeLinkedList

public java.util.LinkedList getAccountIncomeLinkedList()
Gets the LinkedList of the income AccountData

Returns:
The LinkedList with the income AccountData objects

getAccountExpensesLinkedList

public java.util.LinkedList getAccountExpensesLinkedList()
Gets the LinkedList of the expense AccountData

Returns:
The LinkedList with the expense AccountData objects

clear

public void clear()
This method will clear all data in the DataHolder. It will be used if the run-method of the main plugin class gets called. That means, that the plugin is started again and it is possible, that the visclient is disconnected and reconnected to another simulation in the meantime. So remove all data because it is possible that the data is wrong.