com.kerrybuckley.cctrayicon
Class AbstractCcStatus

java.lang.Object
  extended bycom.kerrybuckley.cctrayicon.AbstractCcStatus
All Implemented Interfaces:
CcStatus
Direct Known Subclasses:
SwingCcStatus

public abstract class AbstractCcStatus
extends java.lang.Object
implements CcStatus

Abstract implementation of CcStatus, with no display functionality.

Author:
Kerry Buckley

Field Summary
protected static java.lang.String DEFAULT_URL
           
protected static java.lang.String PREF_KEY_ALERT_ON_FAIL
           
protected static java.lang.String PREF_KEY_ALERT_ON_FIX
           
protected static java.lang.String PREF_KEY_ALERT_ON_SUCCESS
           
protected static java.lang.String PREF_KEY_PROJECTS
           
protected static java.lang.String PREF_KEY_URL
           
protected static java.util.prefs.Preferences PREFS
           
 
Constructor Summary
  AbstractCcStatus(CcStatusMonitor monitor)
          Construct a new status object, reading server details from user preferences.
protected AbstractCcStatus(CcStatusMonitor monitor, java.lang.String serverUrl, java.util.prefs.Preferences prefs)
          Construct a new status object using the specified URL.
 
Method Summary
protected  boolean getAlertOnFail()
           
protected  boolean getAlertOnFix()
           
protected  boolean getAlertOnSuccess()
           
protected  boolean getCheckAllProjects()
           
protected  java.util.List getProjectsToCheck()
           
protected  java.lang.String getServer()
           
 boolean isBuildClean()
          Returns a flag indicating whether the build was clean when last checked.
 boolean isServerReachable()
          Returns a flag indicating whether the server was reachable when last checked.
protected  void readPrefs()
          Read the current configuration from the user preferences, or set defaults if no preferences found.
 void setServer(java.lang.String serverUrl)
          Set the server to monitor.
protected  void setUrl(java.lang.String serverUrl)
          Set the URL.
 void update()
          Update the status from the CruiseControl web page.
protected abstract  void warn(java.lang.String message)
          Generate a warning to the user.
protected  void writePrefs()
          Write the current configuration to the user preferences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFS

protected static final java.util.prefs.Preferences PREFS

PREF_KEY_URL

protected static final java.lang.String PREF_KEY_URL
See Also:
Constant Field Values

DEFAULT_URL

protected static final java.lang.String DEFAULT_URL

PREF_KEY_PROJECTS

protected static final java.lang.String PREF_KEY_PROJECTS
See Also:
Constant Field Values

PREF_KEY_ALERT_ON_FAIL

protected static final java.lang.String PREF_KEY_ALERT_ON_FAIL
See Also:
Constant Field Values

PREF_KEY_ALERT_ON_FIX

protected static final java.lang.String PREF_KEY_ALERT_ON_FIX
See Also:
Constant Field Values

PREF_KEY_ALERT_ON_SUCCESS

protected static final java.lang.String PREF_KEY_ALERT_ON_SUCCESS
See Also:
Constant Field Values
Constructor Detail

AbstractCcStatus

public AbstractCcStatus(CcStatusMonitor monitor)
Construct a new status object, reading server details from user preferences.

Parameters:
monitor - the monitor which this object should communicate

AbstractCcStatus

protected AbstractCcStatus(CcStatusMonitor monitor,
                           java.lang.String serverUrl,
                           java.util.prefs.Preferences prefs)
Construct a new status object using the specified URL. Does not read from user preferences. This constructor is only intended for testing.

Parameters:
monitor - the monitor which this object should communicate
serverUrl - the URL of the Cruise Control server status page
prefs - a Preferences object to read from and write to.
Method Detail

isBuildClean

public boolean isBuildClean()
                     throws java.io.IOException
Description copied from interface: CcStatus
Returns a flag indicating whether the build was clean when last checked. Calling this method does not force a check of the server.

Specified by:
isBuildClean in interface CcStatus
Returns:
whether the build is clean
Throws:
java.io.IOException - if the status can't be read from the configured server
See Also:
CcStatus.isBuildClean()

isServerReachable

public boolean isServerReachable()
Description copied from interface: CcStatus
Returns a flag indicating whether the server was reachable when last checked. Calling this method does not force a check of the server.

Specified by:
isServerReachable in interface CcStatus
Returns:
whether the server was reachable
See Also:
CcStatus.isServerReachable()

update

public void update()
Description copied from interface: CcStatus
Update the status from the CruiseControl web page.

Specified by:
update in interface CcStatus
See Also:
CcStatus.update()

setUrl

protected void setUrl(java.lang.String serverUrl)
               throws java.net.MalformedURLException
Set the URL. Intended for testing only, to simulate a change in status.

Parameters:
serverUrl - the new URL (as a string)
Throws:
java.net.MalformedURLException - if the URL can't be parsed

setServer

public void setServer(java.lang.String serverUrl)
Description copied from interface: CcStatus
Set the server to monitor.

Specified by:
setServer in interface CcStatus
Parameters:
serverUrl - the URL of the Cruise Control server
See Also:
CcStatus.setServer(java.lang.String)

getServer

protected java.lang.String getServer()
Returns:
the configured server URL, as a string

warn

protected abstract void warn(java.lang.String message)
Generate a warning to the user.

Parameters:
message - the message to display

readPrefs

protected void readPrefs()
Read the current configuration from the user preferences, or set defaults if no preferences found.


writePrefs

protected void writePrefs()
Write the current configuration to the user preferences.


getAlertOnFail

protected boolean getAlertOnFail()
Returns:
Returns the alertOnFail.

getAlertOnFix

protected boolean getAlertOnFix()
Returns:
Returns the alertOnFix flag. For testing only.

getAlertOnSuccess

protected boolean getAlertOnSuccess()
Returns:
Returns the alertOnSuccess flag. For testing only.

getCheckAllProjects

protected boolean getCheckAllProjects()
Returns:
Returns the checkAllProjects flag. For testing only.

getProjectsToCheck

protected java.util.List getProjectsToCheck()
Returns:
Returns the projectsToCheck list. For testing only.