/** * Returns a single object that is presumed to have the given rdf:types. */ public Object getObject(Set<URI> types, Resource resource) { Class<?> proxy = of.getObjectClass(resource, types); RDFObject cached = cached(resource); if (cached != null && cached.getClass().equals(proxy)) return cached; return cache(of.createBean(resource, proxy)); }
@Override protected T getNextElement() throws QueryEvaluationException { T next = result.next(); if (next != null) { list.remove(((RDFObject) next).getResource()); return next; } if (!list.isEmpty()) return (T) cache(of.createObject(list.remove(0))); return null; } };
/** * Loads a single Object or converts the literal into an Object. */ public Object getObject(Value value) throws RepositoryException { assert value != null; if (value instanceof Literal) return of.createObject((Literal) value); Resource resource = (Resource) value; RDFObject cached = cached(resource); if (cached != null) return cached; return cache(of.createObject(resource, types.getTypes(resource))); }
/** * Explicitly adds the concept to the entity. * * @return the entity with new composed concept */ public <T> T addDesignation(Object entity, Class<T> concept) throws RepositoryException { if (entity instanceof RDFObjectBehaviour) { RDFObjectBehaviour support = (RDFObjectBehaviour) entity; Object delegate = support.getBehaviourDelegate(); if (delegate != entity) { return addDesignation(delegate, concept); } } Resource resource = findResource(entity); Set<URI> types = new HashSet<URI>(4); getTypes(entity.getClass(), types); addConcept(resource, concept, types); RDFObject bean = of.createObject(resource, types); assert assertConceptRecorded(bean, concept); return (T) cache(bean); }
@SuppressWarnings("unchecked") public <T> T refresh(T object) throws RepositoryException { Resource resource = findResource(object); if (object instanceof Refreshable) { ((Refreshable) object).refresh(); } Set<URI> types = this.types.getTypes(resource); Class<?> proxy = of.getObjectClass(resource, types); RDFObject cached = cached(resource); if (cached != null && cached != object && cached instanceof Refreshable) { ((Refreshable) cached).refresh(); } if (cached != null && cached.getClass().equals(proxy)) return (T) cached; return (T) cache(of.createBean(resource, proxy)); }
return cache(of.createObject(resource, list));