Class TextUtil

java.lang.Object
com.predic8.membrane.core.util.TextUtil

public class TextUtil extends Object
  • Constructor Details

    • TextUtil

      public TextUtil()
  • Method Details

    • formatXML

      public static String formatXML(Reader reader) throws Exception
      Parameters:
      reader -
      Returns:
      Throws:
      Exception
    • formatXML

      public static String formatXML(Reader reader, boolean asHTML) throws Exception
      As HTML is needed for the AdminConsole
      Parameters:
      reader - XML
      asHTML - Should output formatted as XML
      Returns:
      Formatted string
      Throws:
      Exception
    • isNullOrEmpty

      public static boolean isNullOrEmpty(String str)
    • globToRegExp

      public static String globToRegExp(String glob)
    • toEnglishList

      public static String toEnglishList(String conjuction, String... args)
    • capitalize

      public static Object capitalize(String english)
    • isValidXMLSnippet

      public static boolean isValidXMLSnippet(String s)
      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

      public static String linkURL(String url)
    • removeFinalChar

      public static Object removeFinalChar(String s)
    • getLineFromMultilineString

      public static String getLineFromMultilineString(String s, int lineNumber)
      Counts from 1 cause this is needed for getting lines from Javascript source code.
      Parameters:
      s - Multiline string
      lineNumber - number of line to return. Counts from 1
      Returns:
      line
    • escapeQuotes

      public static String escapeQuotes(String s)
    • unifyIndent

      public static String unifyIndent(String multilineString)
      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

      public static StringBuilder trimLines(String[] lines, int minIndent)
      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

      public static int getCurrentIndent(String line)
      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

      public static int getMinIndent(String[] lines)
      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.