net.sourceforge.cruisecontrol.labelincrementers
Class DefaultLabelIncrementer

java.lang.Object
  extended bynet.sourceforge.cruisecontrol.labelincrementers.DefaultLabelIncrementer
All Implemented Interfaces:
LabelIncrementer, java.io.Serializable
Direct Known Subclasses:
CVSLabelIncrementer

public class DefaultLabelIncrementer
extends java.lang.Object
implements LabelIncrementer

This class provides a default label incrementation. This class expects the label format to be "xy", where x is any String and y is an integer and a separator. The default separator is "." and can be modified using setSeparator(java.lang.String).

Author:
alden almagro, Paul Julius
See Also:
Serialized Form

Constructor Summary
DefaultLabelIncrementer()
           
 
Method Summary
 java.lang.String getDefaultLabel()
          The instance must be fully initialized before calling this method.
 java.lang.String incrementLabel(java.lang.String oldLabel, org.jdom.Element buildLog)
          Increments the label when a successful build occurs.
 boolean isPreBuildIncrementer()
          Some implementations of LabelIncrementer, such as those involving dates, are better suited to being incremented before building rather than after building.
 boolean isValidLabel(java.lang.String label)
          Verify that the label specified is a valid label.
 void setDefaultLabel(java.lang.String label)
           
 void setPreBuildIncrementer(boolean preInc)
          Set the pre/post behavior of the label incrementer.
 void setSeparator(java.lang.String newSeparator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLabelIncrementer

public DefaultLabelIncrementer()
Method Detail

incrementLabel

public java.lang.String incrementLabel(java.lang.String oldLabel,
                                       org.jdom.Element buildLog)
Increments the label when a successful build occurs. Assumes that the label will be in the format of "x.y", where x can be anything, and y is an integer. The y value will be incremented by one, the rest will remain the same.

Specified by:
incrementLabel in interface LabelIncrementer
Parameters:
oldLabel - Label from previous successful build.
buildLog - JDOM Element representation of the build.
Returns:
Label to use for most recent successful build.

isPreBuildIncrementer

public boolean isPreBuildIncrementer()
Description copied from interface: LabelIncrementer
Some implementations of LabelIncrementer, such as those involving dates, are better suited to being incremented before building rather than after building. This method determines whether to increment before building or after building.

Specified by:
isPreBuildIncrementer in interface LabelIncrementer

setPreBuildIncrementer

public void setPreBuildIncrementer(boolean preInc)
Set the pre/post behavior of the label incrementer.


isValidLabel

public boolean isValidLabel(java.lang.String label)
Verify that the label specified is a valid label. In this case a valid label contains at least one separator character, and an integer after the last occurrence of the separator character.

Specified by:
isValidLabel in interface LabelIncrementer
Parameters:
label - user-supplied label
Returns:
true if it is a valid label.

setSeparator

public void setSeparator(java.lang.String newSeparator)

getDefaultLabel

public java.lang.String getDefaultLabel()
The instance must be fully initialized before calling this method.

Specified by:
getDefaultLabel in interface LabelIncrementer
Returns:
defaultLabel
Throws:
java.lang.IllegalStateException - if the instance is not properly initialized e.g. if the set separator doesn't match the set default label

setDefaultLabel

public void setDefaultLabel(java.lang.String label)