Package com.predic8.membrane.core.util
Class TextUtil
java.lang.Object
com.predic8.membrane.core.util.TextUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Objectcapitalize(String english) static Stringstatic Stringstatic StringAs HTML is needed for the AdminConsolestatic intgetCurrentIndent(String line) Calculates the current indentation level (number of leading spaces) of a given line.static StringgetLineFromMultilineString(String s, int lineNumber) Counts from 1 cause this is needed for getting lines from Javascript source code.static intgetMinIndent(String[] lines) Determines the minimum indentation level (number of leading spaces) across all non-empty lines in an array of lines.static StringglobToRegExp(String glob) static booleanisNullOrEmpty(String str) static booleanChecks whether s is a valid (well-formed and balanced) XML snippet.static Stringstatic Objectstatic StringtoEnglishList(String conjuction, String... args) static StringBuilderTrims excess indentation from each line in the input array, based on a specified minimum indent level.static StringunifyIndent(String multilineString) Adjusts the indentation of each line in a multiline string to match the minimum indentation found.
-
Constructor Details
-
TextUtil
public TextUtil()
-
-
Method Details
-
formatXML
- Parameters:
reader-- Returns:
- Throws:
Exception
-
formatXML
As HTML is needed for the AdminConsole- Parameters:
reader- XMLasHTML- Should output formatted as XML- Returns:
- Formatted string
- Throws:
Exception
-
isNullOrEmpty
-
globToRegExp
-
toEnglishList
-
capitalize
-
isValidXMLSnippet
Checks whether s is a valid (well-formed and balanced) XML snippet. Note that attributes escaped by single quotes are accepted (which is illegal by spec). -
linkURL
-
removeFinalChar
-
getLineFromMultilineString
Counts from 1 cause this is needed for getting lines from Javascript source code.- Parameters:
s- Multiline stringlineNumber- number of line to return. Counts from 1- Returns:
- line
-
escapeQuotes
-
unifyIndent
Adjusts the indentation of each line in a multiline string to match the minimum indentation found.- Parameters:
multilineString- The input multiline string to process.- Returns:
- A string with adjusted indentation.
-
trimLines
Trims excess indentation from each line in the input array, based on a specified minimum indent level.- Parameters:
lines- The array of lines to process.minIndent- The minimum indent level to maintain.- Returns:
- A StringBuilder containing lines with adjusted indentation.
-
getCurrentIndent
Calculates the current indentation level (number of leading spaces) of a given line.- Parameters:
line- The line to calculate the indentation for.- Returns:
- The number of leading spaces in the line.
-
getMinIndent
Determines the minimum indentation level (number of leading spaces) across all non-empty lines in an array of lines.- Parameters:
lines- The array of lines to analyze.- Returns:
- The minimum indent level found among the lines.
-