Class LegacyTaglibFunctions


  • public class LegacyTaglibFunctions
    extends java.lang.Object
    functions to be used within Proctor rules. Rules are null-safe and return non-null on any input

    was:

    JSTL Functions copied from org.apache.taglibs.standard.Functions, keep the above license statement to remain legal

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean contains​(java.lang.String input, java.lang.String substring)
      Tests if an input string contains the specified substring.
      static boolean containsIgnoreCase​(java.lang.String input, java.lang.String substring)
      Tests if an input string contains the specified substring in a case insensitive way.
      static boolean endsWith​(java.lang.String input, java.lang.String substring)  
      static int indexOf​(java.lang.String input, java.lang.String substring)
      Returns the index withing a string of the first occurrence of a specified substring.
      static java.lang.String join​(java.lang.String[] array, java.lang.String separator)
      Joins all elements of an array into a string.
      static int length​(java.lang.Object obj)  
      static java.lang.String replace​(java.lang.String input, java.lang.String substringBefore, java.lang.String substringAfter)  
      static java.lang.String[] split​(java.lang.String input, java.lang.String delimiters)
      Splits a string into an array of substrings.
      static boolean startsWith​(java.lang.String input, java.lang.String substring)  
      static java.lang.String substring​(java.lang.String input, int beginIndex, int endIndex)
      substring("foobarbaz", 3, 6)).isEqualTo("bar")
      static java.lang.String substringAfter​(java.lang.String input, java.lang.String substring)  
      static java.lang.String substringBefore​(java.lang.String input, java.lang.String substring)  
      static java.lang.String toLowerCase​(java.lang.String input)
      Converts all of the characters of the input string to lower case.
      static java.lang.String toUpperCase​(java.lang.String input)
      Converts all of the characters of the input string to upper case.
      static java.lang.String trim​(java.lang.String input)
      Removes white spaces from both ends of a string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LegacyTaglibFunctions

        public LegacyTaglibFunctions()
    • Method Detail

      • toUpperCase

        public static java.lang.String toUpperCase​(@Nullable
                                                   java.lang.String input)
        Converts all of the characters of the input string to upper case.
      • toLowerCase

        public static java.lang.String toLowerCase​(@Nullable
                                                   java.lang.String input)
        Converts all of the characters of the input string to lower case.
      • indexOf

        public static int indexOf​(@Nullable
                                  java.lang.String input,
                                  @Nullable
                                  java.lang.String substring)
        Returns the index withing a string of the first occurrence of a specified substring.
        Returns:
        0 if any argument is null, else index of first occurence, or -1
      • contains

        public static boolean contains​(@Nullable
                                       java.lang.String input,
                                       @Nullable
                                       java.lang.String substring)
        Tests if an input string contains the specified substring.
        Returns:
        true if any argument is null, else true if substring contained in input
      • containsIgnoreCase

        public static boolean containsIgnoreCase​(@Nullable
                                                 java.lang.String input,
                                                 @Nullable
                                                 java.lang.String substring)
        Tests if an input string contains the specified substring in a case insensitive way.
        Returns:
        true if any argument is null, else true if substring contained in input
      • startsWith

        public static boolean startsWith​(@Nullable
                                         java.lang.String input,
                                         @Nullable
                                         java.lang.String substring)
        Returns:
        true if any argument is null, else true if input starts with substring
      • endsWith

        public static boolean endsWith​(@Nullable
                                       java.lang.String input,
                                       @Nullable
                                       java.lang.String substring)
        Returns:
        true if any argument is null, else true if input ends with substring
      • substring

        public static java.lang.String substring​(@Nullable
                                                 java.lang.String input,
                                                 int beginIndex,
                                                 int endIndex)
        substring("foobarbaz", 3, 6)).isEqualTo("bar")
        Parameters:
        beginIndex - inclusive
        endIndex - exclusive, negative index means infinite
        Returns:
        substring after normalizing arguments, empty string if input is null
      • substringAfter

        public static java.lang.String substringAfter​(@Nullable
                                                      java.lang.String input,
                                                      @Nullable
                                                      java.lang.String substring)
        Parameters:
        input - if null, empty string is returned
        substring - if null, input string is returned
        Returns:
        a subset of a string before a specific substring.
      • substringBefore

        public static java.lang.String substringBefore​(@Nullable
                                                       java.lang.String input,
                                                       @Nullable
                                                       java.lang.String substring)
        Parameters:
        input - if null, empty string is returned
        substring - if null, input string is returned
        Returns:
        arguments is null a subset of a string following a specific substring.
      • trim

        public static java.lang.String trim​(@Nullable
                                            java.lang.String input)
        Removes white spaces from both ends of a string.
        Returns:
        empty string if input is null, trimmed else
      • replace

        public static java.lang.String replace​(@Nullable
                                               java.lang.String input,
                                               @Nullable
                                               java.lang.String substringBefore,
                                               java.lang.String substringAfter)
        Parameters:
        substringBefore - if empty, input string is returned unchanged
        Returns:
        a string resulting from replacing in an input string all occurrences of a non-empty "before" string into an "after" substring.
      • split

        public static java.lang.String[] split​(@Nullable
                                               java.lang.String input,
                                               @Nullable
                                               java.lang.String delimiters)
        Splits a string into an array of substrings.
        Parameters:
        delimiters - "" if null
        Returns:
        [""] when input is null
      • length

        public static int length​(@Nullable
                                 java.lang.Object obj)
        Returns:
        the number of items in a collection, or the number of characters in a string.
      • join

        public static java.lang.String join​(@Nullable
                                            java.lang.String[] array,
                                            @Nullable
                                            java.lang.String separator)
        Joins all elements of an array into a string.
        Returns:
        empty string if input is null