Package dev.roanh.gmark.lang.generic
Class GenericParser
java.lang.Object
dev.roanh.gmark.lang.generic.GenericParser
Class with generic query language parsing utilities.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
GenericParser
protected GenericParser()Hide constructor.
-
-
Method Details
-
split
Splits the given string into parts on the given character. The given character will not be returned in any parts and the found parts will be trimmed of leading and trailing whitespace. This method will ignore any regions of the input string that are enclosed in (nested) round brackets.- Parameters:
str
- The string to split.symbol
- The character to split on.- Returns:
- The input string split on the given character.
- Throws:
IllegalArgumentException
- When brackets are present in the given string, but not balanced properly.
-
parsePredicate
protected static Predicate parsePredicate(String query, Map<String, Predicate> labels, char inverse) throws IllegalArgumentExceptionAttempts to parse an (inverse) predicate/label from the given query string.- Parameters:
query
- The query string to parse.labels
- The set of predicates encountered so far. Used to reuse existing labels and to register newly detected predicates.inverse
- The symbol used to denote inverse labels.- Returns:
- The predicate that was parsed.
- Throws:
IllegalArgumentException
- When the given query string does not represent a valid predicate.
-