From cac8228f38136cfc41673458c58c25f168b1e1ff Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 20 Nov 2012 20:02:47 +0100 Subject: 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. --- src/main/java/io/trygvis/esper/testing/Util.java | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/main/java/io/trygvis/esper/testing/Util.java (limited to 'src/main/java/io/trygvis/esper/testing/Util.java') 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> parseInt = new F>() { + public Option f(String s) { + try { + return some(Integer.parseInt(s)); + } catch (NumberFormatException e) { + return none(); + } + } + }; + + public static F> parseUri = new F>() { + public Option f(String s) { + try { + return some(URI.create(s)); + } catch (Throwable e) { + return none(); + } + } + }; + + public static F> parseBoolean = new F>() { + public Option f(String s) { + try { + return some(Boolean.parseBoolean(s)); + } catch (Throwable e) { + return none(); + } + } + }; + + public static Option childText(Element e, String childName) { + return fromNull(e.getChildText(childName)); + } + + public static Option child(Element e, String childName) { + return fromNull(e.getChild(childName)); + } +} -- cgit v1.2.3