net.sourceforge.cruisecontrol
Class LogFile

java.lang.Object
  extended bynet.sourceforge.cruisecontrol.LogFile
All Implemented Interfaces:
java.io.Serializable

public class LogFile
extends java.lang.Object
implements java.io.Serializable

Represents a XML log file. Build information that is based on the log name is in the BuildInfo class

Author:
Hack Kampbjorn
See Also:
BuildInfo, Serialized Form

Field Summary
static java.lang.String LOG_COMPRESSED_SUFFIX
           
static java.lang.String LOG_SUFFIX
           
 
Constructor Summary
LogFile(java.io.File xmlFile)
          Creates a new instance of LogFile
LogFile(java.io.File logDir, java.lang.String logName)
          Creates a new instance of LogFile
 
Method Summary
 org.jdom.Document asDocument()
           
 BuildInfo getBuildInfo()
          Gets the build information for this log file like the label and build date.
 java.io.File getFile()
          Gets the file object.
 java.io.InputStream getInputStream()
          Gets a stream with the log file's content.
static LogFile getLatestLogFile(java.io.File logDir)
          Gets the latest log file in a given directory.
static LogFile getLatestSuccessfulLogFile(java.io.File logDir)
          Gets the latest successful log file in a given directory.
 java.io.File getLogDirectory()
          Gets the log file's directory.
 java.lang.String getName()
          Gets the log's name.
 LogFileReader getReader()
           
 boolean isCompressed()
          Whether the log file is compressed or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_SUFFIX

public static final java.lang.String LOG_SUFFIX
See Also:
Constant Field Values

LOG_COMPRESSED_SUFFIX

public static final java.lang.String LOG_COMPRESSED_SUFFIX
See Also:
Constant Field Values
Constructor Detail

LogFile

public LogFile(java.io.File logDir,
               java.lang.String logName)
Creates a new instance of LogFile

Parameters:
logDir - directory with the XML log file
logName - name of the XML log file

LogFile

public LogFile(java.io.File xmlFile)
Creates a new instance of LogFile

Parameters:
xmlFile - the XML log file
Method Detail

getLatestLogFile

public static LogFile getLatestLogFile(java.io.File logDir)
Gets the latest log file in a given directory. Since all of our logs contain a date/time string, this method is actually getting the log file that comes last alphabetically.

Returns:
The latest log file or null if there are no log files in the given directory.

getLatestSuccessfulLogFile

public static LogFile getLatestSuccessfulLogFile(java.io.File logDir)
Gets the latest successful log file in a given directory. Since all of our logs contain a date/time string, this method is actually getting the log file that comes last alphabetically.

Returns:
The latest log file or null if there are no successful log files in the given directory

getBuildInfo

public BuildInfo getBuildInfo()
                       throws java.text.ParseException
Gets the build information for this log file like the label and build date.

Returns:
the log file's build information
Throws:
java.text.ParseException

getFile

public java.io.File getFile()
Gets the file object.

Returns:
the log file

isCompressed

public boolean isCompressed()
Whether the log file is compressed or not.

Returns:
true if the file is compressed

getName

public java.lang.String getName()
Gets the log's name. This is the file name without a file extension like .xml or .xml.gz. Use getFile().getName() to get the file name with extension.

Returns:
the name of the log

getLogDirectory

public java.io.File getLogDirectory()
Gets the log file's directory.

Returns:
the parent directory of the log file

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Gets a stream with the log file's content.

Returns:
the file content as a stream
Throws:
java.io.IOException - if there is an error reading the file

asDocument

public org.jdom.Document asDocument()
                             throws org.jdom.JDOMException,
                                    java.io.IOException
Throws:
org.jdom.JDOMException
java.io.IOException

getReader

public LogFileReader getReader()
                        throws org.jdom.JDOMException,
                               java.io.IOException
Throws:
org.jdom.JDOMException
java.io.IOException