phonebill.phonelog
Class PhoneCall

java.lang.Object
  |
  +--phonebill.phonelog.PhoneCall

class PhoneCall
extends java.lang.Object

This class stores a complete phone call divided into a number of intervals.


Field Summary
protected  double callPrice
           
protected  java.util.Date endTime
           
private  java.lang.String header
           
protected  java.util.List intervals
           
private  java.lang.String margin
           
protected  java.util.Date startTime
           
 
Constructor Summary
PhoneCall()
           
PhoneCall(java.util.Date start, java.util.Date end)
           
 
Method Summary
 boolean add(java.util.Date timestamp, PhoneUser user, boolean action)
           
 void addCost(double amount)
           
 double calc(PhonePrice price)
           
 double getCost()
           
private  PhoneCallInterval getInterval(java.util.Date timestamp, java.util.ListIterator i)
          Returns an interval on the interval list which contains timestamp.
 void print(java.io.PrintWriter out)
           
 void print(java.io.PrintWriter out, int level)
           
 void setCost(double amount)
           
 void setEnd(java.util.Date end)
          This function explicitly sets the end of this PhoneCall and should only be called once during the lifetime of this PhoneCall.
 void setStart(java.util.Date start)
          This function explicitly sets the start of this PhoneCall and should only be called once during the lifetime of this PhoneCall.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

header

private final java.lang.String header

margin

private final java.lang.String margin

intervals

protected java.util.List intervals

startTime

protected java.util.Date startTime

endTime

protected java.util.Date endTime

callPrice

protected double callPrice
Constructor Detail

PhoneCall

public PhoneCall(java.util.Date start,
                 java.util.Date end)

PhoneCall

public PhoneCall()
Method Detail

add

public boolean add(java.util.Date timestamp,
                   PhoneUser user,
                   boolean action)

setStart

public void setStart(java.util.Date start)
This function explicitly sets the start of this PhoneCall and should only be called once during the lifetime of this PhoneCall. If it is called multiple times, the results are not predictable. It is assumed that it is safe to modify the first interval to the desired start time.

setEnd

public void setEnd(java.util.Date end)
This function explicitly sets the end of this PhoneCall and should only be called once during the lifetime of this PhoneCall. If it is called multiple times, the results are not predictable. It is assumed that it is safe to modify the last interval to the desired end time.

getInterval

private PhoneCallInterval getInterval(java.util.Date timestamp,
                                      java.util.ListIterator i)
Returns an interval on the interval list which contains timestamp. It is assumed that intervals has a continuous list of intervals starting at startTime and ending at endTime without holes.
Parameters:
timestamp - is within this PhoneCall.
i - iterates over intervals from the start.

calc

public double calc(PhonePrice price)

addCost

public void addCost(double amount)

setCost

public void setCost(double amount)

getCost

public double getCost()

print

public void print(java.io.PrintWriter out)

print

public void print(java.io.PrintWriter out,
                  int level)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object