net.sourceforge.cruisecontrol.labelincrementers
Class FormattedLabelIncrementer

java.lang.Object
  extended bynet.sourceforge.cruisecontrol.labelincrementers.FormattedLabelIncrementer
All Implemented Interfaces:
LabelIncrementer, java.io.Serializable

public class FormattedLabelIncrementer
extends java.lang.Object
implements LabelIncrementer

This class provides a label incrementation for creating consistent, formatted upper case labels. This class expects the label format to be either "x_y_z" or "y_z" where x is any String, y is an integer and z is one of REL, INT or BLD. * Usage: <formattedlabelincrementer prefix="false" defaultlabel="1.INT"/%gt;

Author:
Kevin Lee, Jeff Brekke (Jeff.Brekke@qg.com), alden almagro (alden@thoughtworks.com), Paul Julius (pdjulius@thoughtworks.com)
See Also:
Serialized Form

Constructor Summary
FormattedLabelIncrementer()
           
 
Method Summary
 java.lang.String getDefaultLabel()
          Get the default label
 java.lang.String incrementLabel(java.lang.String oldLabel, org.jdom.Element buildLog)
          Increments the label when a successful build occurs.
 boolean isPreBuildIncrementer()
          Checks whether the label should be incremented pre/post build
 boolean isValidLabel(java.lang.String label)
          Verify that the label specified is a valid label.
 void setDefaultLabel(java.lang.String label)
          Set the default label
 void setPreBuildIncrementer(boolean preInc)
          Set the pre/post behavior of the label incrementer
 void setPrefix(boolean prefix)
          Set whether a prefix is required or no
 void setSeparator(java.lang.String newSeparator)
          set the separtor to be use between parts of the build label, default is "_"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormattedLabelIncrementer

public FormattedLabelIncrementer()
Method Detail

setSeparator

public void setSeparator(java.lang.String newSeparator)
set the separtor to be use between parts of the build label, default is "_"

Parameters:
newSeparator - the character string to use as a separator

setPreBuildIncrementer

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

Parameters:
preInc - whether to increment the build before the build, default is false

setPrefix

public void setPrefix(boolean prefix)
Set whether a prefix is required or no

Parameters:
prefix - whether to include a prefix with the label, default is true

getDefaultLabel

public java.lang.String getDefaultLabel()
Get the default label

Specified by:
getDefaultLabel in interface LabelIncrementer
Returns:
string containing the default label

setDefaultLabel

public void setDefaultLabel(java.lang.String label)
Set the default label

Parameters:
label - string to set the default label to

isPreBuildIncrementer

public boolean isPreBuildIncrementer()
Checks whether the label should be incremented pre/post build

Specified by:
isPreBuildIncrementer in interface LabelIncrementer
Returns:
true if the label will be incremented before the build, else false

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_z" or "y_z", where x can be anything, y is an integer and z is one of REL, INT or BLD The y value will be incremented by one, the rest will remain the same. The label is converted to uppercase by default.

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.

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 '_' character, and an integer after the last but one occurrence of the '_' character, followed by REL, INT or BLD

Specified by:
isValidLabel in interface LabelIncrementer
Parameters:
label - the label to check for validity
Returns:
true if label is valid, else false