org.apache.solr.common.util

## Class StrUtils

- java.lang.Object
- - org.apache.solr.common.util.StrUtils

-     public class StrUtils
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static char[]` | `HEX_DIGITS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StrUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `appendEscapedTextToBuilder(StringBuilder out, String item, char separator)` writes chars from item to out, backslash escaping as needed based on separator -- but does not append the seperator itself
    `static String` | `escapeTextWithSeparator(String item, char separator)` Creates a new copy of the string with the separator backslash escaped.
    `static String` | `formatString(String pattern, Object... args)` Format using MesssageFormat but with the ROOT locale
    `static String` | `join(Collection<?> items, char separator)` Creates a backslash escaped string, joining all the items.
    `static boolean` | `parseBool(String s)` how to transform a String into a boolean...
    `static boolean` | `parseBool(String s, boolean def)` `NullPointerException` and `SolrException` free version of `parseBool(String)`
    `static boolean` | `parseBoolean(String s)` Return if a string starts with '1', 't', or 'T' and return false otherwise.
    `static void` | `partialURLEncodeVal(Appendable dest, String val)` URLEncodes a value, replacing only enough chars so that the URL may be unambiguously pasted back into a browser.
    `static List<String>` | `splitFileNames(String fileNames)` Splits file names separated by comma character.
    `static List<String>` | `splitSmart(String s, char separator)` Split a string based on a separator, but don't split if it's inside a string.
    `static List<String>` | `splitSmart(String s, String separator, boolean decode)` Splits a backslash escaped string on the separator.
    `static List<String>` | `splitWS(String s, boolean decode)`
    `static List<String>` | `toLower(List<String> strings)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### HEX_DIGITS

          public static final char[] HEX_DIGITS

  - ### Constructor Detail

    - #### StrUtils

          public StrUtils()

  - ### Method Detail

    - #### splitSmart

          public static List<String> splitSmart(String s,
                                                char separator)

      Split a string based on a separator, but don't split if it's inside a string. Assume '\' escapes the next char both inside and outside strings.

    - #### splitSmart

          public static List<String> splitSmart(String s,
                                                String separator,
                                                boolean decode)

      Splits a backslash escaped string on the separator.

      Current backslash escaping supported:
      \n \t \r \b \f are escaped the same as a Java String
      Other characters following a backslash are produced verbatim (\c => c)

      Parameters:
        `s` - the string to split
        `separator` - the separator to split on
        `decode` - decode backslash escaping

    - #### splitFileNames

          public static List<String> splitFileNames(String fileNames)

      Splits file names separated by comma character. File names can contain comma characters escaped by backslash '\'
      Parameters:
        `fileNames` - the string containing file names
      Returns:
        a list of file names with the escaping backslashed removed

    - #### join

          public static String join(Collection<?> items,
                                    char separator)

      Creates a backslash escaped string, joining all the items.
      See Also:
        `escapeTextWithSeparator(java.lang.String, char)`

    - #### splitWS

          public static List<String> splitWS(String s,
                                             boolean decode)

    - #### toLower

          public static List<String> toLower(List<String> strings)

    - #### parseBoolean

          public static boolean parseBoolean(String s)

      Return if a string starts with '1', 't', or 'T' and return false otherwise.

    - #### parseBool

          public static boolean parseBool(String s)

      how to transform a String into a boolean... more flexible than Boolean.parseBoolean() to enable easier integration with html forms.

    - #### parseBool

          public static boolean parseBool(String s,
                                          boolean def)

      `NullPointerException` and `SolrException` free version of `parseBool(String)`
      Returns:
        parsed boolean value (or def, if s is null or invalid)

    - #### partialURLEncodeVal

          public static void partialURLEncodeVal(Appendable dest,
                                                 String val)
                                          throws IOException

      URLEncodes a value, replacing only enough chars so that the URL may be unambiguously pasted back into a browser.

      Characters with a numeric value less than 32 are encoded. &,=,%,+,space are encoded.

      Throws:
        `IOException`

    - #### escapeTextWithSeparator

          public static String escapeTextWithSeparator(String item,
                                                       char separator)

      Creates a new copy of the string with the separator backslash escaped.
      See Also:
        `join(java.util.Collection<?>, char)`

    - #### appendEscapedTextToBuilder

          public static void appendEscapedTextToBuilder(StringBuilder out,
                                                        String item,
                                                        char separator)

      writes chars from item to out, backslash escaping as needed based on separator -- but does not append the seperator itself

    - #### formatString

          public static String formatString(String pattern,
                                            Object... args)

      Format using MesssageFormat but with the ROOT locale

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.