Package edu.iu.jrsalata
Class Utility
java.lang.Object
edu.iu.jrsalata.Utility
Utility class provides static methods for string manipulation and processing.
This class is not meant to be instantiated.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Cleans the given line by stripping unnecessary whitespace and removing comments.static String
lengthCheck
(String symbol) Ensures the given symbol string is exactly SymTable.MAX_LEN characters long.static String[]
Splits the given line into parts based on spaces after cleaning it.
-
Constructor Details
-
Utility
public Utility()
-
-
Method Details
-
lengthCheck
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
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
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
-