pulling.availability_predection
Class AvailabilityLogger

java.lang.Object
  extended by pulling.availability_predection.AvailabilityLogger

public class AvailabilityLogger
extends java.lang.Object

This class is responsible for maintaining the file that stores information about the availability history.

Version:
1
Author:
Majd Kokaly

Constructor Summary
AvailabilityLogger()
           
AvailabilityLogger(int timeResolution, int pastReadingsCount)
           
 
Method Summary
 int getPastReadingsCount()
           
 double getReading(int ageRank, WeekDay wd, TimeStamp ts)
          This method reads a reading for a specific entry at specific age.
 int getTimeresolution()
           
 void initHistoryFile()
          This method initiates the history files
 void initHistoryFileWithRandomData()
          This method initiates the history files with random data
 void insertNewReading(double reading, WeekDay wd, TimeStamp ts)
          This method set a new reading for a specific entry and age the rest of the readings by 1
static void main(java.lang.String[] args)
           
 void printHistoryFile(int fractionsDigits)
          This method prints the history file
 java.lang.String readFixedLengthString(int n, java.io.DataInput inStream)
          This method simply read a fixed number of characters off a DataInputStream
 void setReadingQuick(double reading, int ageRank, WeekDay wd, TimeStamp ts)
          This method set a reading for a specific entry at specific age.
 void writeFixedLengthString(java.lang.String toBeWritten, int n, java.io.DataOutput outStream)
          This method writes to output stream outStream the string toBeWritten.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AvailabilityLogger

public AvailabilityLogger()

AvailabilityLogger

public AvailabilityLogger(int timeResolution,
                          int pastReadingsCount)
Method Detail

getPastReadingsCount

public int getPastReadingsCount()

getTimeresolution

public int getTimeresolution()

initHistoryFile

public void initHistoryFile()
This method initiates the history files


initHistoryFileWithRandomData

public void initHistoryFileWithRandomData()
This method initiates the history files with random data


printHistoryFile

public void printHistoryFile(int fractionsDigits)
This method prints the history file


setReadingQuick

public void setReadingQuick(double reading,
                            int ageRank,
                            WeekDay wd,
                            TimeStamp ts)
                     throws java.io.IOException
This method set a reading for a specific entry at specific age.

Parameters:
reading - New value desired to be set.
ageRank - every time slot have N number of reading. 0 means the most recent reading.
wd - is the weekday.
ts - is the time stamp. Together with wd, the specific time slot is defined. example: if you had this line: SUNDAY_22_20: .85 .83 .87 .82 .80 and setReadingQuick(.90, 0, Weekday.Monday, new TimeStam(22, 20) ) was invoked, that line will be: SUNDAY_22_20: .90 .83 .87 .82 .80. Other lines aren't effected
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Parameters:
args -
Throws:
java.io.IOException

insertNewReading

public void insertNewReading(double reading,
                             WeekDay wd,
                             TimeStamp ts)
                      throws java.io.IOException
This method set a new reading for a specific entry and age the rest of the readings by 1

Parameters:
reading - New value desired to be set.
wd - is the weekday.
ts - is the time stamp. (e.g. 12_10)
Throws:
java.io.IOException

getReading

public double getReading(int ageRank,
                         WeekDay wd,
                         TimeStamp ts)
This method reads a reading for a specific entry at specific age.

Parameters:
ageRank - every time slot have N number of reading. 1 means the most recent reading.
wd - is the weekday.
ts - is the time stamp. Together with wd, the specific time slot is defined. example: if you had this line: SUNDAY_22_20: .85 .83 .87 .82 .80 and setReadingQuick(.90, 0, Weekday.Monday, new TimeStam(22, 20) ) was invoked, that line will be: SUNDAY_22_20: .90 .83 .87 .82 .80. Other lines aren't effected

readFixedLengthString

public java.lang.String readFixedLengthString(int n,
                                              java.io.DataInput inStream)
                                       throws java.io.IOException
This method simply read a fixed number of characters off a DataInputStream

Parameters:
n - size of read String
inStream - DataInput to read from (e.g RandomAccessFile Object)
Throws:
java.io.IOException

writeFixedLengthString

public void writeFixedLengthString(java.lang.String toBeWritten,
                                   int n,
                                   java.io.DataOutput outStream)
                            throws java.io.IOException
This method writes to output stream outStream the string toBeWritten. It adds blank spaces if toBeWritten is smaller than n, or write the first n characters of toBeWritten

Parameters:
n - size of written String
outStream - outStream to read from (e.g RandomAccessFile Object)
Throws:
java.io.IOException