 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.utils;
22 import java.util.Arrays;
23 import java.util.regex.Pattern;
24 import org.jetbrains.annotations.NotNull;
25 import org.jetbrains.annotations.Nullable;
147 return str.length() <= 0 ?
"" : str.endsWith(
"\n") ? str : str +
"\n";
162 public static CharSequence
diffTextString(@NotNull
final CharSequence base, @NotNull
final String str,
final boolean ignoreValues) {
164 if (ignoreValues ? line.startsWith(str) : line.equals(str)) {
181 public static String
getAttribute(@NotNull
final CharSequence attributes, @NotNull
final String attributeName) {
182 final String str = attributeName +
" ";
184 if (line.startsWith(str)) {
185 return line.substring(str.length());
197 public static String
sortLines(@NotNull
final CharSequence
string) {
200 final StringBuilder sb =
new StringBuilder();
201 for (
final String line : lines) {
202 sb.append(line).append(
'\n');
204 return sb.toString();
StringUtils()
Private constructor to prevent instantiation.
static final Pattern PATTERN_SLASH
The pattern that matches a single slash ("/").
static final Pattern PATTERN_COLON
The pattern that matches a single colon (":").
static final Pattern PATTERN_TRAILING_WHITESPACE
Pattern to match trailing whitespace.
static final Pattern PATTERN_WHITESPACE
Pattern to match whitespace excluding NL and CR.
static String removeTrailingWhitespace(@NotNull final CharSequence str)
Removes trailing whitespace from a string.
static final Pattern PATTERN_END_OF_LINE
The pattern to match end of line characters separating lines.
static CharSequence diffTextString(@NotNull final CharSequence base, @NotNull final String str, final boolean ignoreValues)
Helper function for 'diffArchText()': Looks for occurrence of the attribute 'str' in 'base' and if fo...
static final Pattern PATTERN_MULTI_LINE_TRAILING_WHITESPACE
Pattern to match trailing whitespace in a multi line string.
static final Pattern PATTERN_SPACE
The pattern that matches a single space.
static final Pattern PATTERN_WHITESPACE_NEWLINE
Pattern to match whitespace including NL and CR.
Utility class for string manipulation.
static String getAttribute(@NotNull final CharSequence attributes, @NotNull final String attributeName)
Returns an attribute line from a set of attribute definitions.
static String sortLines(@NotNull final CharSequence string)
Sorts newline separated lines in a string.
static final Pattern PATTERN_COMMA
The pattern that matches a single comma (",").
static final Pattern PATTERN_NEWLINE
The pattern that matches a single newline ("\n").
static CharSequence ensureTrailingNewline(@NotNull final String str)
Returns a given string which ends with a trailing newline character; empty strings remain empty.
static final Pattern PATTERN_SPACES
The pattern that matches a non-empty sequence of spaces.
static final Pattern PATTERN_BACKSLASH
The pattern that matches a single backslash ("\").
static String removeTrailingWhitespaceFromLines(@NotNull final CharSequence str)
Removes trailing whitespace from all lines of a string.
static final Pattern PATTERN_EQUAL
The pattern that matches a single equal sign ("=").