/** * Parse the source, sending the results to a {@link Model}. * The source must be for triples; any quads are discarded. * This method is equivalent to {@code parse(model.getGraph())}. */ public void parse(Model model) { parse(model.getGraph()); }
/** Read triples into a Model from the given location, with some parameters for the reader * @see #read(Model,String,String,Lang,Context) * @param model Destination for the RDF read * @param uri URI to read from (includes file: and a plain file name). * @param context Content object to control reading process. * @throws RiotNotFoundException if the location is not found - the model is unchanged. * @deprecated To be removed. Use {@code RDFParser.create().context(context)...} */ @Deprecated public static void read(Model model, String uri, Context context) { read(model.getGraph(), uri, context) ; }
/** Create a GraphStore from a Model * @param model * @return GraphStore */ @Deprecated public static GraphStore create(Model model) { return create(model.getGraph()) ; }
/** Put (replace) the default model of a Dataset */ @Override public void putModel(Model data) { updater.httpPut(data.getGraph()) ; }
/** Write the model to the output stream in the default serialization for the language. * @param out OutputStream * @param model Graph to write * @param lang Language for the serialization. */ public static void write(OutputStream out, Model model, Lang lang) { write(out, model.getGraph(), lang); }
/** Write the graph to the output stream in the default serialization for the language. * @param out OutputStream * @param model Model to write * @param serialization Serialization format * @deprecated Use of writers is deprecated - use an OutputStream */ @Deprecated public static void write(Writer out, Model model, RDFFormat serialization) { write(out, model.getGraph(), serialization); }
/** Set the source of writing to the graph argument. * <p> * Any previous source setting is cleared. * <p> * Equivalent to {@code source(model.getGraph()(s)} * * @param model A {@link Model}. * @return this */ public RDFWriterBuilder source(Model model) { return source(model.getGraph()); }
@Override public Model remove( Model m ) { GraphUtil.deleteFrom( getGraph(), m.getGraph()); return this; }
/** * Precompute the implications of a schema Model. The statements in the graph * will be combined with the data when the final InfGraph is created. */ @Override public Reasoner bindSchema(Model tbox) throws ReasonerException { InfGraph graph = new BasicForwardRuleInfGraph(this, rules, null, tbox.getGraph()); return new BasicForwardRuleReasoner(rules, graph, factory); }
@Override protected void readWorker(Model model, Reader reader, String base) { ParserTurtle p = new ParserTurtle() ; p.parse( model.getGraph(), base, reader ) ; } }
/** Put (create/replace) a named model of a Dataset */ @Override public void putModel(String graphUri, Model data) { updater.httpPut(NodeFactory.createURI(graphUri), data.getGraph()) ; }
/** Answer <code>model</code> after updating it with the sub-graph of <code>s</code> rooted at <code>r</code>, bounded by this instances <code>boundary</code>. */ public Model extractInto( Model model, Resource r, Model s ) { TripleBoundary tb = boundary.asTripleBoundary( s ); Graph g = getGraphExtract( tb ) .extractInto( model.getGraph(), r.asNode(), s.getGraph() ); return ModelFactory.createModelForGraph( g ); }
@Override public Dataset addNamedModel(String uri, Model model) { checkGraphName(uri) ; Node n = NodeFactory.createURI(uri) ; dsg.addGraph(n, model.getGraph()) ; return this; }
@Override public PrefixMapping getPrefixMapping() { return createModel().getGraph().getPrefixMapping(); }
@Override public PrefixMapping getPrefixMapping() { return ModelFactory.createDefaultModel().getGraph() .getPrefixMapping(); } }
public void testSchema() { Model schema = model( "P rdf:type owl:ObjectProperty" ); Resource root = resourceInModel( "x rdf:type ja:ReasonerFactory; x ja:schema S" ); Assembler sub = new NamedObjectAssembler( resource( "S" ), schema ); ReasonerFactory rf = (ReasonerFactory) ASSEMBLER.open( sub, root ); Reasoner r = rf.create( null ); assertIsomorphic( schema.getGraph(), ((FBRuleReasoner) r).getBoundSchema() ); }
public void testFollowOwlImports() { final Model modelToLoad = model( "this hasMarker B5" ); Model m = model( "x ja:reasoner y; _x owl:imports eh:/loadMe" ); FileManager fm = new FixedFileManager().add( "eh:/loadMe", modelToLoad ); Model m2 = new ImportManager().withImports( fm, m ); assertInstanceOf( MultiUnion.class, m2.getGraph() ); assertIsoModels( modelToLoad.union( m ), m2 ); }
public void testImportMayBeLiteral() { final Model modelToLoad = model( "this hasMarker B5" ); Model m = model( "x ja:reasoner y; _x ja:imports 'eh:/loadMe'" ); FileManager fm = new FixedFileManager().add( "eh:/loadMe", modelToLoad ); Model m2 = new ImportManager().withImports( fm, m ); assertInstanceOf( MultiUnion.class, m2.getGraph() ); assertIsoModels( modelToLoad.union( m ), m2 ); }
@Test(expected=ConcurrentModificationException.class) public void mrswGraph2() { Model m = create().getDefaultModel() ; Resource r = m.createResource("x") ; ExtendedIterator<Statement> iter1 = m.listStatements(r, null, (RDFNode)null) ; assertNotNull(iter1.next()) ; Triple t = SSE.parseTriple("(<y> <p> 99)") ; m.getGraph().add(t) ; // Bad iter1.hasNext(); }