Class Parsing

java.lang.Object
com.j3d.utility.Parsing

public class Parsing extends Object
Parsing utilities used by CommandParser. This code (brace and quote checking specifically)_is borrowed from the
invalid @linkplain
{@linkplain <a href="https://github.com/yetnt/jaiva">Jaiva
Programming Language}, my custom personal project.

This was abstracted from Jaiva as to not import the entire language runtime and parser for it's utilities and to remove parsing quirks that the Jaiva methods would've introduced.

Author:
Lehlogonolo Poole
See Also:
  • Constructor Details

    • Parsing

      public Parsing()
  • Method Details

    • quotationPairs

      @NotNull public static ArrayList<SamePair<Integer>> quotationPairs(@NotNull String line)
      Finds pairs of double quotation marks within a given line of text, ignoring escaped quotation marks.
      Parameters:
      line - The string to search for quotation mark pairs.
      Returns:
      An ArrayList of SamePair where each pair represents the start and end index of a quotation block.
    • bracePairs

      @NotNull @Contract("_ -> new") public static Parsing.BracePairs bracePairs(@NotNull String line)
      Finds matching brace pairs (parentheses and square brackets) within a given line of text. It also returns any unclosed braces.
      Parameters:
      line - The string to search for brace pairs.
      Returns:
      A Parsing.BracePairs instance containing a Pair with an ArrayList of SamePair for closed brace pairs (start and end index), and an ArrayList of Pair for unclosed braces (index and character).
    • toCamelCase

      @NotNull public static String toCamelCase(@NotNull String input)
      Converts a given string to camelCase. It handles spaces and underscores as delimiters, converting the character following them to uppercase.
      Parameters:
      input - The string to convert to camelCase.
      Returns:
      The camelCase version of the input string.
    • removeHTML

      @NotNull public static String removeHTML(@NotNull String input)
      Removes HTML tags from the input string. This method iterates through the string and appends characters to the result only if they are not enclosed within '<' and '>' characters.
      Parameters:
      input - The string from which to remove HTML tags.
      Returns:
      A new string with all HTML tags removed.
    • split

      @NotNull public static ArrayList<String> split(String input, char c)
      Splits a string by a given character, ignoring delimiters within quotation marks or brace pairs. This method handles nested braces and quotes.
      Parameters:
      input - The string to be split.
      c - The character to split the string by.
      Returns:
      An ArrayList of strings, where each string is a segment of the input string.