private <C extends Collection<URI>> C addConcept(Resource resource, Class<?> role, C set) throws RepositoryException { URI type = of.getNameOf(role); if (type == null) { throw new ObjectPersistException( "Concept is anonymous or is not registered: " + role.getSimpleName()); } types.addTypeStatement(resource, type); set.add(type); return set; }
/** * Creates an object with an assumed rdf:type. */ public <T> T createObject(Resource resource, Class<T> type) { URI rdftype = getNameOf(type); if (rdftype == null) return type.cast(createObject(resource)); Set<URI> types = Collections.singleton(rdftype); return type.cast(createObject(resource, types)); }
private <C extends Collection<URI>> C addConcept(Resource resource, Class<?> role, C set) throws RepositoryException { URI type = of.getNameOf(role); if (type == null) { throw new ObjectPersistException( "Concept is anonymous or is not registered: " + role.getSimpleName()); } types.addTypeStatement(resource, type); set.add(type); return set; }
private <C extends Collection<URI>> C getTypes(Class<?> role, C set) throws RepositoryException { URI type = of.getNameOf(role); if (type == null) { Class<?> superclass = role.getSuperclass(); if (superclass != null) { getTypes(superclass, set); } Class<?>[] interfaces = role.getInterfaces(); for (int i = 0, n = interfaces.length; i < n; i++) { getTypes(interfaces[i], set); } } else { set.add(type); } return set; }
private <C extends Collection<URI>> C getTypes(Class<?> role, C set) throws RepositoryException { URI type = of.getNameOf(role); if (type == null) { Class<?> superclass = role.getSuperclass(); if (superclass != null) { getTypes(superclass, set); } Class<?>[] interfaces = role.getInterfaces(); for (int i = 0, n = interfaces.length; i < n; i++) { getTypes(interfaces[i], set); } } else { set.add(type); } return set; }
/** * Binds the specified variable to the supplied concept. Any value that was * previously bound to the specified value will be overwritten. * * @param name * variable name * @param concept * a registered concept class or interface */ public void setType(String name, Class<?> concept) { URI type = manager.getObjectFactory().getNameOf(concept); if (concept != null && type == null) throw new IllegalArgumentException("Not a registered concept: " + concept); setBinding(name, type); }
/** * Binds the specified variable to the supplied concept. Any value that was * previously bound to the specified value will be overwritten. * * @param name * variable name * @param concept * a registered concept class or interface */ public void setType(String name, Class<?> concept) { URI type = manager.getObjectFactory().getNameOf(concept); if (concept != null && type == null) throw new IllegalArgumentException("Not a registered concept: " + concept); setBinding(name, type); }
/** * Explicitly removes the concept from the entity. */ public void removeDesignation(Object entity, Class<?> concept) throws RepositoryException { Resource resource = findResource(entity); URI type = of.getNameOf(concept); if (type == null) { throw new ObjectPersistException( "Concept is anonymous or is not registered: " + concept.getSimpleName()); } types.removeTypeStatement(resource, type); cachedObjects.remove(resource); }
/** * Creates an object with an assumed rdf:type. */ public <T> T createObject(Resource resource, Class<T> type) { RDFObject obj; URI rdftype = getNameOf(type); if (rdftype == null) { obj = createObject(resource); } else { Set<URI> types = Collections.singleton(rdftype); obj = createObject(resource, types); } try { return type.cast(obj); } catch (ClassCastException e) { String msg = "Cannot cast resource " + obj + " to a " + type.getName(); ClassCastException cce = new ClassCastException(msg); cce.initCause(e); throw cce; } }
/** * Explicitly removes the concept from the entity. */ public void removeDesignation(Object entity, Class<?> concept) throws RepositoryException { Resource resource = findResource(entity); URI type = of.getNameOf(concept); if (type == null) { throw new ObjectPersistException( "Concept is anonymous or is not registered: " + concept.getSimpleName()); } types.removeTypeStatement(resource, type); }
URI uri = getNameOf(concept); boolean typed = uri != null && bindings == 0; if (typed) {
URI uri = getNameOf(concept); boolean isTopConcept = concept.isAssignableFrom(topConcept);
/** * Converts an object into a literal or resource. */ public Value createValue(Object instance) { if (instance instanceof RDFObjectBehaviour) { RDFObjectBehaviour support = (RDFObjectBehaviour) instance; Object entity = support.getBehaviourDelegate(); if (entity != instance) return createValue(entity); } if (instance instanceof RDFObject) return ((RDFObject) instance).getResource(); if (instance instanceof Class<?>) { URI type = getNameOf((Class<?>) instance); if (type != null) return type; } return lm.createLiteral(instance); }
/** * Converts an object into a literal or resource. */ public Value createValue(Object instance) { if (instance instanceof RDFObjectBehaviour) { RDFObjectBehaviour support = (RDFObjectBehaviour) instance; Object entity = support.getBehaviourDelegate(); if (entity != instance) return createValue(entity); } if (instance instanceof RDFObject) return ((RDFObject) instance).getResource(); if (instance instanceof Class<?>) { URI type = getNameOf((Class<?>) instance); if (type != null) return type; } return lm.createLiteral(instance); }
URI rootType = connection.getObjectFactory().getNameOf(type); if (rootType == null) { throw new IllegalArgumentException("Can't query for: " + type + " not found in name map. Is @Iri annotation set?");