hourparser
Class Person

java.lang.Object
  extended by hourparser.Person

public class Person
extends Object

Represents a person who has a personal log file.

Author:
Esko Luontola, http://www.orfjackal.net/

Field Summary
private  File file
          Personal log file of this person.
private  String name
          Name of this person, or null if no name is known.
private  Vector<Entry> records
          Work records of this person.
 
Constructor Summary
Person(File file)
          Constructs a new person by reading the data from a log file.
 
Method Summary
 String[] getCodes(Date start, Date end)
          Returns an array of all different codes used during the specified time period.
 Date getEnd()
          Returns the time of the last record this person has.
 Entry[] getEntries(Date start, Date end)
          Returns the entries the person has made during a time period.
 double getHours(Date start, Date end)
          Returns how many hours in total the person has made during a time period.
 double getHours(Date start, Date end, String code)
          Returns how many hours of a specific work the person has made during a time period.
 String getName()
          Returns the name of this person as defined in the first row of the log file.
 Date getStart()
          Returns the time of the first record this person has.
private  void readFile()
          Reads all the information from the the log file of this person.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

private File file
Personal log file of this person.


name

private String name
Name of this person, or null if no name is known.


records

private Vector<Entry> records
Work records of this person.

Constructor Detail

Person

public Person(File file)
       throws IOException
Constructs a new person by reading the data from a log file.

Parameters:
file - the log file of the person.
Throws:
IOException - if reading the log file fails.
Method Detail

readFile

private void readFile()
               throws IOException
Reads all the information from the the log file of this person.

Throws:
IOException - if reading the log file fails.

getName

public String getName()
Returns the name of this person as defined in the first row of the log file.

Returns:
the name of this person or null if no name is set.

getEntries

public Entry[] getEntries(Date start,
                          Date end)
Returns the entries the person has made during a time period.

Parameters:
start - the beginning of the time period. Results are >= start.
end - the end of the time period. Results are < end.
Returns:
total hours of work during the time period.

getHours

public double getHours(Date start,
                       Date end)
Returns how many hours in total the person has made during a time period.

Parameters:
start - the beginning of the time period. Results are >= start.
end - the end of the time period. Results are < end.
Returns:
total hours of work during the time period.

getHours

public double getHours(Date start,
                       Date end,
                       String code)
Returns how many hours of a specific work the person has made during a time period.

Parameters:
start - the beginning of the time period. Results are >= start.
end - the end of the time period. Results are < end.
code - the code of the work type to be included or null to include all.
Returns:
total hours of work during the time period.

getCodes

public String[] getCodes(Date start,
                         Date end)
Returns an array of all different codes used during the specified time period.

Parameters:
start - the beginning of the time period. Results are >= start.
end - the end of the time period. Results are < end.
Returns:
total hours of work during the time period.

getStart

public Date getStart()
Returns the time of the first record this person has.

Returns:
the time of the first record, or the current time if there are no records.

getEnd

public Date getEnd()
Returns the time of the last record this person has.

Returns:
the time of the last record, or the current time if there are no records.