Package org.openrdf.query

Examples of org.openrdf.query.MalformedQueryException


          else {
            dataset.addDefaultGraph(uri);
          }
        }
        catch (IllegalArgumentException e) {
          throw new MalformedQueryException(e.getMessage(), e);
        }
      }
    }

    return dataset;
View Full Code Here


  {
    try {
      request.execute();
    }
    catch (MalformedQuery e) {
      throw new MalformedQueryException(e);
    }
    catch (UnsupportedQueryLanguage e) {
      throw new UnsupportedQueryLanguageException(e);
    }
    catch (UnsupportedFileFormat e) {
View Full Code Here

      if (mode == EvaluationMode.DEMO) {
        this.enableOrDisableButtons(queryOrRif);
      }
      return true;
    } else if (e instanceof MalformedQueryException) {
      final MalformedQueryException mqe = (MalformedQueryException) e;
      this.displayErrorMessage(mqe.getMessage(), false, queryOrRif);

      // create the pattern to match
      // and create a matcher against the string
      final Pattern pattern = Pattern
          .compile("line (\\d+), column (\\d+)");
      final Matcher matcher = pattern.matcher(mqe.getMessage());

      // try to find the pattern in the message...
      if (matcher.find() == true) {
        // get matches...
        final int line = Integer.parseInt(matcher.group(1));
View Full Code Here

    StringProcessor visitor = new StringProcessor();
    try {
      qc.jjtAccept(visitor, null);
    }
    catch (VisitorException e) {
      throw new MalformedQueryException(e.getMessage(), e);
    }
  }
View Full Code Here

        // Prefix already defined
        if (nsMap.get(prefix).equals(uri)) {
          // duplicate, ignore
        }
        else {
          throw new MalformedQueryException("Multiple namespace declarations for prefix '" + prefix
              + "'");
        }
      }
      else {
        nsMap.put(prefix, uri);
      }
    }

    // Use default namespace prefixes when not defined explicitly
    if (!nsMap.containsKey("rdf")) {
      nsMap.put("rdf", RDF.NAMESPACE);
    }
    if (!nsMap.containsKey("rdfs")) {
      nsMap.put("rdfs", RDFS.NAMESPACE);
    }
    if (!nsMap.containsKey("xsd")) {
      nsMap.put("xsd", XMLSchema.NAMESPACE);
    }
    if (!nsMap.containsKey("owl")) {
      nsMap.put("owl", OWL.NAMESPACE);
    }
    if (!nsMap.containsKey("sesame")) {
      nsMap.put("sesame", SESAME.NAMESPACE);
    }

    // For backwards compatibility:
    Map<String, String> extendedNsMap = new HashMap<String, String>(nsMap);
    if (!extendedNsMap.containsKey("serql")) {
      extendedNsMap.put("serql", SESAME.NAMESPACE);
    }

    // Replace all qnames with URIs
    QNameProcessor visitor = new QNameProcessor(extendedNsMap);
    try {
      qc.jjtAccept(visitor, null);
    }
    catch (VisitorException e) {
      throw new MalformedQueryException(e.getMessage(), e);
    }

    return nsMap;
  }
View Full Code Here

    ASTBaseDecl baseDecl = qc.getBaseDecl();
    if (baseDecl != null) {
      parsedBaseURI = new ParsedURI(baseDecl.getIRI());

      if (!parsedBaseURI.isAbsolute()) {
        throw new MalformedQueryException("BASE IRI is not an absolute IRI: " + externalBaseURI);
      }
    }
    else if (externalBaseURI != null) {
      // Use external base URI if the query doesn't contain one itself
      parsedBaseURI = new ParsedURI(externalBaseURI);

      if (!parsedBaseURI.isAbsolute()) {
        throw new IllegalArgumentException("Supplied base URI is not an absolute IRI: " + externalBaseURI);
      }
    }
    else {
      // FIXME: use the "Default Base URI"?
    }

    if (parsedBaseURI != null) {
      RelativeIRIResolver visitor = new RelativeIRIResolver(parsedBaseURI);
      try {
        qc.jjtAccept(visitor, null);
      }
      catch (VisitorException e) {
        throw new MalformedQueryException(e);
      }
    }
  }
View Full Code Here

      }

      return query;
    }
    catch (ParseException e) {
      throw new MalformedQueryException(e.getMessage(), e);
    }
    catch (TokenMgrError e) {
      throw new MalformedQueryException(e.getMessage(), e);
    }
  }
View Full Code Here

    TupleExprBuilder tupleExprBuilder = new TupleExprBuilder(new ValueFactoryImpl());
    try {
      return (TupleExpr)qc.jjtAccept(tupleExprBuilder, null);
    }
    catch (VisitorException e) {
      throw new MalformedQueryException(e.getMessage(), e);
    }
  }
View Full Code Here

  {
    try {
      qc.jjtAccept(new BlankNodeToVarConverter(), null);
    }
    catch (VisitorException e) {
      throw new MalformedQueryException(e);
    }
  }
View Full Code Here

        wildcardNode.jjtAppendChild(varNode);
        varNode.jjtSetParent(wildcardNode);
      }
    }
    catch (VisitorException e) {
      throw new MalformedQueryException(e);
    }
  }
View Full Code Here

TOP

Related Classes of org.openrdf.query.MalformedQueryException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.