aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/trygvis/esper/testing/Util.java
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-06 12:43:09 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-06 12:43:09 +0100
commit37207267bf3a1149f78a5022ed8e016cac6b85ca (patch)
tree6cb1166ba3904780ab64f5edf52528bc743c0817 /src/main/java/io/trygvis/esper/testing/Util.java
parenta9543bd5570b7435b760a8eb3c8b457c889a5fca (diff)
downloadesper-testing-37207267bf3a1149f78a5022ed8e016cac6b85ca.tar.gz
esper-testing-37207267bf3a1149f78a5022ed8e016cac6b85ca.tar.bz2
esper-testing-37207267bf3a1149f78a5022ed8e016cac6b85ca.tar.xz
esper-testing-37207267bf3a1149f78a5022ed8e016cac6b85ca.zip
o Adding a view for showing a list of people.
Diffstat (limited to 'src/main/java/io/trygvis/esper/testing/Util.java')
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/Util.java47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/Util.java b/src/main/java/io/trygvis/esper/testing/Util.java
index c33e64c..6b9d1b6 100755
--- a/src/main/java/io/trygvis/esper/testing/Util.java
+++ b/src/main/java/io/trygvis/esper/testing/Util.java
@@ -73,12 +73,37 @@ public class Util {
}
};
- public static Option<String> childText(Element e, String childName) {
- return fromNull(e.getChildText(childName));
- }
+ // -----------------------------------------------------------------------
+ // SQL
+ // -----------------------------------------------------------------------
- public static Option<Element> child(Element e, String childName) {
- return fromNull(e.getChild(childName));
+ public static String orderBy(Iterable<String> inputs, String... allowed) {
+ StringBuilder buffer = new StringBuilder();
+
+ for (String input : inputs) {
+ boolean desc = false;
+
+ if (input.endsWith("-")) {
+ desc = true;
+ input = input.substring(0, input.length() - 1);
+ }
+
+ for (String s : allowed) {
+ if (s.equals(input)) {
+ if (buffer.length() == 0) {
+ buffer.append(" ORDER BY ");
+ } else {
+ buffer.append(", ");
+ }
+ buffer.append(s);
+ if (desc) {
+ buffer.append(" DESC");
+ }
+ }
+ }
+ }
+
+ return buffer.toString();
}
public static UUID[] toUuidArray(ResultSet rs, int index) throws SQLException {
@@ -102,4 +127,16 @@ public class Util {
}
return list;
}
+
+ // -----------------------------------------------------------------------
+ // XML
+ // -----------------------------------------------------------------------
+
+ 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));
+ }
}