Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.logging.log4j.util
Class Strings

    java.lang.Object
      org.apache.logging.log4j.util.Strings

    public final class Strings

extends Object

Consider this class private.

See Also:
  Apache Commons Lang

Field Summary
`static String` | `EMPTY` The empty string.

Method Summary
`static String` | `dquote(String str)` Returns a double quoted string.
`static boolean` | `isBlank(String s)` Checks if a String is blank.
`static boolean` | `isEmpty(CharSequence cs)` Checks if a CharSequence is empty ("") or null.
`static boolean` | `isNotBlank(String s)` Checks if a String is not blank.
`static boolean` | `isNotEmpty(CharSequence cs)` Checks if a CharSequence is not empty ("") and not null.
`static String` | `quote(String str)` Returns a quoted string.
`static String` | `trimToNull(String str)` Removes control characters (char <= 32) from both ends of this String returning `null` if the String is empty ("") after the trim or if it is `null`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### EMPTY

    public static final String EMPTY

  The empty string.

  See Also:
    Constant Field Values

Method Detail

### isEmpty

    public static boolean isEmpty(CharSequence cs)

  Checks if a CharSequence is empty ("") or null.

       Strings.isEmpty(null)      = true
       Strings.isEmpty("")        = true
       Strings.isEmpty(" ")       = false
       Strings.isEmpty("bob")     = false
       Strings.isEmpty("  bob  ") = false

  NOTE: This method changed in Lang version 2.0. It no longer trims the CharSequence. That functionality is available in isBlank().

  Copied from Apache Commons Lang org.apache.commons.lang3.StringUtils.isEmpty(CharSequence)

  Parameters:
    `cs` - the CharSequence to check, may be null
  Returns:
    `true` if the CharSequence is empty or null

### isNotEmpty

    public static boolean isNotEmpty(CharSequence cs)

  Checks if a CharSequence is not empty ("") and not null.

       Strings.isNotEmpty(null)      = false
       Strings.isNotEmpty("")        = false
       Strings.isNotEmpty(" ")       = true
       Strings.isNotEmpty("bob")     = true
       Strings.isNotEmpty("  bob  ") = true

  Copied from Apache Commons Lang org.apache.commons.lang3.StringUtils.isNotEmpty(CharSequence)

  Parameters:
    `cs` - the CharSequence to check, may be null
  Returns:
    `true` if the CharSequence is not empty and not null

### isBlank

    public static boolean isBlank(String s)

  Checks if a String is blank. A blank string is one that is `null`, empty, or when trimmed using `String.trim()` is empty.

  Parameters:
    `s` - the String to check, may be `null`
  Returns:
    `true` if the String is `null`, empty, or trims to empty.

### isNotBlank

    public static boolean isNotBlank(String s)

  Checks if a String is not blank. The opposite of `isBlank(String)`.

  Parameters:
    `s` - the String to check, may be `null`
  Returns:
    `true` if the String is non-`null` and has content after being trimmed.

### trimToNull

    public static String trimToNull(String str)

  Removes control characters (char <= 32) from both ends of this String returning `null` if the String is empty ("") after the trim or if it is `null`.

  The String is trimmed using `String.trim()`. Trim removes start and end characters <= 32.

       Strings.trimToNull(null)          = null
       Strings.trimToNull("")            = null
       Strings.trimToNull("     ")       = null
       Strings.trimToNull("abc")         = "abc"
       Strings.trimToNull("    abc    ") = "abc"

  Copied from Apache Commons Lang org.apache.commons.lang3.StringUtils.trimToNull(String)

  Parameters:
    `str` - the String to be trimmed, may be null
  Returns:
    the trimmed String, `null` if only chars <= 32, empty or null String input

### quote

    public static String quote(String str)

  Returns a quoted string.

  Parameters:
    `str` - a String
  Returns:
    `'str'`

### dquote

    public static String dquote(String str)

  Returns a double quoted string.

  Parameters:
    `str` - a String
  Returns:
    `"str"`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.