Package com.data2semantics.yasgui.shared.exceptions

Examples of com.data2semantics.yasgui.shared.exceptions.SparqlParseException


   * @throws SparqlParseException When json string is not valid
   * @throws SparqlEmptyException When json string is valid, but contains no results
   */
  public void processResults(String jsonString) throws SparqlParseException, SparqlEmptyException {
    if (jsonString == null || jsonString.length() == 0) {
      throw new SparqlParseException("Unable to parse empty JSON string");
    }
    JSONValue jsonValue = JSONParser.parseStrict(jsonString);
    //no need for this anymore, and it can be quite big. Fingers crossed and hope garbage collector deals witht this properly
    jsonString = null;
    if (jsonValue == null) {
      throw new SparqlParseException("Unable to parse query json string");
    }
    JSONObject queryResult = jsonValue.isObject();
    if (queryResult == null) throw new SparqlParseException("Unable to parse query json string");
   
    if (queryMode == ResultType.Table) {
      storeVariables(queryResult);
      storeBindings(queryResult);
    } else if (queryMode == ResultType.Boolean) {
View Full Code Here


   * @return
   * @throws SparqlParseException
   */
  public JSONObject getAsObject(JSONValue jsonValue) throws SparqlParseException {
    if (jsonValue == null) {
      throw new SparqlParseException("Unable to get as object");
    }
    JSONObject result = jsonValue.isObject();
    if (result == null) {
      throw new SparqlParseException("Unable to get as object");
    }
    return result;
  }
View Full Code Here

   * @throws SparqlParseException
   */
  public JSONArray getAsArray(JSONObject jsonObject, String key) throws SparqlParseException {
    JSONValue jsonValue = jsonObject.get(key);
    if (jsonValue == null) {
      throw new SparqlParseException("Unable to get " + key + " as array");
    }
    JSONArray result = jsonValue.isArray();
    if (result == null) {
      throw new SparqlParseException("Unable to get " + key + " as array");
    }
    return result;
  }
View Full Code Here

   * @throws SparqlParseException
   */
  public String getAsString(JSONValue jsonValue) throws SparqlParseException {
    JSONString jsonString = jsonValue.isString();
    if (jsonString == null) {
      throw new SparqlParseException("Cannot format value as string");
    }
    return jsonString.stringValue();
  }
View Full Code Here

 
 
  private void storeBooleanResult(JSONObject queryResult) {
    JSONBoolean jsonBoolean = queryResult.get("boolean").isBoolean();
    if (jsonBoolean == null) {
      throw new SparqlParseException("Cannot format value as boolean");
    }
    booleanResult = jsonBoolean.booleanValue();
  }
View Full Code Here

    }
    DlvWrapper dlv;
    try {
      dlv = JsMethods.getDlv(jsonString, separator);
    } catch (Throwable e) {
      throw new SparqlParseException("Unable to parse " + (separator.equals(",")? "CSV": "TSV") + " string", e);
    }
    if (dlv.length() < 2) { //first row contains vars
      throw new SparqlEmptyException("No results");
    }
    if (queryMode == ResultType.Table) {
View Full Code Here

 
  private void storeBooleanResult(DlvWrapper dlv) throws SparqlParseException {
    Row row = dlv.getRow(1); //just 2 lines, second line contains the boolean val
   
    if (row.length() == 0 || row.getCol(0) == null || row.getCol(0).length() == 0) {
      throw new SparqlParseException("Invalid " + (separator.equals(",")? "CSV": "TSV") + ". Unable to detect boolean value");
    } else {
      String value = row.getCol(0);
      this.booleanResult = (value.equals("1") || value.equalsIgnoreCase("true"));
    }
  }
View Full Code Here

  private void addQueryResult(String responseString, Type contentType) {
    try {
      String queryType = JsMethods.getQueryType(view.getSelectedTab().getQueryTextArea().getInputId());
      if (!queryTypes.containsKey(queryType)) {
        throw new SparqlParseException("No valid query type detected for this query");
      }
      ResultType queryMode = queryTypes.get(queryType);
      switch (queryTypes.get(queryType)) {
      case Insert:
        addMember(getResultsLabel(Imgs.CHECKBOX.get(), "Done"));
View Full Code Here

    } else if (contentType == Type.SELECT_CSV) {
      results = new DlvResults(responseString, view, resultType, ",");
    } else if (contentType == Type.SELECT_TSV) {
      results = new DlvResults(responseString, view, resultType, "\t");
    } else {
      throw new SparqlParseException("no valid content type found for this response");
    }
    return results;
  }
View Full Code Here

   * @throws SparqlParseException When json string is not valid
   * @throws SparqlEmptyException When json string is valid, but contains no results
   */
  public void processResults(String xmlString) throws SparqlParseException, SparqlEmptyException {
    if (xmlString == null || xmlString.length() == 0) {
      throw new SparqlParseException("Unable to parse empty xml string");
    }
    Document xmlDoc = XMLParser.parse(xmlString);
    //no need for this anymore, and it can be quite big. Fingers crossed and hope garbage collector deals witht this properly
    xmlString = null;
   
View Full Code Here

TOP

Related Classes of com.data2semantics.yasgui.shared.exceptions.SparqlParseException

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.