ur_rna.Utilities

## Class Strings

- java.lang.Object
- - ur_rna.Utilities.Strings

-     public abstract class Strings
      extends java.lang.Object

  A collection of String utilities.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DefaultBufferSize`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Strings()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `asBool(java.lang.String boolString)`
    `static boolean` | `asBool(java.lang.String boolString, boolean defaultIfEmpty)` Attempts to convert a string representing a conceptual "true/false" into a boolean.
    `static java.lang.String` | `escapeHTML(java.lang.String s)`
    `static java.lang.String` | `escapeStringLiteral(java.lang.String subject)` Used to convert raw characters to their escaped version when these raw version cannot be used as part of a Java string literal.
    `static java.lang.String` | `escapeStringLiteral(java.lang.String subject, int escapeOptions)` Used to convert raw characters to their escaped version when these raw version cannot be used as part of a Java string literal.
    `static java.lang.String` | `firstNonEmpty(java.lang.String... names)` Returns the first string in the list of parameters that is not null or empty ("") Returns empty ("") if all strings are either null or empty.
    `static java.lang.String` | `fmt(java.lang.String format, java.lang.Object... args)`
    `static java.lang.String` | `fromChar(char fillWith, int length)` Creates a string of the specified length, composed by repeating the specified character.
    `static boolean` | `isEmpty(java.lang.String str)` Returns true if the string is null or empty ("").
    `static boolean` | `isWhiteSpace(java.lang.String str)` Returns true if the string is null, empty or is composed entirely of whitespace (as determined by Character.is (e.g.
    `static <T> java.lang.String` | `join(java.lang.String delim, java.lang.Iterable<T> values)`
    `static <T> java.lang.String` | `join(java.lang.String delimiter, java.lang.Iterable<T> values, java.util.function.Function<? super T,java.lang.String> formatter)`
    `static <T> java.lang.String` | `join(java.lang.String delim, T[] values)`
    `static java.lang.String` | `md5(java.lang.String input)` Returns a 32-character hexadecimal-formatted MD5 hash of the subject string.
    `static java.lang.String` | `pad(int targetLength, java.lang.String subject)`
    `static java.lang.String` | `pad(int targetLength, java.lang.String subject, char padWith, int truncate)` Pad a string with the specified character.
    `static java.lang.String` | `pad0s(int targetLength, java.lang.String subject)`
    `static java.lang.String` | `padl(int targetLength, java.lang.String subject)` Pad-Left.
    `static java.lang.String` | `padr(int targetLength, java.lang.String subject)` Pad-Right.
    `private static java.text.ParseException` | `parseError(java.lang.String message, int pos)`
    `static java.lang.String` | `readAll(java.io.InputStream input)`
    `static java.lang.String` | `readAll(java.io.InputStream input, java.nio.charset.Charset charset)`
    `static java.lang.String` | `readAll(java.io.InputStream input, java.nio.charset.Charset charset, int bufferSize)`
    `static java.lang.String` | `readAll(java.io.InputStream input, java.lang.String charset)`
    `static java.lang.String` | `readAll(java.io.InputStream input, java.lang.String charset, int bufferSize)`
    `static java.lang.String` | `replaceNonPrintable(java.lang.String s, char replaceControlChars, char replaceWhiteSpace)`
    `static java.lang.String` | `replaceNonPrintableU(java.lang.String s, char replaceControlChars, char replaceWhiteSpace)` Same as `replaceNonPrintable(java.lang.String, char, char)` but includes support for unicode characters, including Surrogate pairs.
    `static java.lang.String` | `toFriendlyName(java.lang.String name)` Converts a camel-case name into space separated words.
    `static java.lang.String` | `unescapeStringLiteral(java.lang.String subject)` UN-escapes a string by replacing backslash-escaped sequences with the character literals they represent.
    `static void` | `writeAll(java.lang.String content, java.io.OutputStream output)`
    `static void` | `writeAll(java.lang.String content, java.io.OutputStream output, java.nio.charset.Charset charset)`
    `static void` | `writeAll(java.lang.String content, java.io.OutputStream output, java.nio.charset.Charset charset, int bufferSize)`
    `static void` | `writeAll(java.lang.String content, java.io.OutputStream output, java.lang.String charset)`
    `static void` | `writeAll(java.lang.String content, java.io.OutputStream output, java.lang.String charset, int bufferSize)`

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

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

- - ### Field Detail

    - #### DefaultBufferSize

          public static final int DefaultBufferSize

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Strings

          public Strings()

  - ### Method Detail

    - #### asBool

          public static boolean asBool(java.lang.String boolString)

    - #### asBool

          public static boolean asBool(java.lang.String boolString,
                                       boolean defaultIfEmpty)

      Attempts to convert a string representing a conceptual "true/false" into a boolean.
      Returns:
        `defaultIfEmpty` if `boolString` is null, empty (""), or whitespace. Returns FALSE if `boolString` == "false", "no" or "0" (case insensitive, trimmed). True otherwise.

    - #### escapeHTML

          public static java.lang.String escapeHTML(java.lang.String s)

    - #### escapeStringLiteral

          public static java.lang.String escapeStringLiteral(java.lang.String subject)

      Used to convert raw characters to their escaped version when these raw version cannot be used as part of a Java string literal.

      Escapes NULL, BKSP, TAB, CR, LF, FF, backslash, double (") and single (') quotes to their java escape codes. Also escapes all other control characters (1 to 31) and all characters above 127 to the corresponding Java unicode escape code (, ⚽ etc. )

      Parameters:
        `subject` - The string to escape.
      Returns:
        The escaped string.
      See Also:
        `escapeStringLiteral(String,int)`

    - #### escapeStringLiteral

          public static java.lang.String escapeStringLiteral(java.lang.String subject,
                                                             int escapeOptions)

      Used to convert raw characters to their escaped version when these raw version cannot be used as part of a Java string literal.

      Escapes NULL, BKSP, TAB, CR, LF, FF, backslash, double (") and single (') quotes to their java escape codes. Also escapes all other control characters (1 to 31) and all characters above 127 to the corresponding Java unicode escape code (, ⚽ etc. )

      Parameters:
        `subject` - The string to escape.
        `escapeOptions` - A bitfield of `CharType` values indicating which types of characters to escape.

        However note `CharType.CONTROL` characters are ALWAYS escaped, while `CharType.ALPHA`, `CharType.DIGITS`, and most `CharType.SYMBOLS` are NEVER escaped. The only character types for which escaping can be enabled or disabled are the following: `CharType.TAB`, `CharType.NEWLINE`, `CharType.DOUBLE_QUOTES`, `CharType.SINGLE_QUOTE`, `CharType.BACKSLASH`, and `CharType.EXT_ASCII`.

      Returns:
        The escaped string.
      See Also:
        `escapeStringLiteral(String, int)`

    - #### firstNonEmpty

          @NotNull
          public static java.lang.String firstNonEmpty(java.lang.String... names)

      Returns the first string in the list of parameters that is not null or empty ("") Returns empty ("") if all strings are either null or empty.

    - #### fmt

          public static java.lang.String fmt(java.lang.String format,
                                             java.lang.Object... args)

    - #### fromChar

          public static java.lang.String fromChar(char fillWith,
                                                  int length)

      Creates a string of the specified length, composed by repeating the specified character.
      Parameters:
        `fillWith` - The character used to fill the string.
        `length` - The desired length of the string.
      Returns:
        a string of the specified length, composed by repeating the specified character.

    - #### isEmpty

          public static boolean isEmpty(java.lang.String str)

      Returns true if the string is null or empty ("").
      Parameters:
        `str` -
      Returns:

    - #### isWhiteSpace

          public static boolean isWhiteSpace(@Nullable
                                             java.lang.String str)

      Returns true if the string is null, empty or is composed entirely of whitespace (as determined by Character.is (e.g. space, tab, newlines, etc).
      Parameters:
        `str` -
      Returns:

    - #### join

          public static <T> java.lang.String join(java.lang.String delim,
                                                  java.lang.Iterable<T> values)

    - #### join

          public static <T> java.lang.String join(java.lang.String delimiter,
                                                  java.lang.Iterable<T> values,
                                                  @Nullable
                                                  java.util.function.Function<? super T,java.lang.String> formatter)

    - #### join

          public static <T> java.lang.String join(java.lang.String delim,
                                                  T[] values)

    - #### md5

          public static java.lang.String md5(java.lang.String input)

      Returns a 32-character hexadecimal-formatted MD5 hash of the subject string.

    - #### pad

          public static java.lang.String pad(int targetLength,
                                             java.lang.String subject)

    - #### pad

          public static java.lang.String pad(int targetLength,
                                             java.lang.String subject,
                                             char padWith,
                                             int truncate)

      Pad a string with the specified character. The padding can be placed on the right or left side of the string, depending on the sign of the width parameter: A negative width places the padding on the left, while a positive width pads to the right side.
      Parameters:
        `targetLength` - Determines both the side to pad on and the target number of characters to return. A negative value causes padding to be placed on the left side, while a positive one pads on the right. Padding is added until the string length is at least abs(width) long. (Where abs is the absolute value function).
        `subject` - The string to pad.
        `padWith` - The character to pad with.
        `truncate` - An int that specifies whether the string should be truncated if its current length is larger than the desired width. 0 indicates that no truncating should occur. If the string is longer than width, it is returned unmodified. 1 indicates that the string should be truncated by removing excess characters from the RIGHT side of the string. -1 indicates that the string should be truncated by removing excess characters from the LEFT side of the string.
      Returns:
        If truncate is 1 or -1, the length of the returned string will be exactly targetLength. If truncate = 0, the string will have a minimum length of targetLength.

    - #### pad0s

          public static java.lang.String pad0s(int targetLength,
                                               java.lang.String subject)

    - #### padl

          public static java.lang.String padl(int targetLength,
                                              java.lang.String subject)

      Pad-Left. Synonym for pad(-targetLength), but negative lengths are not allowed.

    - #### padr

          public static java.lang.String padr(int targetLength,
                                              java.lang.String subject)

      Pad-Right. Synonym for pad, but negative lengths are not allowed.

    - #### parseError

          private static java.text.ParseException parseError(java.lang.String message,
                                                             int pos)

    - #### readAll

          public static java.lang.String readAll(java.io.InputStream input)
                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readAll

          public static java.lang.String readAll(java.io.InputStream input,
                                                 java.nio.charset.Charset charset)
                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readAll

          public static java.lang.String readAll(java.io.InputStream input,
                                                 java.nio.charset.Charset charset,
                                                 int bufferSize)
                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readAll

          public static java.lang.String readAll(java.io.InputStream input,
                                                 java.lang.String charset)
                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readAll

          public static java.lang.String readAll(java.io.InputStream input,
                                                 java.lang.String charset,
                                                 int bufferSize)
                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### replaceNonPrintable

          public static java.lang.String replaceNonPrintable(java.lang.String s,
                                                             char replaceControlChars,
                                                             char replaceWhiteSpace)

    - #### replaceNonPrintableU

          public static java.lang.String replaceNonPrintableU(java.lang.String s,
                                                              char replaceControlChars,
                                                              char replaceWhiteSpace)

      Same as `replaceNonPrintable(java.lang.String, char, char)` but includes support for unicode characters, including Surrogate pairs.

    - #### toFriendlyName

          public static java.lang.String toFriendlyName(java.lang.String name)

      Converts a camel-case name into space separated words. firstName yields "First Name" getID yields "Get ID" SSNNumber yields "SSN Number" iAmNice yields "I Am Nice" _myName yields "My Name" name1 yields "Name 1" first_name yields First Name

    - #### unescapeStringLiteral

          @NotNull
          public static java.lang.String unescapeStringLiteral(@NotNull
                                                                         java.lang.String subject)
                                                                  throws java.text.ParseException

      UN-escapes a string by replacing backslash-escaped sequences with the character literals they represent. Handles the following cases: `\\ \" \'` are replaced by backslash (\), double-quote ("), and apostrophe (') respectively. `\r \n \t \f \b \a` are replaced by CR, LF, TAB, FormFeed, and BackSpace respectively. `\e \a` are replaced by ESC and ALERT respectively `\cX` is replaced by the control character represented by X (e.g. \cM is the carriage return (CR, 0x0D, #13) `\O \OO \OOO` are replaced by their octal character values (where 'O' can be any digit 0-7) `\xHH` is replaced by its hexadecimal character value (where 'H' is a hex digit: 0-9, A-F, or a-f) `\\uHHHH` is replaced by its unicode character value ('H' as above). `\UHHHHHHHH` is replaced by its unicode character value ('H' as above). Unknown backslash escape sequences are passed through as-is. They do not result in errors. E.g. "c:\Windows" yields "c:\Windows" whereas "c:\Users" yields ERROR (invalid \U escape) Similarly, a trailing backslash is not considered an error and is simply passed through. "hi\" yields "hi\"
      Parameters:
        `subject` -
      Returns:
        The un-escaped string
      Throws:
        `java.text.ParseException` - if any of the `\c \O \x \\u or \U` escapes is NOT followed by a valid sequence of valid characters of the appropriate length.

    - #### writeAll

          public static void writeAll(java.lang.String content,
                                      java.io.OutputStream output)
                               throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeAll

          public static void writeAll(java.lang.String content,
                                      java.io.OutputStream output,
                                      java.nio.charset.Charset charset)
                               throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeAll

          public static void writeAll(java.lang.String content,
                                      java.io.OutputStream output,
                                      java.nio.charset.Charset charset,
                                      int bufferSize)
                               throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeAll

          public static void writeAll(java.lang.String content,
                                      java.io.OutputStream output,
                                      java.lang.String charset)
                               throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeAll

          public static void writeAll(java.lang.String content,
                                      java.io.OutputStream output,
                                      java.lang.String charset,
                                      int bufferSize)
                               throws java.io.IOException

      Throws:
        `java.io.IOException`