public final class StringUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
asString(ArrayList<String> lines)
Return lines joined with line separators as a String.
|
static ArrayList<String> |
escapeXml(ArrayList<String> strings)
Escape an array of quote strings, for safe inclusion in an XML document.
|
static String |
escapeXml(String string)
Escape a quote string to be safely included in an XML document.
|
static ArrayList<String> |
extractQuote(ArrayList<String> text,
String marker)
Extract a single quote from an array of strings.
|
static ArrayList<String> |
extractQuote(ArrayList<String> text,
String start,
String end)
Extract a single quote from an array of strings.
|
static ArrayList<String> |
indent(ArrayList<String> text,
String indent)
Indent an array of strings.
|
static ArrayList<String> |
outdent(ArrayList<String> indented)
Outdent an array of strings,
removing an equal number of leftmost spaces from each string
until at least one string starts with a non-space character.
|
static String |
removeEmptySpace(String string)
Return an empty string if the string is only whitespace.
|
public static String asString(ArrayList<String> lines)
lines
- Lines to join with line separators.public static ArrayList<String> escapeXml(ArrayList<String> strings)
This method deals only with &, <, >, ", '
.
strings
- The array of strings to escape.public static String escapeXml(String string)
This method deals only with &, <, >, ", '
.
string
- The string to escape.public static ArrayList<String> extractQuote(ArrayList<String> text, String start, String end)
The quote is surrounded by a string marking the start of the quote, and a string marking the end of the quote.
If the start marker is null or empty, then this method assumes the entire input text is the quote.
If the start marker exists but the end marker is null or empty, then this method assumes everything after the start marker is the quote.
This method does not allow a null or empty end marker. To quote from the start marker to the end of the text, use an end marker that does not show up in the text.
Unless the start marker and end marker are found on the same line, this method assumes the start marker and end marker lines are separate from the quote. In other words, for this case the method ignores substrings following the start marker on the same line and substrings preceding the end marker on the same line, unless both markers are on the same line.
text
- Strings possibly containing a quote.start
- String marking start of quote.end
- String marking end of quote.IllegalArgumentException
- End marker was null or empty.public static ArrayList<String> extractQuote(ArrayList<String> text, String marker)
The quote is surrounded by a single string that marks both the start of the quote and the end of the quote.
If the marker is null or empty, then the entire input text is the quote.
If the start marker exists but end marker is null or empty, then this method assumes everything after the start marker is the quote.
Unless the markers are found on the same line, this method assumes the markers lines are separate from the quote. In other words, for this case the method ignores substrings following the initial marker on the same line and substrings preceding the final marker on the same line, unless both markers are on the same line.
text
- The array of strings supposed to contain a quote.marker
- The string marking the start and end of the quote.public static ArrayList<String> indent(ArrayList<String> text, String indent)
text
- Array of strings to indent.indent
- The indentation string, usually a series of spaces.public static ArrayList<String> outdent(ArrayList<String> indented)
Tab width (or height) depends and is subject to debate, so throw an exception if the initial whitespace includes a tab.
indented
- Array of strings with leftmost spaces.IllegalArgumentException
- Initial whitespace included a tab.Copyright © 2025 Open Identity Platform Community. All rights reserved.