@Override public Graph openGraph() { if (defaultGraph == null) throw new DoesNotExistException ( "no default graph in this GraphMaker [" + this.getClass() + "]" ); return defaultGraph; }
@Override public Graph openGraph() { if (defaultGraph == null) throw new DoesNotExistException ( "no default graph in this GraphMaker [" + this.getClass() + "]" ); return defaultGraph; }
/** Remove the mapping from name to any graph from the local map. */ @Override public void removeGraph( String name ) { if (!graphs.containsKey( name )) throw new DoesNotExistException( name ); graphs.remove( name ); }
/** Remove the mapping from name to any graph from the local map. */ @Override public void removeGraph( String name ) { if (!graphs.containsKey( name )) throw new DoesNotExistException( name ); graphs.remove( name ); }
@Override public Model openModel(String name) { Model m = getModel(name); if (m == null) { throw new DoesNotExistException(name); } else { return m; } }
/** Open (aka find) a graph with the given name in the local map. */ @Override public Graph openGraph( String name, boolean strict ) { GraphMemBase already = (GraphMemBase) graphs.get( name ); if (already == null) if (strict) throw new DoesNotExistException( name ); else return createGraph( name, true ); else return already.openAgain(); }
/** Open (aka find) a graph with the given name in the local map. */ @Override public Graph openGraph( String name, boolean strict ) { GraphMemBase already = (GraphMemBase) graphs.get( name ); if (already == null) if (strict) throw new DoesNotExistException( name ); else return createGraph( name, true ); else return already.openAgain(); }
@Override public void removeGraph(String uri) { AGGraph g = created.get(uri); if (g == null) { throw new DoesNotExistException(uri); } else { try { g.getConnection().clear(g.getGraphContext()); created.remove(uri); } catch (RepositoryException e) { throw new RuntimeException(e); } } }
@Override public Model openModel(String name, boolean strict) { if (strict && !this.hasModel(name)) { throw new DoesNotExistException(name); } else { return getModel(name); } }
/** * Reads from url, using url as base, adding triples to model. * Uses content negotiation to ask for application/rdf+xml, if available. * * @param m * A model to add triples to. * @param url * The URL of the RDF/XML document. */ @Override public void read(Model m, String url) throws JenaException { try { URLConnection conn = new URL(url).openConnection(); conn.setRequestProperty("accept", "application/rdf+xml, application/xml; q=0.8, text/xml; q=0.7, application/rss+xml; q=0.3, */*; q=0.2"); String encoding = conn.getContentEncoding(); if (encoding == null) read(m, conn.getInputStream(), url); else read(m, new InputStreamReader(conn.getInputStream(), encoding), url); } catch (FileNotFoundException e) { throw new DoesNotExistException(url); } catch (IOException e) { throw new JenaException(e); } }
@Override public AGGraph openGraph(String uri, boolean strict) { AGGraph g = created.get(uri); if (g == null) { if (strict) { throw new DoesNotExistException(uri); } else { Node node = NodeFactory.createURI(absUriFromString(uri)); g = new AGGraph(this, node); created.put(uri, g); } } return g; }
/** * Reads from url, using url as base, adding triples to model. * Uses content negotiation to ask for application/rdf+xml, if available. * * @param m * A model to add triples to. * @param url * The URL of the RDF/XML document. */ @Override public void read(Model m, String url) throws JenaException { try { URLConnection conn = new URL(url).openConnection(); conn.setRequestProperty("accept", "application/rdf+xml, application/xml; q=0.8, text/xml; q=0.7, application/rss+xml; q=0.3, */*; q=0.2"); String encoding = conn.getContentEncoding(); if (encoding == null) read(m, conn.getInputStream(), url); else read(m, new InputStreamReader(conn.getInputStream(), encoding), url); } catch (FileNotFoundException e) { throw new DoesNotExistException(url); } catch (IOException e) { throw new JenaException(e); } }
@Override public void removeModel(String name) { if (hasModel(name)) { models.remove(name); } else { throw new DoesNotExistException(name); } }
@Override public Model openModel(String name) { if (hasModel(name)) { return models.get(name); } else { throw new DoesNotExistException(name); } }
@Override public Model openModel(String name, boolean strict) { if (strict && !hasModel(name)) { throw new DoesNotExistException(name); } else { return openModel(name); } }