@Override public void addAll(Iterator<? extends Statement> other) throws ModelRuntimeException { this.delegatedModel.addAll(other); }
@Override public void addAll(Iterator<? extends Statement> other) throws ModelRuntimeException { this.delegatedModel.addAll(other); }
@Override public void addAll(Iterator<? extends Statement> other) throws ModelRuntimeException { log.debug("addAll"); this.model.addAll(other); }
/** * @param a a Model * @param b a Model * @param result should be empty before calling this method * @return the result after executing the union * @throws ModelRuntimeException from underlying IO errors, if any. */ public static Model union(Model a, Model b, Model result) throws ModelRuntimeException { ClosableIterator<Statement> it = a.iterator(); result.addAll(it); it.close(); it = b.iterator(); result.addAll(it); it.close(); return result; }
public static void write(Model m, String filename, String format) throws ModelRuntimeException { Model jenaModel = new ModelImplJena(Reasoning.none); jenaModel.addAll(m.iterator()); com.hp.hpl.jena.rdf.model.Model jm = (com.hp.hpl.jena.rdf.model.Model)jenaModel .getUnderlyingModelImplementation(); DumpUtils.addCommonPrefixesToJenaModel(jm); try { // encoding! if(format.equalsIgnoreCase("rdf/xml")) { log.error("Writing RDF/XML in UTF-8..."); FileOutputStream fos; fos = new FileOutputStream(new File(filename)); OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); // Jena is not adding this to the XML file, when choosing UTF-8 // encoding osw.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); jm.write(osw, "RDF/XML", ""); } else jm.write(new FileWriter(new File(filename)), format, ""); } catch(FileNotFoundException e) { throw new ModelRuntimeException(e); } catch(IOException e) { throw new ModelRuntimeException(e); } }
/** * @param m the model to copy * @return a copy of the model in a memory model */ public static Model copyModel(Model m) { Model res = RDF2Go.getModelFactory().createModel(); res.open(); res.addAll(m.iterator()); return res; }
public static void write(Model m, Writer w) throws ModelRuntimeException { Model jenaModel = new ModelImplJena(Reasoning.none); jenaModel.addAll(m.iterator()); com.hp.hpl.jena.rdf.model.Model jm = (com.hp.hpl.jena.rdf.model.Model)jenaModel .getUnderlyingModelImplementation(); try { writeJenaModel(jm, w); } catch(IOException e) { throw new ModelRuntimeException(e); } }
/** * @param a a Model * @param b a Model * @param result the resulting Model, should be empty before calling this * method * @return the result after executing the complement of b in a (a\b) * @throws ModelRuntimeException from underlying IO errors, if any. */ public static Model complement(Model a, Model b, Model result) throws ModelRuntimeException { ClosableIterator<Statement> it = a.iterator(); result.addAll(it); it.close(); it = b.iterator(); result.removeAll(it); it.close(); return result; }
/** * Merge all input files into one model and export to outfile in output * syntax * * @throws IOException from file reading * @throws ModelRuntimeException from underlying IO errors, if any. */ public static void convert(File[] inFiles, Syntax[] inSyntax, File out, Syntax outSyntax) throws ModelRuntimeException, IOException { Model merged = RDF2Go.getModelFactory().createModel(); for(int i = 0; i < inFiles.length; i++) { Model inModel = loadFromFile(inFiles[i], inSyntax[i]); ClosableIterator<Statement> it = inModel.iterator(); merged.addAll(it); it.close(); } writeToFile(merged, out, outSyntax); }
target.addAll(it); it.close(); } else {