[jboss-svn-commits] JBL Code SVN: r7858 - labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Nov 27 16:47:21 EST 2006


Author: burrsutter
Date: 2006-11-27 16:47:09 -0500 (Mon, 27 Nov 2006)
New Revision: 7858

Modified:
   labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java
Log:
added greater than and less than

Modified: labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java	2006-11-27 21:44:09 UTC (rev 7857)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java	2006-11-27 21:47:09 UTC (rev 7858)
@@ -72,5 +72,58 @@
 		String node = (String) xpath.evaluate(xpathExp, inputSource, XPathConstants.STRING);
 		return value.equals(node);
 	}
+
+	/** 
+	 * Uses XPath to look for the occurence of a certain tag, specific in the xpath expression.
+	 * 
+	 * @param message - the ESB Message which body content will be used.
+	 * @param xpathExp - XPath expression to find a node.
+	 * @param value - used to compare against the result found using the XPath expression.
+	 * @return true if node (returned by the xpath expression) is greater than the current value, false in all other cases.
+	 * @throws XPathExpressionException
+	 */
+	public static boolean xmlContentGreaterThan(Message message, String xpathExp, String value) throws XPathExpressionException 
+	{
+		XPath xpath = xpf.newXPath();
+		InputSource inputSource = new InputSource(new ByteArrayInputStream(message.getBody().getContents()));	
+		String node = (String) xpath.evaluate(xpathExp, inputSource, XPathConstants.STRING);
+		try {
+			double lValue = Double.parseDouble(value);
+			double lNode = Double.parseDouble(node);
+		} catch (NumberFormationException ne) {
+			throw ne;
+		}
+		if (lNode > lValue)
+			return true;
+		else
+			return false;
+		
+	}
+	
+	/** 
+	 * Uses XPath to look for the occurence of a certain tag, specific in the xpath expression.
+	 * 
+	 * @param message - the ESB Message which body content will be used.
+	 * @param xpathExp - XPath expression to find a node.
+	 * @param value - used to compare against the result found using the XPath expression.
+	 * @return true if node (returned by the xpath expression) is less than the current value, false in all other cases.
+	 * @throws XPathExpressionException
+	 */
+	public static boolean xmlContentLessThan(Message message, String xpathExp, String value) throws XPathExpressionException 
+	{
+		XPath xpath = xpf.newXPath();
+		InputSource inputSource = new InputSource(new ByteArrayInputStream(message.getBody().getContents()));
+		String node = (String) xpath.evaluate(xpathExp, inputSource, XPathConstants.STRING);
+		try {
+			double lValue = Double.parseDouble(value);
+			double lNode = Double.parseDouble(node);
+		} catch (NumberFormationException ne) {
+			throw ne;
+		}		
+		if (lNode < lValue)
+			return true;
+		else
+			return false;
+	}
 }
 	




More information about the jboss-svn-commits mailing list