Class Utility

java.lang.Object
edu.iu.jrsalata.Utility

public class Utility extends Object
Utility class provides static methods for string manipulation and processing. This class is not meant to be instantiated.
  • Constructor Details

    • Utility

      public Utility()
  • Method Details

    • lengthCheck

      public static String lengthCheck(String symbol)
      Ensures the given symbol string is exactly SymTable.MAX_LEN characters long. If the symbol is longer, it is truncated. If it is shorter, it is padded with spaces. The resulting string is converted to uppercase.
      Parameters:
      symbol - the input string to be checked and adjusted
      Returns:
      the adjusted string of length SymTable.MAX_LEN in uppercase
    • cleanLine

      public static String cleanLine(String line)
      Cleans the given line by stripping unnecessary whitespace and removing comments. If the line is empty or is just a comment, an empty string is returned.
      Parameters:
      line - the input string to be cleaned
      Returns:
      the cleaned string without comments and unnecessary whitespace
    • splitLine

      public static String[] splitLine(String line)
      Splits the given line into parts based on spaces after cleaning it. If the line is empty or is just a comment, an array with two empty strings is returned.
      Parameters:
      line - the input string to be split
      Returns:
      an array of strings split by spaces or tabs