com.technicolor.eloyente
Class XPathExpressionHandler

java.lang.Object
  extended by com.technicolor.eloyente.XPathExpressionHandler

public class XPathExpressionHandler
extends Object

This is a convenience class for working with XPath expressions.

It is used in ElOyente for filters and for environment variables, based on XMPP events. XMPP events are XML messages, and a filters uses the test() function of this class to check whether the XMPP event should trigger a Jenkins job. The evaluate() function at the other hand will be used to extract data from the XMPP event, and to store it in environment variables, such that the Jenkins job which is triggered by the event can use the data.

Author:
Frank Vanderhallen

Constructor Summary
XPathExpressionHandler()
          Default constructor
XPathExpressionHandler(String expression)
          Constructor which configures an expression
 
Method Summary
 String evaluate(String xml)
          Evaluate the expression
 String getExpression()
          Function to retrieve the expression
 void setExpression(String expression)
          Function to change the expression
 boolean test(String xml)
          Test the expression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPathExpressionHandler

public XPathExpressionHandler()
                       throws XPathExpressionException
Default constructor

Creates an XPathExpression handler with an empty expression.

Throws:
XPathExpressionException

XPathExpressionHandler

public XPathExpressionHandler(String expression)
                       throws XPathExpressionException
Constructor which configures an expression

Parameters:
expression - An expression in XPath notation
Throws:
XPathExpressionException
Method Detail

setExpression

public void setExpression(String expression)
                   throws XPathExpressionException
Function to change the expression

Parameters:
expression - An expression in XPath notation.
Throws:
XPathExpressionException

getExpression

public String getExpression()
Function to retrieve the expression

Returns:
The expression that the object holds

evaluate

public String evaluate(String xml)
                throws XPathExpressionException
Evaluate the expression

This function evaluates the expression against the provided XML document and returns the result as a string.

Parameters:
xml - The XML document to evaluate
Returns:
The result of evaluating the expression
Throws:
XPathExpressionException

test

public boolean test(String xml)
             throws XPathExpressionException
Test the expression

This function evaluates the expression against the provided XML document and returns true if the expression result is not empty.

Parameters:
xml - The XML document to evaluate
Returns:
True if the result is not empty
Throws:
XPathExpressionException


Copyright © 2004-2012. All Rights Reserved.