eu.xtreemos.xosd.localallocmgr.basic.manipulators
Class FreeSlots

java.lang.Object
  extended by eu.xtreemos.xosd.localallocmgr.basic.manipulators.FreeSlots
All Implemented Interfaces:
java.io.Serializable

public class FreeSlots
extends java.lang.Object
implements java.io.Serializable

Class used by local manager in order to determine all free slots available for a resoruce. Also, the time of the first and last reservation are set, in order to provide an info about open intervals before and agter reservations. If these values are not set, it means, that the time table is empty and there are no restraints regarding the reservations.
The time table elements (TTElm) returned can be directly used for the reservation requests. Not that the default type of the free slot element is a MUTUAL lock.
Also note, that the free slots are only the slots where there are no reservations whatsoever, and do not include the ones where there are reservations, but the reservation do not use max amount of the resource. In order to get those slots, please use getSelection method of a service/wrapper.

Author:
uros
See Also:
Serialized Form

Field Summary
 java.util.GregorianCalendar firstOccupied
          denotes the starting time of the first element in the table. if set at null, the table is empty and any value can be used.
 java.util.LinkedList<TTElm> free
          holds TTElm objects denoting the free slots.
 java.util.GregorianCalendar lastOccupied
          denotes the ending time of the last element in the table. if set at null, the table is empty and any value can be used.
 
Constructor Summary
FreeSlots(TimeTable source)
           
FreeSlots(TimeTable source, java.util.GregorianCalendar from, java.util.GregorianCalendar to)
           
 
Method Summary
private  void addNewFreeSlot(java.util.GregorianCalendar start, java.util.GregorianCalendar end)
          free slots are basic TTElm objects.
private  void findFree(java.util.LinkedList<TTElm> src)
          returns the free slots from the whole stored interval
private  void findFree(java.util.LinkedList<TTElm> src, java.util.GregorianCalendar from, java.util.GregorianCalendar to)
          return free slots between the given intervals.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

firstOccupied

public java.util.GregorianCalendar firstOccupied
denotes the starting time of the first element in the table. if set at null, the table is empty and any value can be used.


lastOccupied

public java.util.GregorianCalendar lastOccupied
denotes the ending time of the last element in the table. if set at null, the table is empty and any value can be used.


free

public java.util.LinkedList<TTElm> free
holds TTElm objects denoting the free slots. if the occupied elms are not null, but the free list is empty, only one element is in the time table and there are no intermediate free time slots.

Constructor Detail

FreeSlots

public FreeSlots(TimeTable source)
          throws AttributeConformanceException
Throws:
AttributeConformanceException

FreeSlots

public FreeSlots(TimeTable source,
                 java.util.GregorianCalendar from,
                 java.util.GregorianCalendar to)
          throws AttributeConformanceException
Throws:
AttributeConformanceException
Method Detail

findFree

private void findFree(java.util.LinkedList<TTElm> src)
               throws AttributeConformanceException
returns the free slots from the whole stored interval

Parameters:
src -
Throws:
AttributeConformanceException

findFree

private void findFree(java.util.LinkedList<TTElm> src,
                      java.util.GregorianCalendar from,
                      java.util.GregorianCalendar to)
               throws AttributeConformanceException
return free slots between the given intervals. if the source holds only one element or is empty, the table of free elements is empty, only interval occupation is noted (if possible).

Parameters:
src -
from -
to -
Throws:
AttributeConformanceException

addNewFreeSlot

private void addNewFreeSlot(java.util.GregorianCalendar start,
                            java.util.GregorianCalendar end)
free slots are basic TTElm objects. All we need are their time bounds.

Parameters:
start -
end -

size

public int size()