Top Description Fields Constructors Methods
org.apache.groovy.parser.antlr4.util

public Class StringUtils

extends Object
Class Inheritance
Imports
groovy.lang.Closure, org.apache.groovy.util.Maps, org.codehaus.groovy.runtime.StringGroovyMethods, java.util.Map, java.util.regex.Pattern

Utilities for handling strings

Field Summary

Modifier and TypeField and Description
private static final String
public static final int
private static final Pattern
private static final int
INDEX_NOT_FOUND

Copied from Apache commons-lang3-3.6 Represents a failed index search.

private static final Pattern
public static final int
private static final Pattern
public static final int
private static final Map<Character, Character>
private static final Pattern

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static long
countChar(String text, char c)

public static boolean

Returns:

true if the CharSequence is empty or null
isEmpty
(final CharSequence
the CharSequence to check, may be null
cs
)

Copied from Apache commons-lang3-3.6

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

private static boolean
public static boolean
matches(String text, Pattern pattern)

public static String
public static String

Returns:

the text with any replacements processed, null if null String input
replace
(final String
text to search and replace in, may be null
text
,
String
the String to search for, may be null
searchString
,
final String
the String to replace it with, may be null
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.

public static String
replaceEscapes(String text, int slashyType)

private static String
public static String
private static String
public static String
public static String
public static String
trimQuotations(String text, int quotationLength)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BACKSLASHback to summary
private static final String BACKSLASH
DOLLAR_SLASHYback to summary
public static final int DOLLAR_SLASHY
HEX_ESCAPES_PATTERNback to summary
private static final Pattern HEX_ESCAPES_PATTERN
INDEX_NOT_FOUNDback to summary
private static final int INDEX_NOT_FOUND

Copied from Apache commons-lang3-3.6 Represents a failed index search.

LINE_ESCAPE_PATTERNback to summary
private static final Pattern LINE_ESCAPE_PATTERN
NONE_SLASHYback to summary
public static final int NONE_SLASHY
OCTAL_ESCAPES_PATTERNback to summary
private static final Pattern OCTAL_ESCAPES_PATTERN
SLASHYback to summary
public static final int SLASHY
STANDARD_ESCAPESback to summary
private static final Map<Character, Character> STANDARD_ESCAPES
STANDARD_ESCAPES_PATTERNback to summary
private static final Pattern STANDARD_ESCAPES_PATTERN

Constructor Detail

StringUtilsback to summary
public StringUtils()

Method Detail

countCharback to summary
public static long countChar(String text, char c)
isEmptyback to summary
public static boolean isEmpty(final 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:CharSequence

the CharSequence to check, may be null

Returns:boolean

true if the CharSequence is empty or null

isLengthOddback to summary
private static boolean isLengthOdd(String str)
matchesback to summary
public static boolean matches(String text, Pattern pattern)
removeCRback to summary
public static String removeCR(String text)
replaceback to summary
public static String replace(final String text, String searchString, final 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:String

text to search and replace in, may be null

searchString:String

the String to search for, may be null

replacement:String

the String to replace it with, may be null

Returns:String

the text with any replacements processed, null if null String input

replaceEscapesback to summary
public static String replaceEscapes(String text, int slashyType)
replaceEscapesback to summary
private static String replaceEscapes(String text)
replaceHexEscapesback to summary
public static String replaceHexEscapes(String text)
replaceLineEscapeback to summary
private static String replaceLineEscape(String text)
replaceOctalEscapesback to summary
public static String replaceOctalEscapes(String text)
replaceStandardEscapesback to summary
public static String replaceStandardEscapes(String text)
trimQuotationsback to summary
public static String trimQuotations(String text, int quotationLength)