Search in sources :

Example 1 with ARQParser

use of org.apache.jena.sparql.lang.arq.ARQParser in project jena by apache.

the class ParserARQUpdate method _parse.

private void _parse(UpdateSink sink, Reader r) {
    ARQParser parser = null;
    try {
        parser = new ARQParser(r);
        parser.setUpdateSink(sink);
        parser.UpdateUnit();
    } catch (org.apache.jena.sparql.lang.arq.ParseException ex) {
        throw new QueryParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn);
    } catch (org.apache.jena.sparql.lang.arq.TokenMgrError tErr) {
        // Last valid token : not the same as token error message - but this should not happen
        int col = parser.token.endColumn;
        int line = parser.token.endLine;
        throw new QueryParseException(tErr.getMessage(), line, col);
    } catch (QueryException ex) {
        throw ex;
    } catch (JenaException ex) {
        throw new QueryException(ex.getMessage(), ex);
    } catch (Error err) {
        // The token stream can throw errors.
        throw new QueryParseException(err.getMessage(), err, -1, -1);
    } catch (Throwable th) {
        Log.error(this, "Unexpected throwable: ", th);
        throw new QueryException(th.getMessage(), th);
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) QueryException(org.apache.jena.query.QueryException) ARQParser(org.apache.jena.sparql.lang.arq.ARQParser) QueryParseException(org.apache.jena.query.QueryParseException)

Example 2 with ARQParser

use of org.apache.jena.sparql.lang.arq.ARQParser in project jena by apache.

the class PathParser method parse.

public static Path parse(String str, Prologue prologue) {
    Query query = new Query(prologue);
    Reader in = new StringReader(str);
    ARQParser parser = new ARQParser(in);
    try {
        query.setStrict(true);
        parser.setQuery(query);
        return parser.PathUnit();
    } catch (org.apache.jena.sparql.lang.arq.ParseException ex) {
        throw new QueryParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn);
    } catch (org.apache.jena.sparql.lang.arq.TokenMgrError tErr) {
        // Last valid token : not the same as token error message - but this should not happen
        int col = parser.token.endColumn;
        int line = parser.token.endLine;
        throw new QueryParseException(tErr.getMessage(), line, col);
    } catch (QueryException ex) {
        throw ex;
    } catch (JenaException ex) {
        throw new QueryException(ex.getMessage(), ex);
    } catch (Error err) {
        // The token stream can throw errors.
        throw new QueryParseException(err.getMessage(), err, -1, -1);
    } catch (Throwable th) {
        Log.warn(PathParser.class, "Unexpected throwable: ", th);
        throw new QueryException(th.getMessage(), th);
    }
}
Also used : Query(org.apache.jena.query.Query) StringReader(java.io.StringReader) Reader(java.io.Reader) QueryParseException(org.apache.jena.query.QueryParseException) JenaException(org.apache.jena.shared.JenaException) QueryException(org.apache.jena.query.QueryException) ARQParser(org.apache.jena.sparql.lang.arq.ARQParser) StringReader(java.io.StringReader)

Example 3 with ARQParser

use of org.apache.jena.sparql.lang.arq.ARQParser in project jena by apache.

the class ParserARQUpdate method executeParse.

@Override
protected void executeParse(UpdateSink sink, Prologue prologue, Reader r) {
    ARQParser parser = null;
    try {
        parser = new ARQParser(r);
        parser.setUpdate(prologue, sink);
        parser.UpdateUnit();
    } catch (org.apache.jena.sparql.lang.arq.ParseException ex) {
        throw new QueryParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn);
    } catch (org.apache.jena.sparql.lang.arq.TokenMgrError tErr) {
        // Last valid token : not the same as token error message - but this should not happen
        int col = parser.token.endColumn;
        int line = parser.token.endLine;
        throw new QueryParseException(tErr.getMessage(), line, col);
    } catch (QueryException ex) {
        throw ex;
    } catch (JenaException ex) {
        throw new QueryException(ex.getMessage(), ex);
    } catch (Error err) {
        // The token stream can throw errors.
        throw new QueryParseException(err.getMessage(), err, -1, -1);
    } catch (Throwable th) {
        Log.error(this, "Unexpected throwable: ", th);
        throw new QueryException(th.getMessage(), th);
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) QueryException(org.apache.jena.query.QueryException) ARQParser(org.apache.jena.sparql.lang.arq.ARQParser) QueryParseException(org.apache.jena.query.QueryParseException)

Example 4 with ARQParser

use of org.apache.jena.sparql.lang.arq.ARQParser in project jena by apache.

the class ParserARQ method parseTemplate.

public static Template parseTemplate(String string) {
    final Query query = new Query();
    Action action = new Action() {

        @Override
        public void exec(ARQParser parser) throws Exception {
            Template t = parser.ConstructTemplate();
            query.setConstructTemplate(t);
        }
    };
    perform(query, string, action);
    return query.getConstructTemplate();
}
Also used : Query(org.apache.jena.query.Query) ARQParser(org.apache.jena.sparql.lang.arq.ARQParser) Template(org.apache.jena.sparql.syntax.Template)

Example 5 with ARQParser

use of org.apache.jena.sparql.lang.arq.ARQParser in project jena by apache.

the class ParserARQ method perform.

// All throwable handling.
private static void perform(Query query, String string, Action action) {
    Reader in = new StringReader(string);
    ARQParser parser = new ARQParser(in);
    try {
        query.setStrict(true);
        parser.setQuery(query);
        action.exec(parser);
    } catch (org.apache.jena.sparql.lang.arq.ParseException ex) {
        throw new QueryParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn);
    } catch (org.apache.jena.sparql.lang.arq.TokenMgrError tErr) {
        // Last valid token : not the same as token error message - but this should not happen
        int col = parser.token.endColumn;
        int line = parser.token.endLine;
        throw new QueryParseException(tErr.getMessage(), line, col);
    } catch (QueryException ex) {
        throw ex;
    } catch (JenaException ex) {
        throw new QueryException(ex.getMessage(), ex);
    } catch (Error err) {
        // The token stream can throw errors.
        throw new QueryParseException(err.getMessage(), err, -1, -1);
    } catch (Throwable th) {
        Log.warn(ParserSPARQL11.class, "Unexpected throwable: ", th);
        throw new QueryException(th.getMessage(), th);
    }
}
Also used : StringReader(java.io.StringReader) Reader(java.io.Reader) QueryParseException(org.apache.jena.query.QueryParseException) JenaException(org.apache.jena.shared.JenaException) QueryException(org.apache.jena.query.QueryException) ARQParser(org.apache.jena.sparql.lang.arq.ARQParser) StringReader(java.io.StringReader)

Aggregations

ARQParser (org.apache.jena.sparql.lang.arq.ARQParser)7 QueryParseException (org.apache.jena.query.QueryParseException)5 Query (org.apache.jena.query.Query)4 QueryException (org.apache.jena.query.QueryException)4 JenaException (org.apache.jena.shared.JenaException)4 StringReader (java.io.StringReader)3 Reader (java.io.Reader)2 VarExprList (org.apache.jena.sparql.core.VarExprList)1 ParseException (org.apache.jena.sparql.lang.arq.ParseException)1 TokenMgrError (org.apache.jena.sparql.lang.arq.TokenMgrError)1 Element (org.apache.jena.sparql.syntax.Element)1 Template (org.apache.jena.sparql.syntax.Template)1