Class QueryPrologLexer
java.lang.Object
org.eclipse.rdf4j.query.parser.QueryPrologLexer
A simple lexer that tokenizes a syntactically legal input SPARQL query string on prolog items (prefixes, base
declarations, IRIs, comments, and syntactical tokens such as keywords, opening and closing brackets, and hashes).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final QueryPrologLexer.Tokenprivate static final Patternprivate static final QueryPrologLexer.Tokenprivate static final Patternprivate static final QueryPrologLexer.Tokenprivate static final QueryPrologLexer.Tokenprivate static final Patternprivate static final QueryPrologLexer.Token -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic QueryPrologLexer.TokengetRestOfQueryToken(String input) Tokenizes the input string on prolog elements and returns the final Token.static List<QueryPrologLexer.Token> Tokenizes a syntactically legal input SPARQL query on prolog elements.private static StringreadComment(String input, int index) Reads the first comment line from the input, and returns the comment line (including the line break character) without the leading "#".private static Stringprivate static StringreadPrefix(String input, int index)
-
Field Details
-
HASH_TOKEN
-
PREFIX_KEYWORD_TOKEN
-
BASE_KEYWORD_TOKEN
-
LBRACKET_TOKEN
-
RBRACKET_TOKEN
-
IRI_PATTERN
-
PREFIX_PATTERN
-
COMMENT_PATTERN
-
-
Constructor Details
-
QueryPrologLexer
public QueryPrologLexer()
-
-
Method Details
-
lex
Tokenizes a syntactically legal input SPARQL query on prolog elements. The last token in the returned list is of typeQueryPrologLexer.TokenType.REST_OF_QUERYand contains the SPARQL query string minus the prolog.- Parameters:
input- a syntactically legal SPARQL query string- Returns:
- a list with tokens for each prolog element. If the input string is syntactically legal SPARQL, the final
returned token is guaranteed to be of type
QueryPrologLexer.TokenType.REST_OF_QUERYand to contain the SPARQL query string minus the prolog. If the input string is not syntactically legal SPARQL, the method will still return normally but no guarantees about the returned list are made.
-
getRestOfQueryToken
Tokenizes the input string on prolog elements and returns the final Token. If the input string is a syntactically legal SPARQL query, this Token will be of typeQueryPrologLexer.TokenType.REST_OF_QUERYand contain the query string minus prolog.- Parameters:
input- a syntactically legal SPARQL string- Returns:
- if the input is syntactically legal SPARQL, a Token containing the query string without prolog. If the input is not syntactically legal, the method will still exist normally, but no guarantees are made about the returned object.
-
readComment
-
readPrefix
-
readIRI
-