diff options
author | Paul Duncan <pabs@pablotron.org> | 2018-09-06 08:40:23 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2018-09-06 08:40:23 -0400 |
commit | f422534cd4cf1ba32523c9fc798c207065038ca5 (patch) | |
tree | d3dce87dffeca2acfceab6aa9abf7046843f9145 /java/pablotron/luigi/Filter.java | |
parent | c02640d395fe95a41183a63bea29113676e92fae (diff) | |
download | luigi-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.java | 89 |
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("&"); - break; - case '<': - r.append("<"); - break; - case '>': - r.append(">"); - break; - case '\'': - r.append("'"); - break; - case '"': - r.append("""); - break; - default: - r.append(c); - } - } - - return r.toString(); -/* - * return val - * .replace("&", "&") - * .replace("<", "<") - * .replace(">", ">") - * .replace("'", "'") - * .replace("\"", """); - */ - } - }); - }}; -}; |