Package org.openrdf.model.impl

Examples of org.openrdf.model.impl.TreeModel


    /**
     * Test related to STANBOL-698
     */
    @Test
    public void testDouble(){
        Model graph = new TreeModel();
        URI id = vf.createURI("http://www.example.org/test");
        URI doubleTestField = vf.createURI("http://www.example.org/field/double");
        graph.add(id, doubleTestField, vf.createLiteral(Double.NaN));
        graph.add(id, doubleTestField, vf.createLiteral(Double.POSITIVE_INFINITY));
        graph.add(id, doubleTestField, vf.createLiteral(Double.NEGATIVE_INFINITY));
       
        RdfValueFactory valueFactory = new RdfValueFactory(graph,vf);
        Representation r = valueFactory.createRepresentation(id.stringValue());
        Set<Double> expected = new HashSet<Double>(Arrays.asList(
            Double.NaN, Double.POSITIVE_INFINITY,Double.NEGATIVE_INFINITY));
View Full Code Here


        Assert.assertTrue(expected.isEmpty());
    }
   
    @Test
    public void testFloat(){
        Model graph = new TreeModel();
        URI id = vf.createURI("http://www.example.org/test");
        URI floatTestField = vf.createURI("http://www.example.org/field/float");
        graph.add(id, floatTestField, vf.createLiteral(Float.NaN));
        graph.add(id, floatTestField, vf.createLiteral(Float.POSITIVE_INFINITY));
        graph.add(id, floatTestField, vf.createLiteral(Float.NEGATIVE_INFINITY));
       
        RdfValueFactory valueFactory = new RdfValueFactory(graph,vf);
        Representation r = valueFactory.createRepresentation(id.stringValue());
        Set<Float> expected = new HashSet<Float>(Arrays.asList(
            Float.NaN, Float.POSITIVE_INFINITY,Float.NEGATIVE_INFINITY));
View Full Code Here

                getConfig().getMaxQueryResultNumber());
            results = executeSparqlFieldQuery(con,query, limit, false);
            //parse the results and generate the Representations
            //create an own valueFactors so that all the data of the query results
            //are added to the same Sesame Model
            Model model = new TreeModel();
            RdfValueFactory valueFactory = new RdfValueFactory(model, sesameFactory);
            List<Representation> representations = limit > 0 ?
                    new ArrayList<Representation>(limit) : new ArrayList<Representation>();
            while(results.hasNext()){
                BindingSet result = results.next();
                Value value = result.getValue(query.getRootVariableName());
                if(value instanceof URI){
                    //copy all data to the model and create the representation
                    RdfRepresentation rep = createRepresentationGraph(con, valueFactory, (URI)value);
                    model.add(queryRoot, queryResult, value); //link the result with the query result
                    representations.add(rep);
                } //ignore non URI results
            }
            con.commit();
            return new SesameQueryResultList(model, query, representations);
View Full Code Here

                getConfig().getMaxQueryResultNumber());
            results = executeSparqlFieldQuery(con,query, limit, true);
            //parse the results and generate the Representations
            //create an own valueFactors so that all the data of the query results
            //are added to the same Sesame Model
            Model model = new TreeModel();
            RdfValueFactory valueFactory = new RdfValueFactory(model, sesameFactory);
            List<Representation> representations = limit > 0 ? new ArrayList<Representation>(limit)
                    : new ArrayList<Representation>();
            Map<String,URI> bindings = new HashMap<String,URI>(query.getFieldVariableMappings().size());
            for(Entry<String,String> mapping : query.getFieldVariableMappings().entrySet()){
                bindings.put(mapping.getValue(), sesameFactory.createURI(mapping.getKey()));
            }
            while(results.hasNext()){
                BindingSet result = results.next();
                Value value = result.getValue(query.getRootVariableName());
                if(value instanceof URI){
                    URI subject = (URI) value;
                    //link the result with the query result
                    model.add(queryRoot, queryResult, subject);
                    //now copy over the other selected data
                    for(String binding : result.getBindingNames()){
                        URI property = bindings.get(binding);
                        if(property != null){
                            model.add(subject, property, result.getValue(binding));
                        } //else no mapping for the query.getRootVariableName()
                    }
                    //create a representation and add it to the results
                    representations.add(valueFactory.createRdfRepresentation(subject));
                } //ignore non URI results
View Full Code Here

     * Creates a {@link RdfRepresentation} for the parsed {@link URI}
     * @param subject the URI
     * @return the {@link RdfRepresentation}
     */
    public RdfRepresentation createRdfRepresentation(URI subject) {
        Model model = this.model == null ? new TreeModel() : this.model;
        return new RdfRepresentation(subject, model, this);
    }
View Full Code Here

                if(ce != null) {
                    SailConnection con = store.getConnection();
                    try {
                        con.begin();

                        Model triples = new TreeModel();
                        ModelCommons.add(triples,con.getStatements(resource,null,null,true,store.getValueFactory().createURI(cacheContext)));
                        ce.setTriples(triples);

                        con.commit();
                    } catch(SailException ex) {
View Full Code Here

        public ResponseHandler(String resource, Endpoint endpoint) throws RepositoryException {
            this.resource = resource;
            this.endpoint = endpoint;

            triples = new TreeModel();
        }
View Full Code Here

     * @throws java.io.IOException            if an I/O error occurs
     * @throws ClassNotFoundException if a class could not be found
     */
    @Override
    public TreeModel readObject(ObjectInput input) throws IOException, ClassNotFoundException {
        TreeModel model = new TreeModel();

        int size = input.readInt();
        for(int i=0; i<size; i++) {
            Resource subject = (Resource) input.readObject();
            URI predicate = (URI) input.readObject();
            Value object = (Value) input.readObject();

            boolean hasContext = input.readBoolean();
            if(hasContext) {
                Resource context = (Resource) input.readObject();

                model.add(new ContextStatementImpl(subject,predicate,object,context));
            } else {
                model.add(new StatementImpl(subject,predicate,object));
            }
        }

        return null;
    }
View Full Code Here

    public DummyLoaderHandler() {
        this(0);
    }

    public DummyLoaderHandler(long methodSleep) {
        model = new TreeModel();
        sleep = methodSleep;
    }
View Full Code Here

                    newEntry.setUpdateCount(entry.getUpdateCount()+1);
                } else {
                    newEntry.setUpdateCount(1);
                }
                newEntry.setTripleCount(0);
                newEntry.setTriples(new TreeModel());

                backend.putEntry(resource, newEntry);

            } finally {
                this.lock.readLock().unlock();
View Full Code Here

TOP

Related Classes of org.openrdf.model.impl.TreeModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.