com.myJava.util.history
Class DefaultHistory

java.lang.Object
  extended by com.myJava.util.history.DefaultHistory
All Implemented Interfaces:
History

public class DefaultHistory
extends java.lang.Object
implements History


Author:
Olivier PETRUCCI

Areca Build ID : 7299034069467778562

Nested Class Summary
protected static class DefaultHistory.GregorianCalendarComparator
           
 
Field Summary
protected  java.util.HashMap content
           
protected  java.io.File file
           
protected  FileTool tool
           
 
Constructor Summary
DefaultHistory(java.io.File file)
           
 
Method Summary
 void addEntry(HistoryEntry entry)
          Add an entry
 void clear()
          Removes all entries from the history
 void clearData()
          Does not clear the internal data; destroys only the data stored on disk.
 void flush()
          Close the history and writes its content.
 java.util.HashMap getContent()
          Return the internal content of the history as a Map
Key = GregorianCalendar
Value = HistoryEntry
 HistoryEntry getEntry(java.util.GregorianCalendar date)
          Return the entry for the given date
 java.util.GregorianCalendar[] getOrderedKeys()
          Return the keys (dates) as an ordered array
 void importHistory(History h)
          Imports the content of the source history
 boolean isEmpty()
          Tells whether the history is empty or not
 void load()
          Load the history from disk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

protected java.io.File file

content

protected java.util.HashMap content

tool

protected FileTool tool
Constructor Detail

DefaultHistory

public DefaultHistory(java.io.File file)
               throws java.io.IOException
Throws:
java.io.IOException
Method Detail

isEmpty

public boolean isEmpty()
Description copied from interface: History
Tells whether the history is empty or not

Specified by:
isEmpty in interface History

importHistory

public void importHistory(History h)
                   throws java.io.IOException
Description copied from interface: History
Imports the content of the source history

Specified by:
importHistory in interface History
Throws:
java.io.IOException

addEntry

public void addEntry(HistoryEntry entry)
              throws java.io.IOException
Description copied from interface: History
Add an entry

Specified by:
addEntry in interface History
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Close the history and writes its content.
This mode may seem unefficient because it writes the whole history data instead of appending the new data.
The advantage of this approach is that it is compatible with FileSystemDrivers that do not support writing "append" mode.

Specified by:
flush in interface History
Throws:
java.io.IOException

clearData

public void clearData()
Description copied from interface: History
Does not clear the internal data; destroys only the data stored on disk.
The internal data can be written on disk using the "flush" method.

Specified by:
clearData in interface History

getContent

public java.util.HashMap getContent()
Description copied from interface: History
Return the internal content of the history as a Map
Key = GregorianCalendar
Value = HistoryEntry

Specified by:
getContent in interface History
See Also:
History.getContent()

getOrderedKeys

public java.util.GregorianCalendar[] getOrderedKeys()
Description copied from interface: History
Return the keys (dates) as an ordered array

Specified by:
getOrderedKeys in interface History

getEntry

public HistoryEntry getEntry(java.util.GregorianCalendar date)
Description copied from interface: History
Return the entry for the given date

Specified by:
getEntry in interface History

clear

public void clear()
Description copied from interface: History
Removes all entries from the history

Specified by:
clear in interface History

load

public void load()
          throws java.io.IOException
Description copied from interface: History
Load the history from disk

Specified by:
load in interface History
Throws:
java.io.IOException