public boolean isGraph() { if ( !hasBeenSet ) throw new ResultSetException("Not set"); return model != null; }
System.err.println(ex.getMessage()); ex.printStackTrace(System.err);
@SuppressWarnings("unchecked") public static <T> T wrapException(Supplier<T> supplier) { T result; try { result = supplier.get(); } catch(Exception e) { RuntimeException f; if(e instanceof ResultSetException) { ResultSetException x = (ResultSetException)e; String msg = x.getMessage(); if(msg.contains("One or more of the required keys")) { result = (T)ResultSetFactory.create(QueryIterNullIterator.create(null), Collections.<String>emptyList()); return result; } else { f = new RuntimeException(e); } } else { f = HttpExceptionUtils.makeHumanFriendly(e); } throw f; } return result; }
System.err.println(ex.getMessage()); ex.printStackTrace(System.err);
public boolean isJson() { if ( !hasBeenSet ) throw new ResultSetException("Not set"); return jsonItems != null; }
System.err.println(ex.getMessage()) ; ex.printStackTrace(System.err) ;
public boolean isResultSet() { if ( !hasBeenSet ) throw new ResultSetException("Not set"); return resultSet != null; }
System.err.println(ex.getMessage()) ; ex.printStackTrace(System.err) ;
public boolean isDataset() { if ( !hasBeenSet ) throw new ResultSetException("Not set"); return dataset != null; }
public boolean isBoolean() { if ( !hasBeenSet ) throw new ResultSetException("Not set"); return booleanResult != null; }
public Boolean getBooleanResult() { if ( !hasBeenSet ) throw new ResultSetException("Not set"); if ( !isBoolean() ) throw new ResultSetException("Not a boolean result"); return booleanResult; }
public Model getModel() { if ( !hasBeenSet ) throw new ResultSetException("Not set"); if ( !isModel() ) throw new ResultSetException("Not a graph result"); return model; }
public Dataset getDataset() { if ( !hasBeenSet ) throw new ResultSetException("Not set"); if ( !isDataset() ) throw new ResultSetException("Not a dataset result"); return dataset; }
public ResultSet getResultSet() { if ( !hasBeenSet ) throw new ResultSetException("Not set"); if ( !isResultSet() ) throw new ResultSetException("Not a ResultSet result"); return resultSet; }
public Iterator<JsonObject> getJsonItems() { if ( !hasBeenSet ) throw new ResultSetException("Not set"); if ( !isJson() ) throw new ResultSetException("Not a JSON result"); return jsonItems; }
public static SPARQLResult read(Reader in, Model model, Context context) { XMLInputFactory xf = XMLInputFactory.newInstance() ; try { XMLStreamReader xReader = xf.createXMLStreamReader(in) ; return worker(xReader, model, context) ; } catch (XMLStreamException e) { throw new ResultSetException("Can't initialize StAX parsing engine", e) ; } catch (Exception ex) { throw new ResultSetException("Failed when initializing the StAX parsing engine", ex) ; } }
public static SPARQLResult read(InputStream in, Model model, Context context) { XMLInputFactory xf = XMLInputFactory.newInstance() ; try { XMLStreamReader xReader = xf.createXMLStreamReader(in) ; return worker(xReader, model, context); } catch (XMLStreamException e) { throw new ResultSetException("Can't initialize StAX parsing engine", e) ; } catch (Exception ex) { throw new ResultSetException("Failed when initializing the StAX parsing engine", ex) ; } }
private static void checkContains(JsonObject term, boolean allowUndefinedKeys, boolean requireAllExpectedKeys, String... keys) { List<String> expectedKeys = Arrays.asList(keys); Set<String> declared = new HashSet<>(); for ( String k : term.keys() ) { if ( !expectedKeys.contains(k) && !allowUndefinedKeys ) throw new ResultSetException("Expected only object keys " + Arrays.asList(keys) + " but encountered '" + k + "'"); if ( expectedKeys.contains(k) ) declared.add(k); } if ( requireAllExpectedKeys && declared.size() < expectedKeys.size() ) throw new ResultSetException("One or more of the required keys " + expectedKeys + " was not found"); } }
@Override public void read(Reader reader, String baseURI, ContentType ct, StreamRDF output, Context context) { XMLInputFactory xf = XMLInputFactory.newInstance() ; XMLStreamReader xReader ; try { xReader = xf.createXMLStreamReader(reader) ; } catch (XMLStreamException e) { throw new ResultSetException("Can't initialize StAX parsing engine", e) ; } read(xReader, baseURI, output) ; }
private void staxError(String msg, Throwable th) { Log.warn(this, "StAX error: " + msg, th) ; throw new ResultSetException(msg, th) ; } }