net.sourceforge.cruisecontrol.util
Class XPathAwareChild

java.lang.Object
  extended bynet.sourceforge.cruisecontrol.util.XPathAwareChild
Direct Known Subclasses:
NamedXPathAwareChild, SfeeDocumentManagerPublisher.Status

public class XPathAwareChild
extends java.lang.Object

This class represents a plugin subelement that returns either a fixed value or uses an xpath expression to retrieve a value from an XML document. Instances of this class represent an element that has either a fixed value, e.g.

 <mychild value="foo"/>
 

or one that has an xpath expression that will be executed against CruiseControl's log file at execution time, e.g.

 <mychild xpathExpression="sum(cruisecontrol/testsuite/@tests)"/>
 

or one that has an xpath expression that will be executed against a named xml file at execution time, e.g.

 <mychild xpathExpression="sum(cruisecontrol/testsuite/@tests)" xmlFile="/path/to/my/xml/file"/>
 
For example usage in a plugin, see SfeeDocumentManagerPublisher.createDescription().

Author:
Paul Julius, Kent Spillner
See Also:
SfeeDocumentManagerPublisher

Constructor Summary
XPathAwareChild()
           
 
Method Summary
 java.lang.String getFixedValue()
           
 java.lang.String getXpathExpression()
           
 java.lang.String lookupValue(org.jdom.Element log)
          Looks up the appropriate value based on how the class is being used.
protected  void markDirty()
          Called to indicate that this classs needs to be validated, as after a change to a member variable.
 void setInputStream(java.io.InputStream in)
          Used for testing.
 void setValue(java.lang.String value)
          If this value is set, then it is considered to be a "fixed" value that will be returned by the lookupValue method.
 void setXMLFile(java.lang.String filename)
           
 void setXPathExpression(java.lang.String xpathExpression)
           
 void validate()
          Must be called after setting all the instance values and before calling lookupValue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPathAwareChild

public XPathAwareChild()
Method Detail

setValue

public void setValue(java.lang.String value)
If this value is set, then it is considered to be a "fixed" value that will be returned by the lookupValue method. If this is set, then xpathExpression and xmlFile should NOT be set.


setXPathExpression

public void setXPathExpression(java.lang.String xpathExpression)

setInputStream

public void setInputStream(java.io.InputStream in)
Used for testing. CruiseControl will not be able to call this method directly, so it has not applicability to the intended use of this class. Use this method from unit tests to set an InputStream instead of an actual xmlFile.


setXMLFile

public void setXMLFile(java.lang.String filename)

getFixedValue

public java.lang.String getFixedValue()

getXpathExpression

public java.lang.String getXpathExpression()

lookupValue

public java.lang.String lookupValue(org.jdom.Element log)
                             throws CruiseControlException
Looks up the appropriate value based on how the class is being used. It will return either the fixed value, or execute the xpath expression against the appropriate xml file/log.

Throws:
CruiseControlException

validate

public void validate()
              throws CruiseControlException
Must be called after setting all the instance values and before calling lookupValue.

Throws:
CruiseControlException

markDirty

protected void markDirty()
Called to indicate that this classs needs to be validated, as after a change to a member variable.