@Test public void testSetOptions() { Map<String, String> options = new HashMap<>(); options.put("backend", "dummy"); try { graph.setOptions(options); fail("Should have raised IllegalArgumentException"); } catch (IllegalArgumentException e) { } options.put("backend", "memory"); graph.setOptions(options); options.put("databaseDoCompressUri", "dummy"); try { graph.setOptions(options); fail("Should have raised IllegalArgumentException"); } catch (IllegalArgumentException e) { } options.put("databaseDoCompressUri", "true"); graph.setOptions(options); options.put("databaseTransactionEnabled", "dummy"); try { graph.setOptions(options); fail("Should have raised IllegalArgumentException"); } catch (IllegalArgumentException e) { } options.put("databaseTransactionEnabled", "false"); graph.setOptions(options); }
protected void setOptions(Map<String, String> options) { for (Map.Entry<String, String> option : options.entrySet()) { String key = option.getKey(); String value = option.getValue(); if (key.equals("backend")) { if (value.equals("memory") || value.equals("sql")) { backend = value; } else { throw new IllegalArgumentException(String.format("Unknown backend %s for Jena graph", value)); } } else if (key.equals("datasource")) { datasource = value; } else if (key.equals("databaseType")) { databaseType = value; } else if (key.equals("databaseDoCompressUri")) { if (value.equals("true")) { databaseDoCompressUri = true; } else if (value.equals("false")) { databaseDoCompressUri = false; } else { String format = "Illegal value %s for databaseDoCompressUri, must be true or false"; throw new IllegalArgumentException(String.format(format, value)); } } else if (key.equals("databaseTransactionEnabled")) { if (value.equals("true")) { databaseTransactionEnabled = true; } else if (value.equals("false")) { databaseTransactionEnabled = false; } else { String format = "Illegal value %s for databaseTransactionEnabled, must be true or false"; throw new IllegalArgumentException(String.format(format, value)); } } } }
JenaGraph implements Graph { protected void setOptions(Map<String, String> options) { for (Map.Entry<String, String> option : options.entrySet()) { String key = option.getKey(); String value = option.getValue(); if (key.equals("backend")) { if (value.equals("memory") || value.equals("sql")) { backend = value; } else { throw new IllegalArgumentException(String.format("Unknown backend %s for Jena graph", value)); } } else if (key.equals("datasource")) { datasource = value; } else if (key.equals("databaseType")) { databaseType = value; } else if (key.equals("databaseDoCompressUri")) { if (value.equals("true")) { databaseDoCompressUri = true; } else if (value.equals("false")) { databaseDoCompressUri = false; } else { String format = "Illegal value %s for databaseDoCompressUri, must be true or false"; throw new IllegalArgumentException(String.format(format, value)); } } else if (key.equals("databaseTransactionEnabled")) { if (value.equals("true")) { databaseTransactionEnabled = true; } else if (value.equals("false")) { databaseTransactionEnabled = false; } else { String format = "Illegal value %s for databaseTransactionEnabled, must be true or false"; throw new IllegalArgumentException(String.format(format, value)); } } } } }
JenaGraph implements Graph { protected void setOptions(Map<String, String> options) { for (Map.Entry<String, String> option : options.entrySet()) { String key = option.getKey(); String value = option.getValue(); if (key.equals("backend")) { if (value.equals("memory") || value.equals("sql")) { backend = value; } else { throw new IllegalArgumentException(String.format("Unknown backend %s for Jena graph", value)); } } else if (key.equals("datasource")) { datasource = value; } else if (key.equals("databaseType")) { databaseType = value; } else if (key.equals("databaseDoCompressUri")) { if (value.equals("true")) { databaseDoCompressUri = true; } else if (value.equals("false")) { databaseDoCompressUri = false; } else { String format = "Illegal value %s for databaseDoCompressUri, must be true or false"; throw new IllegalArgumentException(String.format(format, value)); } } else if (key.equals("databaseTransactionEnabled")) { if (value.equals("true")) { databaseTransactionEnabled = true; } else if (value.equals("false")) { databaseTransactionEnabled = false; } else { String format = "Illegal value %s for databaseTransactionEnabled, must be true or false"; throw new IllegalArgumentException(String.format(format, value)); } } } }  }
JenaGraph implements Graph { protected void setOptions(Map<String, String> options) { for (Map.Entry<String, String> option : options.entrySet()) { String key = option.getKey(); String value = option.getValue(); if (key.equals("backend")) { if (value.equals("memory") || value.equals("sql")) { backend = value; } else { throw new IllegalArgumentException(String.format("Unknown backend %s for Jena graph", value)); } } else if (key.equals("datasource")) { datasource = value; } else if (key.equals("databaseType")) { databaseType = value; } else if (key.equals("databaseDoCompressUri")) { if (value.equals("true")) { databaseDoCompressUri = true; } else if (value.equals("false")) { databaseDoCompressUri = false; } else { String format = "Illegal value %s for databaseDoCompressUri, must be true or false"; throw new IllegalArgumentException(String.format(format, value)); } } else if (key.equals("databaseTransactionEnabled")) { if (value.equals("true")) { databaseTransactionEnabled = true; } else if (value.equals("false")) { databaseTransactionEnabled = false; } else { String format = "Illegal value %s for databaseTransactionEnabled, must be true or false"; throw new IllegalArgumentException(String.format(format, value)); } } } }  @Override void setDescription(GraphDescription graphDescription); void setNamespaces(Map<String, String> namespaces); @Override Map<String, String> getNamespaces(); @Override void add(Statement statement); @Override void add(List<Statement> statements); @Override void remove(Statement statement); @Override void remove(List<Statement> statements); @Override List<Statement> getStatements(); @Override List<Statement> getStatements(Node subject, Node predicate, Node object); @Override List<Statement> getStatements(Statement statement); @Override List<Node> getSubjects(Node predicate, Node object); @Override List<Node> getPredicates(Node subject, Node object); @Override List<Node> getObjects(Node subject, Node predicate); @Override boolean hasStatement(Statement statement); @Override boolean hasResource(Resource resource); @Override Long size(); @Override void clear(); @Override QueryResult query(String queryString, String language, String baseURI); @Override int queryCount(String queryString, String language, String baseURI); @Override boolean read(InputStream in, String lang, String base); @Override boolean read(String path, String lang, String base); @Override boolean write(OutputStream out, String lang, String base); @Override boolean write(String path, String lang, String base); }
JenaGraph implements Graph { protected void setOptions(Map<String, String> options) { for (Map.Entry<String, String> option : options.entrySet()) { String key = option.getKey(); String value = option.getValue(); if (key.equals("backend")) { if (value.equals("memory") || value.equals("sql")) { backend = value; } else { throw new IllegalArgumentException(String.format("Unknown backend %s for Jena graph", value)); } } else if (key.equals("datasource")) { datasource = value; } else if (key.equals("databaseType")) { databaseType = value; } else if (key.equals("databaseDoCompressUri")) { if (value.equals("true")) { databaseDoCompressUri = true; } else if (value.equals("false")) { databaseDoCompressUri = false; } else { String format = "Illegal value %s for databaseDoCompressUri, must be true or false"; throw new IllegalArgumentException(String.format(format, value)); } } else if (key.equals("databaseTransactionEnabled")) { if (value.equals("true")) { databaseTransactionEnabled = true; } else if (value.equals("false")) { databaseTransactionEnabled = false; } else { String format = "Illegal value %s for databaseTransactionEnabled, must be true or false"; throw new IllegalArgumentException(String.format(format, value)); } } } }  @Override void setDescription(GraphDescription graphDescription); void setNamespaces(Map<String, String> namespaces); @Override Map<String, String> getNamespaces(); @Override void add(Statement statement); @Override void add(List<Statement> statements); @Override void remove(Statement statement); @Override void remove(List<Statement> statements); @Override List<Statement> getStatements(); @Override List<Statement> getStatements(Node subject, Node predicate, Node object); @Override List<Statement> getStatements(Statement statement); @Override List<Node> getSubjects(Node predicate, Node object); @Override List<Node> getPredicates(Node subject, Node object); @Override List<Node> getObjects(Node subject, Node predicate); @Override boolean hasStatement(Statement statement); @Override boolean hasResource(Resource resource); @Override Long size(); @Override void clear(); @Override QueryResult query(String queryString, String language, String baseURI); @Override int queryCount(String queryString, String language, String baseURI); @Override boolean read(InputStream in, String lang, String base); @Override boolean read(String path, String lang, String base); @Override boolean write(OutputStream out, String lang, String base); @Override boolean write(String path, String lang, String base);  }