Github user mattf-horton commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/516#discussion_r110965812
  
    --- Diff: 
metron-platform/metron-common/src/main/java/org/apache/metron/common/dsl/functions/StringFunctions.java
 ---
    @@ -343,4 +343,120 @@ public Object apply(List<Object> args) {
           return String.format(format, formatArgs);
         }
       }
    +
    +  @Stellar( name="CHOMP"
    +          , description = "Removes one newline from end of a String if 
it's there, otherwise leave it alone. A newline is \"\\n\", \"\\r\", or 
\"\\r\\n\""
    +          , params = { "the String to chomp a newline from, may be null"}
    +          , returns = "String without newline, null if null String input"
    +  )
    +  public static class Chomp extends BaseStellarFunction {
    +
    +    @Override
    +    public Object apply(List<Object> strings) {
    +
    +      if(strings.size() == 0) {
    +        throw new IllegalArgumentException("[CHOMP] missing argument: 
string to chomp a newline from");
    +      }
    +
    +      String chomp = StringUtils.chomp((String) strings.get(0));
    +      return chomp;
    +    }
    +  }
    +  @Stellar( name="CHOP"
    +          , description = "Remove the last character from a String"
    +          , params = { "the String to chop last character from, may be 
null"}
    +          , returns = "String without last character, null if null String 
input"
    +  )
    +  public static class Chop extends BaseStellarFunction {
    +
    +    @Override
    +    public Object apply(List<Object> strings) {
    +
    +      if(strings.size() == 0) {
    +        throw new IllegalArgumentException("[CHOP] missing argument: 
string to be chopped");
    +      }
    +
    +      String chop = StringUtils.chop((String) strings.get(0));
    +      return chop;
    +    }
    +  }
    +
    +  @Stellar( name = "PREPEND_IF_MISSING"
    +          , description = "Prepends the prefix to the start of the string 
if the string does not already start with any of the prefixes"
    +          , params = {
    +          "str - The string."
    +          , "prefix - The string prefix to prepend to the start of the 
string"
    +          , "prefixes - Optional - Additional string prefixes that are 
valid"
    +  }
    +          , returns = "A new String if prefix was prepended, the same 
string otherwise."
    +  )
    +  public static class PrependIfMissing extends BaseStellarFunction {
    +
    +    @Override
    +    public Object apply(List<Object> strings) {
    +
    +      String prefixed;
    +      switch (strings.size()) {
    +        case 2: prefixed = StringUtils.prependIfMissing((String) 
strings.get(0), (String) strings.get(1));
    +          break;
    +        case 3: prefixed = StringUtils.prependIfMissing((String) 
strings.get(0), (String) strings.get(1), (String) strings.get(2));
    +          break;
    +        default: throw new IllegalArgumentException("[PREPEND_IF_MISSING] 
incorrect arguments: " + strings.toString() + "\nUsage: PREPEND_IF_MISSING 
<String> <prefix> [<prefix>...]");
    +      }
    +      return prefixed;
    +    }
    +  }
    +
    +  @Stellar( name = "APPEND_IF_MISSING"
    +          , description = "Appends the suffix to the end of the string if 
the string does not already end with any of the suffixes"
    +          , params = {
    +          "str - The string."
    +          , "suffix - The string suffix to append to the end of the string"
    +          , "suffixes - Optional - Additional string suffixes that are 
valid terminators"
    --- End diff --
    
    Same doc concern as in the .md file: Is "suffixes" a string, a regex, an 
array of strings, or what? If it is a single string, how does it represent 
plural suffixes?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to