@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 ); }
public int indexOf(String varname) { for ( int i = 0 ; i < indexes.size() ; i++ ) { if ( indexes.get(i).equals(varname) ) return i ; } //return -1 ; throw new DoesNotExistException("Name not bound: "+varname) ; }
protected void readModelFrom( Model m, boolean strict, File name ) { FileInputStream in = null; try { in = new FileInputStream( name ); model.read( in, "", this.lang ); } catch (FileNotFoundException f) { if (strict) throw new DoesNotExistException( name.toString() ); } finally { if (in != null) try {in.close();} catch (IOException ignore) {} } }
/** 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(); }
/** * 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); } }