Class Parsing

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

public class Parsing extends Object
Parsing utilities used by CommandParser. This code 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

      public static ArrayList<SamePair<Integer>> quotationPairs(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

      public static Parsing.BracePairs bracePairs(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

      public static String toCamelCase(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

      public static String removeHTML(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

      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.