Package org.eclipse.rdf4j.query.parser
Class QueryPrologLexer
- java.lang.Object
-
- org.eclipse.rdf4j.query.parser.QueryPrologLexer
-
public class QueryPrologLexer extends java.lang.ObjectA 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 Classes Modifier and Type Class Description static classQueryPrologLexer.Tokenstatic classQueryPrologLexer.TokenType
-
Field Summary
Fields Modifier and Type Field Description private static QueryPrologLexer.TokenBASE_KEYWORD_TOKENprivate static java.util.regex.PatternCOMMENT_PATTERNprivate static QueryPrologLexer.TokenHASH_TOKENprivate static java.util.regex.PatternIRI_PATTERNprivate static QueryPrologLexer.TokenLBRACKET_TOKENprivate static QueryPrologLexer.TokenPREFIX_KEYWORD_TOKENprivate static java.util.regex.PatternPREFIX_PATTERNprivate static QueryPrologLexer.TokenRBRACKET_TOKEN
-
Constructor Summary
Constructors Constructor Description QueryPrologLexer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static QueryPrologLexer.TokengetRestOfQueryToken(java.lang.String input)Tokenizes the input string on prolog elements and returns the final Token.static java.util.List<QueryPrologLexer.Token>lex(java.lang.String input)Tokenizes a syntactically legal input SPARQL query on prolog elements.private static java.lang.StringreadComment(java.lang.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 java.lang.StringreadIRI(java.lang.String input, int index)private static java.lang.StringreadPrefix(java.lang.String input, int index)
-
-
-
Field Detail
-
HASH_TOKEN
private static final QueryPrologLexer.Token HASH_TOKEN
-
PREFIX_KEYWORD_TOKEN
private static final QueryPrologLexer.Token PREFIX_KEYWORD_TOKEN
-
BASE_KEYWORD_TOKEN
private static final QueryPrologLexer.Token BASE_KEYWORD_TOKEN
-
LBRACKET_TOKEN
private static final QueryPrologLexer.Token LBRACKET_TOKEN
-
RBRACKET_TOKEN
private static final QueryPrologLexer.Token RBRACKET_TOKEN
-
IRI_PATTERN
private static final java.util.regex.Pattern IRI_PATTERN
-
PREFIX_PATTERN
private static final java.util.regex.Pattern PREFIX_PATTERN
-
COMMENT_PATTERN
private static final java.util.regex.Pattern COMMENT_PATTERN
-
-
Method Detail
-
lex
public static java.util.List<QueryPrologLexer.Token> lex(java.lang.String input)
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
public static QueryPrologLexer.Token getRestOfQueryToken(java.lang.String input)
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
private static java.lang.String readComment(java.lang.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 "#".- Parameters:
input-index-- Returns:
-
readPrefix
private static java.lang.String readPrefix(java.lang.String input, int index)
-
readIRI
private static java.lang.String readIRI(java.lang.String input, int index)
-
-