aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/trygvis/esper/testing/Util.java
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-11-20 20:02:47 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2012-11-20 20:02:47 +0100
commitcac8228f38136cfc41673458c58c25f168b1e1ff (patch)
tree34f482cfd506a3b217f9f62fc00719b7f36e4a9e /src/main/java/io/trygvis/esper/testing/Util.java
parent8596b9b566745ca65b3a75fe8b6d4c091369fedc (diff)
downloadesper-testing-cac8228f38136cfc41673458c58c25f168b1e1ff.tar.gz
esper-testing-cac8228f38136cfc41673458c58c25f168b1e1ff.tar.bz2
esper-testing-cac8228f38136cfc41673458c58c25f168b1e1ff.tar.xz
esper-testing-cac8228f38136cfc41673458c58c25f168b1e1ff.zip
o Adding BoneCP init to Config.
o Starting on an actor-like structure for the running jobs. o Loading Nexus servers and group ids to look for from the database.
Diffstat (limited to 'src/main/java/io/trygvis/esper/testing/Util.java')
-rw-r--r--src/main/java/io/trygvis/esper/testing/Util.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/Util.java b/src/main/java/io/trygvis/esper/testing/Util.java
new file mode 100644
index 0000000..49d6a37
--- /dev/null
+++ b/src/main/java/io/trygvis/esper/testing/Util.java
@@ -0,0 +1,48 @@
+package io.trygvis.esper.testing;
+
+import fj.*;
+import fj.data.*;
+import static fj.data.Option.*;
+import org.jdom2.*;
+
+import java.net.*;
+
+public class Util {
+ public static F<String, Option<Integer>> parseInt = new F<String, Option<Integer>>() {
+ public Option<Integer> f(String s) {
+ try {
+ return some(Integer.parseInt(s));
+ } catch (NumberFormatException e) {
+ return none();
+ }
+ }
+ };
+
+ public static F<String, Option<URI>> parseUri = new F<String, Option<URI>>() {
+ public Option<URI> f(String s) {
+ try {
+ return some(URI.create(s));
+ } catch (Throwable e) {
+ return none();
+ }
+ }
+ };
+
+ public static F<String, Option<Boolean>> parseBoolean = new F<String, Option<Boolean>>() {
+ public Option<Boolean> f(String s) {
+ try {
+ return some(Boolean.parseBoolean(s));
+ } catch (Throwable e) {
+ return none();
+ }
+ }
+ };
+
+ public static Option<String> childText(Element e, String childName) {
+ return fromNull(e.getChildText(childName));
+ }
+
+ public static Option<Element> child(Element e, String childName) {
+ return fromNull(e.getChild(childName));
+ }
+}