aboutsummaryrefslogtreecommitdiff
path: root/java/pablotron/luigi/Filter.java
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-09-06 08:40:23 -0400
committerPaul Duncan <pabs@pablotron.org>2018-09-06 08:40:23 -0400
commitf422534cd4cf1ba32523c9fc798c207065038ca5 (patch)
treed3dce87dffeca2acfceab6aa9abf7046843f9145 /java/pablotron/luigi/Filter.java
parentc02640d395fe95a41183a63bea29113676e92fae (diff)
downloadluigi-template-f422534cd4cf1ba32523c9fc798c207065038ca5.tar.bz2
luigi-template-f422534cd4cf1ba32523c9fc798c207065038ca5.zip
java: add pom.xml, mv sources to src/main/java/org/pablotron, add src/test, add initial junit tests, update makefile and .gitignore
Diffstat (limited to 'java/pablotron/luigi/Filter.java')
-rw-r--r--java/pablotron/luigi/Filter.java89
1 files changed, 0 insertions, 89 deletions
diff --git a/java/pablotron/luigi/Filter.java b/java/pablotron/luigi/Filter.java
deleted file mode 100644
index d89beab..0000000
--- a/java/pablotron/luigi/Filter.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package pablotron.luigi;
-
-import java.util.Map;
-import java.util.HashMap;
-
-public final class Filter {
- public interface Handler {
- public String filter(String val, String args[], Map<String, String> row);
- };
-
- public static Map<String, Handler> FILTERS = new HashMap<String, Handler>() {{
- put("null", new Handler() {
- public String filter(String val, String args[], Map<String, String> row) {
- return "";
- }
- });
-
- put("s", new Handler() {
- public String filter(String val, String args[], Map<String, String> row) {
- int v = Integer.parseInt(val);
- return (v == 1) ? "" : "s";
- }
- });
-
- put("uc", new Handler() {
- public String filter(String val, String args[], Map<String, String> row) {
- return val.toUpperCase();
- }
- });
-
- put("lc", new Handler() {
- public String filter(String val, String args[], Map<String, String> row) {
- return val.toLowerCase();
- }
- });
-
- put("length", new Handler() {
- public String filter(String val, String args[], Map<String, String> row) {
- return Integer.toString(val.length());
- }
- });
-
- put("trim", new Handler() {
- public String filter(String val, String args[], Map<String, String> row) {
- return val.trim();
- }
- });
-
- put("h", new Handler() {
- public String filter(String val, String args[], Map<String, String> row) {
- StringBuilder r = new StringBuilder(val.length());
-
- for (int i = 0, l = val.length(); i < l; i++) {
- char c = val.charAt(i);
-
- switch (c) {
- case '&':
- r.append("&amp;");
- break;
- case '<':
- r.append("&lt;");
- break;
- case '>':
- r.append("&gt;");
- break;
- case '\'':
- r.append("&apos;");
- break;
- case '"':
- r.append("&quot;");
- break;
- default:
- r.append(c);
- }
- }
-
- return r.toString();
-/*
- * return val
- * .replace("&", "&amp;")
- * .replace("<", "&lt;")
- * .replace(">", "&gt;")
- * .replace("'", "&apos;")
- * .replace("\"", "&quot;");
- */
- }
- });
- }};
-};