Package no.priv.garshol.duke

Examples of no.priv.garshol.duke.DukeException


      return new MongoDBIterator(result, mongo);
   
    } catch (UnknownHostException e) {
      throw new RuntimeException(e);
    } catch (Exception ex){
    throw new DukeException(ex);
    }
  }
View Full Code Here


    @Override  // is this "Override" necessary?
    public void close(){
      try {
        mongoClient.close();
      } catch (Exception e) {
        throw new DukeException(e);
      }
    }
View Full Code Here

  public RecordIterator getRecordsFromString(String s) {
    try {
      JsonFactory jsonFactory = new JsonFactory();
      return new JsonIterator(jsonFactory.createParser(new StringReader(s)));
    } catch (IOException e) {
      throw new DukeException(e);
    }
  }
View Full Code Here

    JsonFactory jsonFactory = new JsonFactory();
    try {
      JsonParser jp = jsonFactory.createParser(is);
      return new JsonIterator(jp);
    } catch (IOException e) {
      throw new DukeException(e);
    }
  }
View Full Code Here

  public RecordIterator getRecords() {
    try {
      return getRecordsFromStream(new FileInputStream(file));
    } catch (IOException e) {
      throw new DukeException("Error reading JSON from " + file, e);
    }
  }
View Full Code Here

            for (Column currentCol : currentCols)
              builder.addValue(currentCol, parser.getText());

        } while (currentToken != JsonToken.END_OBJECT || nestingLevel != -1);
      } catch (IOException e) {
        throw new DukeException(e);
      }
      return builder.getRecord();
    }
View Full Code Here

    if (line.charAt(pos) == '<')
      subject = parseuri();
    else if (line.charAt(pos) == '_')
      subject = parsebnode();
    else
      throw new DukeException("Subject in line " + lineno +
                              " is neither URI nor bnode: " + line);

    skipws();

    // property
    if (pos >= line.length())
      throw new DukeException("Line ends before predicate on line " + lineno);
    else if (line.charAt(pos) != '<')
      throw new DukeException("Predicate does not start with '<', " +
                              "nearby: '" +
                              line.substring(pos - 5, pos + 5) + "', at " +
                              "position: " + pos + " in line " + lineno);
    String property = parseuri();

    skipws();

    // object
    boolean literal = false;
    String object;
    if (pos >= line.length())
      throw new DukeException("Line ends before object on line " + lineno);
    else if (line.charAt(pos) == '<')
      object = parseuri();
    else if (line.charAt(pos) == '"') {
      object = unescape(parseliteral());
      literal = true;
    } else if (line.charAt(pos) == '_')
      object = parsebnode();
    else
      throw new DukeException("Illegal object on line " + lineno + ": " +
                              line.substring(pos));

    // terminator
    skipws();
    if (pos >= line.length() || line.charAt(pos++) != '.')
      throw new DukeException("Statement did not end with period; line: '" +
                              line + "', line number: " + lineno);

    skipws();
    if (pos + 1 < line.length())
      throw new DukeException("Garbage after period on line " + lineno);
   
    handler.statement(subject, property, object, literal);
  }
View Full Code Here

          if (literal.length() < ix + 4 ||
              !(hexchar(literal.charAt(ix)) &&
                hexchar(literal.charAt(ix + 1)) &&
                hexchar(literal.charAt(ix + 2)) &&
                hexchar(literal.charAt(ix + 3))))
            throw new DukeException("Bad Unicode escape: '" +
                                    literal.substring(ix - 2, ix + 4) + "'");
          buf[pos++] = unhex(literal, ix);
          ix += 3;
        } else
          throw new DukeException("Unknown escaped character: '" + ch + "' in '" + literal + "'");
      } else
        buf[pos++] = literal.charAt(ix);

    return new String(buf, 0, pos);
  }
View Full Code Here

  private String parseuri() {
    int start = pos + 1; // skip initial '<'
    while (pos < line.length() && line.charAt(pos) != '>')
      pos++;
    if (pos >= line.length())
      throw new DukeException("Line ends in URI at line " + lineno);
    pos++; // skip final '>'
    return line.substring(start, pos - 1);
  }
View Full Code Here

  }

  private void parsedatatype() {
    pos++; // skip first ^
    if (line.charAt(pos++) != '^')
      throw new DukeException("Incorrect start of datatype");
    if (line.charAt(pos) != '<')
      throw new DukeException("Datatype URI does not start with '<'");
    parseuri();
  }
View Full Code Here

TOP

Related Classes of no.priv.garshol.duke.DukeException

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.