All pastes #9256 Raw Edit

Jena listInstances

public text v1 · immutable
#9256 ·published 2005-04-10 17:06 UTC
rendered paste body
This is showing the expected results:

    public Vector getShops(){
        Vector out = new Vector();
        logger.debug("Getting shops in " + this.name);

        ResIterator iter = model.listSubjectsWithProperty(RPG.isLocatedIn);
        while (iter.hasNext()){
            Resource tmp = iter.nextResource();
            logger.debug("Adding " + tmp);
            out.add(new ShopImpl(tmp.getURI()));
        }
        return out;
    }

This does not

    public Vector getShops(){
        Vector out = new Vector();
        logger.debug("Getting shops in " + this.name);

        OntClass shopClass = model.getOntClass(RPG.Shop.getURI());
        Iterator shopIter = shopClass.listInstances();
        while (shopIter.hasNext()){
            Individual tmp = (Individual)shopIter.next();
            logger.debug("Adding " + tmp);
            out.add(new ShopImpl(tmp.getURI()));
            tmp = null;
        }
        return out;
    }


The second verion lists a lot of instances that do not exist.
I would like to know why!