diff options
author | pabs@pablotron.org <pabs@pablotron.org> | 2014-12-18 16:09:13 -0500 |
---|---|---|
committer | pabs@pablotron.org <pabs@pablotron.org> | 2014-12-18 16:09:13 -0500 |
commit | 6cb72314f1d60e0836e7fe7aedad2872051f148f (patch) | |
tree | 4c8a6f01eac7db86ab40ee61d7c78053165d5bf4 /java/pablotron/luigi/Parser.java | |
parent | ce4be12c9afb8f7eeefee9f7ab4636cfb6134a2c (diff) | |
download | luigi-template-6cb72314f1d60e0836e7fe7aedad2872051f148f.tar.bz2 luigi-template-6cb72314f1d60e0836e7fe7aedad2872051f148f.zip |
handle empty argument list more efficiently
Diffstat (limited to 'java/pablotron/luigi/Parser.java')
-rw-r--r-- | java/pablotron/luigi/Parser.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/java/pablotron/luigi/Parser.java b/java/pablotron/luigi/Parser.java index 6bf2638..207df86 100644 --- a/java/pablotron/luigi/Parser.java +++ b/java/pablotron/luigi/Parser.java @@ -87,6 +87,8 @@ public final class Parser { return r.toArray(new Action[r.size()]); } + private static final String[] NO_ARGS = {}; + public static FilterReference[] parse_filters( String filters_str ) throws LuigiError { @@ -104,8 +106,14 @@ public final class Parser { if (!m.find()) throw new LuigiError("invalid filter: " + f); + // get arguments string + String args = m.group(2).trim(); + // append new filter reference to result - r.add(new FilterReference(m.group(1), RE_DELIM_ARGS.split(m.group(2).trim()))); + r.add(new FilterReference( + m.group(1), + (args.length() > 0) ? RE_DELIM_ARGS.split(args) : NO_ARGS + )); } // return result |