public static void main(String[] args) throws IOException { Model model=ModelFactory.createDefaultModel(); model.read(new FileInputStream("simpsons.ttl"),null,"TTL"); }
protected static void addSubclassesFrom( Model result, Model schema ) { for (StmtIterator it = schema.listStatements( ANY, RDFS.subClassOf, ANY ); it.hasNext();) { Statement s = it.nextStatement(); if (s.getSubject().isURIResource() && s.getObject().isURIResource()) result.add( s ); } }
/** * @param rs * The reified statement to look for predicate. * @return The predicate uri or null if an error occurs */ protected String getReifiedStatementPredicate(final ReifiedStatement rs) { return rs.getStatement().getPredicate().getURI(); }
private Model normalizeModel(Model m) { Model norm = ModelFactory.createDefaultModel(); norm.add(m); // Filter out labels which we may or may not be fetching for (StmtIterator i = norm.listStatements(null, RDFS.label, (RDFNode) null); i.hasNext();) { i.next(); i.remove(); } return norm; }
protected Content getInitialContent( Assembler a, Resource root ) { Model partial = ModelFactory.createDefaultModel(); Resource combined = partial.createResource(); for (StmtIterator it = root.listProperties( JA.initialContent ); it.hasNext();) transferContentProperties( partial, it.nextStatement().getResource(), combined ); return contentFromModel( a, root, partial, combined ); }
private String asBody( RDFNode n ) { if (n.isLiteral()) return n.asLiteral().getLexicalForm(); if (n.isResource()) return n.asResource().getURI(); return n.toString(); }
public boolean selects(Statement s) { if (s.getObject().isResource()) { Resource res = s.getObject().asResource(); return res.equals(FOAF.Organization); } else { return false; } } };
protected int countArcsTo(Property prop, Resource resource) { int numArcs = 0 ; StmtIterator sIter = resource.getModel().listStatements(null, prop, resource) ; for ( ; sIter.hasNext() ; ) { sIter.nextStatement() ; numArcs++ ; } sIter.close() ; return numArcs ; }
public Resource asRDF(Model model, boolean result) { Resource results = model.createResource() ; results.addProperty(RDF.type, ResultSetGraphVocab.ResultSet) ; Literal lit = model.createTypedLiteral(result) ; results.addProperty(ResultSetGraphVocab.p_boolean, lit) ; return results ; }
public boolean hasProxy() throws OREException { Selector selector = new SimpleSelector(null, ORE.proxyFor, res); StmtIterator itr = model.listStatements(selector); if (itr.hasNext()) { return true; } return false; }
/** * Closes the model and the temporary model. Recreates a temporary model just in case. */ public void close() { this.model.close(); this.tempModel.close(); this.tempModel = ModelFactory.createDefaultModel(); }
private Resource completedClone( Resource root, Resource newRoot, Model fragment ) { Model typed = fragment.add( newRoot, RDF.type, JA.Content ); return newRoot.inModel( ModelFactory.createUnion( root.getModel(), typed ) ); }
/** 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 ); }
private boolean isInstanceOfTheClass(Resource resource, Resource class_resource) { Property type_property = ResourceFactory.createProperty(Namespaces.RDF + "type"); if (resource == null || !resource.isResource()) return true; if (resource.hasProperty(type_property, class_resource)) return true; else return false; }
public void clearTypes() { StmtIterator itr = res.listProperties(RDF.type); model.remove(itr); }
private void disableDefaultMetadata(Resource root) { List<Statement> dd = root.listProperties(ELDA_API.disable_default_metadata).toList(); for (Statement d: dd) { boolean disable = d.getBoolean(); disableDefaultMetadata = disable; } }
public boolean selects(Statement s) { if (s.getObject().isResource()) { return s.getObject().asResource() .equals(SKOS.CONCEPTSCHEME); } else { return false; } } };
private boolean isInstanceOfTheClass(Resource resource, Resource class_resource) { Property type_property = ResourceFactory.createProperty(Namespaces.RDF + "type"); if (resource == null || !resource.isResource()) return true; if (resource.hasProperty(type_property, class_resource)) return true; else return false; }