code: @Override
      public MarkLogicQuery prepareQuery(QueryLanguage queryLanguage, String queryString, String baseURI)
              throws RepositoryException, MalformedQueryException
      {
          // function routing based on query form
          if (SPARQL.equals(queryLanguage)) {
              String queryStringWithoutProlog = QueryParserUtil.removeSPARQLQueryProlog(queryString).toUpperCase();
              if (queryStringWithoutProlog.startsWith("SELECT")) {
                  return prepareTupleQuery(queryLanguage, queryString, baseURI);   //must be a TupleQuery
              }
              else if (queryStringWithoutProlog.startsWith("ASK")) {
                  return prepareBooleanQuery(queryLanguage, queryString, baseURI); //must be a BooleanQuery
              }
              else {
                  return prepareGraphQuery(queryLanguage, queryString, baseURI);   //all the rest use GraphQuery
              }
          }
          throw new UnsupportedQueryLanguageException("Unsupported query language " + queryLanguage.getName());
      }
docs: base method for prepareQuery
  
  routes to all other query forms (prepareTupleQuery,prepareBooleanQuery,prepareGraphQuery)
  
  @param queryLanguage
  @param queryString
  @param baseURI
  @return MarkLogicQuery
  @throws RepositoryException
  @throws MalformedQueryException