summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-03-10 15:55:23 (EST)
committer pelder2006-03-10 15:55:23 (EST)
commitcebaeea57095ef478b65253f019e396897532bce (patch)
tree09335135ac27a57a6e64a1a6cbc6c4540c938c28
parentaf4ae64f0a132ba5240e97f3fba16545648e5dcb (diff)
downloadorg.eclipse.jet-cebaeea57095ef478b65253f019e396897532bce.zip
org.eclipse.jet-cebaeea57095ef478b65253f019e396897532bce.tar.gz
org.eclipse.jet-cebaeea57095ef478b65253f019e396897532bce.tar.bz2
[131191] Utility class for exposing XPath conversion functions 'string', 'boolean' and 'number'.
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/xpath/XPathUtil.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/xpath/XPathUtil.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/xpath/XPathUtil.java
new file mode 100644
index 0000000..47e1d30
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/xpath/XPathUtil.java
@@ -0,0 +1,73 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.jet.xpath;
+
+import org.eclipse.jet.internal.xpath.functions.BooleanFunction;
+import org.eclipse.jet.internal.xpath.functions.NumberFunction;
+import org.eclipse.jet.internal.xpath.functions.StringFunction;
+
+/**
+ * Utility class for common XPath operations.
+ */
+public class XPathUtil
+{
+
+ /**
+ * Invoke the <a href="http://www.w3.org/TR/xpath#function-string">XPath 'string' function</a> on the argument.
+ * @param object the argument to convert to a string. Cannot be <code>null</code>
+ * @return the result of the XPath 'string' function.
+ * @throws NullPointerException if <code>object</code> is <code>null</code>.
+ */
+ public static String xpathString(Object object)
+ {
+ if(object == null)
+ {
+ throw new NullPointerException();
+ }
+ return StringFunction.evaluate(object);
+ }
+
+ /**
+ * Invoke the <a href="http://www.w3.org/TR/xpath#function-boolean">XPath 'boolean' function</a> on the argument.
+ * @param object the argument to convert to a boolean. Cannot be <code>null</code>
+ * @return the result of the XPath 'boolean' function.
+ * @throws NullPointerException if <code>object</code> is <code>null</code>.
+ */
+ public static boolean xpathBoolean(Object object)
+ {
+ if(object == null)
+ {
+ throw new NullPointerException();
+ }
+ return BooleanFunction.evaluate(object);
+ }
+
+ /**
+ * Invoke the <a href="http://www.w3.org/TR/xpath#function-number">XPath 'number' function</a> on the argument.
+ * @param object the argument to convert to a number (double). Cannot be <code>null</code>
+ * @return the result of the XPath 'number' function.
+ * @throws NullPointerException if <code>object</code> is <code>null</code>.
+ */
+ public static double xpathNumber(Object object)
+ {
+ if(object == null)
+ {
+ throw new NullPointerException();
+ }
+ return NumberFunction.evaluate(object);
+ }
+}