com.avian.util
Class BirdHistoryFile

java.lang.Object
  extended by com.avian.util.BirdHistoryFile

public class BirdHistoryFile
extends java.lang.Object

Utility object that manages all of the messy details of writing the history of a bird to a file. The writing of a bird history is done all at once, so the open and close are part of the same try-catch block. In the future it may be preferable to write one line or one chunk of data at a time, but we'll update this object at the time when we need that ability.


Constructor Summary
BirdHistoryFile(java.lang.String fileName, java.lang.String action)
          The only constructor that is defined for this helper object.
 
Method Summary
 java.lang.String getFileName()
          Returns the fileName that is currently set in this helper object.
 void openAndWrite(java.lang.String birdHistory)
          Opens the fileName that was set when this object was created and writes the String that is passed to this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BirdHistoryFile

public BirdHistoryFile(java.lang.String fileName,
                       java.lang.String action)
The only constructor that is defined for this helper object. The assumption is that the only time that this object will be required is when it is actually needed so it assumes that the filename and the action will be known at that time.

Parameters:
fileName - String that contains the path and file name to write to.
action - String that describes how the file should be opened. If the String equals "New" then the file will be opened and discard any previous contents of the file. If the String does not equal "New" then it will open and append any additional contents to the file.
Method Detail

getFileName

public java.lang.String getFileName()
Returns the fileName that is currently set in this helper object.

Returns:
String that contains the currently set fileName.

openAndWrite

public void openAndWrite(java.lang.String birdHistory)
Opens the fileName that was set when this object was created and writes the String that is passed to this method. The assumption is that the complete bird history will be written all at once. The action that is currently set for the object will determine if opening the file will overwrite or append to any previously existing file with this fileName.

Parameters:
birdHistory - String that contains a complete bird history.