/** * Parses the supplied query into a query model. * * @param ql * The language in which the query is formulated. * @param query * The query. * @param baseURI * The base URI to resolve any relative URIs that are in the query against, can be <tt>null</tt> if * the query does not contain any relative URIs. * @return The query model for the parsed query. * @throws MalformedQueryException * If the supplied query was malformed. * @throws UnsupportedQueryLanguageException * If the specified query language is not supported. */ public static ParsedQuery parseQuery(QueryLanguage ql, String query, String baseURI) throws MalformedQueryException, UnsupportedQueryLanguageException { QueryParser parser = createParser(ql); return parser.parseQuery(query, baseURI); }
|| strippedOperation.startsWith("DESCRIBE") || strippedOperation.startsWith("ASK")) parsedOperation = parser.parseQuery(operation, baseURI); parsedOperation = parser.parseUpdate(operation, baseURI); parsedOperation = parser.parseQuery(operation, baseURI);
/** * Parses the supplied update operation into a query model. * * @param ql * The language in which the update operation is formulated. * @param update * The update operation. * @param baseURI * The base URI to resolve any relative URIs that are in the operation against, can be * <tt>null</tt> if the update operation does not contain any relative URIs. * @return The model for the parsed update operation. * @throws MalformedQueryException * If the supplied update operation was malformed. * @throws UnsupportedQueryLanguageException * If the specified query language is not supported. */ public static ParsedUpdate parseUpdate(QueryLanguage ql, String update, String baseURI) throws MalformedQueryException, UnsupportedQueryLanguageException { QueryParser parser = createParser(ql); return parser.parseUpdate(update, baseURI); }
/** * Parses the supplied update operation into a query model. * * @param ql * The language in which the update operation is formulated. * @param update * The update operation. * @param baseURI * The base URI to resolve any relative URIs that are in the operation against, can be * <tt>null</tt> if the update operation does not contain any relative URIs. * @return The model for the parsed update operation. * @throws MalformedQueryException * If the supplied update operation was malformed. * @throws UnsupportedQueryLanguageException * If the specified query language is not supported. */ public static ParsedUpdate parseUpdate(QueryLanguage ql, String update, String baseURI) throws MalformedQueryException, UnsupportedQueryLanguageException { QueryParser parser = createParser(ql); return parser.parseUpdate(update, baseURI); }
/** * Parses the supplied query into a query model. * * @param ql * The language in which the query is formulated. * @param query * The query. * @param baseURI * The base URI to resolve any relative URIs that are in the query against, can be <tt>null</tt> if * the query does not contain any relative URIs. * @return The query model for the parsed query. * @throws MalformedQueryException * If the supplied query was malformed. * @throws UnsupportedQueryLanguageException * If the specified query language is not supported. */ public static ParsedQuery parseQuery(QueryLanguage ql, String query, String baseURI) throws MalformedQueryException, UnsupportedQueryLanguageException { QueryParser parser = createParser(ql); return parser.parseQuery(query, baseURI); }
|| strippedOperation.startsWith("DESCRIBE") || strippedOperation.startsWith("ASK")) parsedOperation = parser.parseQuery(operation, baseURI); parsedOperation = parser.parseUpdate(operation, baseURI); parsedOperation = parser.parseQuery(operation, baseURI);
/** * Parses the supplied update operation into a query model. * * @param ql * The language in which the update operation is formulated. * @param update * The update operation. * @param baseURI * The base URI to resolve any relative URIs that are in the operation against, can be * <tt>null</tt> if the update operation does not contain any relative URIs. * @return The model for the parsed update operation. * @throws MalformedQueryException * If the supplied update operation was malformed. * @throws UnsupportedQueryLanguageException * If the specified query language is not supported. */ public static ParsedUpdate parseUpdate(QueryLanguage ql, String update, String baseURI) throws MalformedQueryException, UnsupportedQueryLanguageException { QueryParser parser = createParser(ql); return parser.parseUpdate(update, baseURI); }
/** * Parses the supplied query into a query model. * * @param ql * The language in which the query is formulated. * @param query * The query. * @param baseURI * The base URI to resolve any relative URIs that are in the query against, can be <tt>null</tt> if * the query does not contain any relative URIs. * @return The query model for the parsed query. * @throws MalformedQueryException * If the supplied query was malformed. * @throws UnsupportedQueryLanguageException * If the specified query language is not supported. */ public static ParsedQuery parseQuery(QueryLanguage ql, String query, String baseURI) throws MalformedQueryException, UnsupportedQueryLanguageException { QueryParser parser = createParser(ql); return parser.parseQuery(query, baseURI); }
|| strippedOperation.startsWith("DESCRIBE") || strippedOperation.startsWith("ASK")) parsedOperation = parser.parseQuery(operation, baseURI); parsedOperation = parser.parseUpdate(operation, baseURI); parsedOperation = parser.parseQuery(operation, baseURI);
ParsedQuery parsedQuery = null; try { parsedQuery = parser.parseQuery(sparql, null); } catch (MalformedQueryException e) { throw new IOException(e);
/** * @inheritDoc */ public void validateQueryFormat(final String theQuery, final String theProjectionVarName) { String aQuery = theQuery.toLowerCase().trim(); aQuery = aQuery.replaceAll(RdfQuery.VT_RE, asProjectionVar("x")); if (!startsWithKeyword(aQuery)) { if (!aQuery.contains(patternKeyword())) { aQuery = " " + patternKeyword() + " " + aQuery; } aQuery = "select " + asProjectionVar(theProjectionVarName) + " " + aQuery; } StringBuffer aBuffer = new StringBuffer(aQuery); insertNamespaces(aBuffer); try { new SeRQLParserFactory().getParser().parseQuery(aBuffer.toString(), ""); } catch (MalformedQueryException e) { throw new IllegalArgumentException("Invalid query: " + aBuffer.toString(), e); } }
/** * @inheritDoc */ public void validateQueryFormat(final String theQuery, final String theProjectionVarName) { String aQuery = theQuery.toLowerCase().trim(); aQuery = aQuery.replaceAll(RdfQuery.VT_RE, asProjectionVar("x")); if (!startsWithKeyword(aQuery)) { if (!aQuery.contains(patternKeyword())) { aQuery = " " + patternKeyword() + " " + aQuery; } aQuery = "select " + asProjectionVar(theProjectionVarName) + " " + aQuery; } StringBuffer aBuffer = new StringBuffer(aQuery); insertNamespaces(aBuffer); try { new SPARQLParserFactory().getParser().parseQuery(aBuffer.toString(), "http://example.org"); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid query: " + aBuffer.toString(), e); } catch (MalformedQueryException e) { throw new IllegalArgumentException("Invalid query: " + aBuffer.toString(), e); } }
ParsedQuery parsedQuery = queryParserFactory.getParser().parseQuery(newQuery.toString(), null);
ParsedQuery parsedQuery = queryParserFactory.getParser().parseQuery(newQuery.toString(), null);
@Override protected void runTest() throws Exception { // Read query from file InputStream stream = url(queryFile).openStream(); String query = IOUtil.readString(new InputStreamReader(stream, "UTF-8")); stream.close(); try { QueryParser parser = createParser(); parser.parseQuery(query, null); if (MFX_PARSE_ERROR.equals(result)) { fail("Negative syntax test failed. Malformed query caused no error."); } } catch (MalformedQueryException e) { if (MFX_CORRECT.equals(result)) { fail("Positive syntax test failed: " + e.getMessage()); } else { return; } } }
ParsedQuery parsedQuery = queryParserFactory.getParser().parseQuery(newQuery.toString(), null);
ParsedQuery parsedQuery = queryParserFactory.getParser().parseQuery(newQuery.toString(), null);
QueryParserFactory queryParserFactory = QueryParserRegistry.getInstance().get(QueryLanguage.SPARQL).get(); ParsedQuery parsedQuery = queryParserFactory.getParser().parseQuery(query, null);
public String generatePigScript(final String sparql) throws Exception { Preconditions.checkNotNull(sparql, "Sparql query cannot be null"); final QueryParser parser = new SPARQLParser(); final ParsedQuery parsedQuery = parser.parseQuery(sparql, null); final QueryRoot tupleExpr = new QueryRoot(parsedQuery.getTupleExpr()); // SimilarVarJoinOptimizer similarVarJoinOptimizer = new SimilarVarJoinOptimizer(); // similarVarJoinOptimizer.optimize(tupleExpr, null, null); if (inference || stats) { if (inference) { tupleExpr.visit(new TransitivePropertyVisitor(conf, inferenceEngine)); tupleExpr.visit(new SymmetricPropertyVisitor(conf, inferenceEngine)); tupleExpr.visit(new InverseOfVisitor(conf, inferenceEngine)); } if (stats) { (new QueryJoinOptimizer(rdfCloudTripleStoreEvaluationStatistics)).optimize(tupleExpr, null, null); } } sparqlToPigTransformVisitor.meet(tupleExpr); return sparqlToPigTransformVisitor.getPigScript(); }
QueryParserFactory queryParserFactory = QueryParserRegistry.getInstance().get(QueryLanguage.SPARQL).get(); ParsedQuery parsedQuery = queryParserFactory.getParser().parseQuery(query, null);