On this page
[Java] Class StringUtils
- org.apache.groovy.parser.antlr4.util.StringUtils
public class StringUtils
extends Object
Utilities for handling strings
Field Summary
Modifiers | Name | Description |
---|---|---|
static int |
DOLLAR_SLASHY |
|
static int |
NONE_SLASHY |
|
static int |
SLASHY |
Methods Summary
Type Params | Return Type | Name and description |
---|---|---|
public static long |
countChar(String text, char c) |
|
public static boolean |
isEmpty(CharSequence cs) Copied from Apache commons-lang3-3.6 |
|
public static boolean |
matches(String text, Pattern pattern) |
|
public static String |
removeCR(String text) |
|
public static String |
replace(String text, String searchString, String replacement) The modified implementation is based on StringUtils#replace(String text, String searchString, String replacement, int max), Apache commons-lang3-3.6 |
|
public static String |
replaceEscapes(String text, int slashyType) |
|
public static String |
replaceHexEscapes(String text) |
|
public static String |
replaceOctalEscapes(String text) |
|
public static String |
replaceStandardEscapes(String text) |
|
public static String |
trimQuotations(String text, int quotationLength) |
Inherited Methods Summary
Field Detail
public static final int DOLLAR_SLASHY
public static final int NONE_SLASHY
public static final int SLASHY
Method Detail
public static long countChar(String text, char c)
public static boolean isEmpty(CharSequence cs)
Copied from Apache commons-lang3-3.6
Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true
StringUtils.isEmpty("") = true
StringUtils.isEmpty(" ") = false
StringUtils.isEmpty("bob") = false
StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0. It no longer trims the CharSequence. That functionality is available in isBlank().
- Parameters:
cs
- the CharSequence to check, may be null
- Returns:
true
if the CharSequence is empty or null
public static boolean matches(String text, Pattern pattern)
public static String removeCR(String text)
public static String replace(String text, String searchString, String replacement)
The modified implementation is based on StringUtils#replace(String text, String searchString, String replacement, int max), Apache commons-lang3-3.6
Replaces all occurrences of a String within another String.
A null
reference passed to this method is a no-op.
StringUtils.replace(null, *, *) = null
StringUtils.replace("", *, *) = ""
StringUtils.replace("any", null, *) = "any"
StringUtils.replace("any", *, null) = "any"
StringUtils.replace("any", "", *) = "any"
StringUtils.replace("aba", "a", null) = "aba"
StringUtils.replace("aba", "a", "") = "b"
StringUtils.replace("aba", "a", "z") = "zbz"
- Parameters:
text
- text to search and replace in, may be nullsearchString
- the String to search for, may be nullreplacement
- the String to replace it with, may be null
- Returns:
-
the text with any replacements processed,
null
if null String input
public static String replaceEscapes(String text, int slashyType)
public static String replaceHexEscapes(String text)
public static String replaceOctalEscapes(String text)
public static String replaceStandardEscapes(String text)
public static String trimQuotations(String text, int quotationLength)
© 2003-2022 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/4.0.0/html/gapi/org/apache/groovy/parser/antlr4/util/StringUtils.html