public SparqlBuilder(ObjectConnection con, SPARQLQuery query) { assert con != null; assert query != null; this.con = con; this.query = query; of = con.getObjectFactory(); }
public SparqlBuilder(ObjectConnection con, SparqlQuery query) { assert con != null; assert query != null; this.con = con; this.query = query; of = con.getObjectFactory(); }
public ObjectCursor(ObjectConnection manager, CloseableIteration<BindingSet, QueryEvaluationException> result, String binding) throws QueryEvaluationException { this.binding = binding; this.result = result; this.next = result.hasNext() ? result.next() : null; this.manager = manager; this.of = manager.getObjectFactory(); }
public ObjectArrayCursor(ObjectConnection manager, TupleQueryResult result, List<String> bindings, Class<?> componentType) throws QueryEvaluationException { this.bindings = bindings; this.result = result; this.next = result.hasNext() ? result.next() : null; this.manager = manager; this.of = manager.getObjectFactory(); this.componentType = componentType; }
public ObjectCursor(ObjectConnection manager, CloseableIteration<BindingSet, QueryEvaluationException> result, String binding) throws QueryEvaluationException { this.binding = binding; this.result = result; this.next = result.hasNext() ? result.next() : null; this.manager = manager; this.of = manager.getObjectFactory(); }
/** * 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); }
public ObjectArrayCursor(ObjectConnection manager, TupleQueryResult result, List<String> bindings, Class<?> componentType) throws QueryEvaluationException { this.bindings = bindings; this.result = result; this.next = result.hasNext() ? result.next() : null; this.manager = manager; this.of = manager.getObjectFactory(); this.componentType = componentType; }
@Override public <T> T createObject(Class<T> clazz, Resource id) throws RepositoryException, IllegalAccessException, InstantiationException { ObjectFactory objectFactory = connection.getObjectFactory(); Resource resource = (id != null) ? id : IDGenerator.BLANK_RESOURCE; T object = objectFactory.createObject(resource, clazz); return connection.addDesignation(object, clazz); }
/** * 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); }
/** * Creates an resource object using the {@link ObjectConnection} provided. * @param clazz The concept of the instance to create. * @param id The ID/URI of the instance to create. * @param <T> The type of the instances concept. * @return The created object. * @throws RepositoryException Thrown if an error occurs while instantiating. */ private <T> T createObject(Class<T> clazz, Resource id) throws RepositoryException { ObjectConnection connection = getConnection(); ObjectFactory objectFactory = connection.getObjectFactory(); Resource resource = (id != null) ? id : IDGenerator.BLANK_RESOURCE; T object = objectFactory.createObject(resource, clazz); return connection.addDesignation(object, clazz); }
/** * Binds the specified variable to the supplied object. Any value that was * previously bound to the specified value will be overwritten. * * @param name * variable name * @param value * datatype or concept implementation */ public void setObject(String name, Object value) { if (value == null) { setBinding(name, null); } else { setBinding(name, manager.getObjectFactory().createValue(value)); } }
/** * Binds the specified variable to the supplied object. Any value that was * previously bound to the specified value will be overwritten. * * @param name * variable name * @param value * datatype or concept implementation */ public void setObject(String name, Object value) { if (value == null) { setBinding(name, null); } else { setBinding(name, manager.getObjectFactory().createValue(value)); } }
protected Object createInstance(Value value) throws RepositoryException { if (value instanceof Resource) return getObjectConnection().getObject((Resource) value); return getObjectConnection().getObjectFactory().createObject( ((Literal) value)); }
protected Object createInstance(Value value) throws RepositoryException { if (value instanceof Resource) return getObjectConnection().getObject((Resource) value); return getObjectConnection().getObjectFactory().createObject( ((Literal) value)); }
/** * Evaluates the query returning a result of a single Object, assumed to * implement the given concept. */ public <T> Result<T> evaluate(Class<T> concept) throws QueryEvaluationException { TupleQueryResult tuple = query.evaluate(); List<String> bindings = tuple.getBindingNames(); if (concept.isArray() && !manager.getObjectFactory().isDatatype(concept)) { ObjectArrayCursor cursor = new ObjectArrayCursor(manager, tuple, bindings, concept.getComponentType()); Result result = new ResultImpl(cursor, concept); return (Result<T>) result; } else { String binding = bindings.get(0); ObjectCursor cursor = new ObjectCursor(manager, tuple, binding); Result result = new ResultImpl(cursor, concept); return (Result<T>) result; } }
private Object createInstance(Value first) { try { if (first instanceof Resource) return getObjectConnection() .getObject((Resource) first); return getObjectConnection().getObjectFactory() .createObject(((Literal) first)); } catch (RepositoryException e) { throw new ObjectStoreException(e); } } };
private Object createInstance(Value first) { try { if (first instanceof Resource) return getObjectConnection() .getObject((Resource) first); return getObjectConnection().getObjectFactory() .createObject(((Literal) first)); } catch (RepositoryException e) { throw new ObjectStoreException(e); } } };
private Object getDefaultValue(String value, Type type, ObjectConnection con) { Class<?> ctype = asClass(type); if (Set.class.equals(ctype)) { Object v = getDefaultValue(value, getComponentType(ctype, type), con); if (v == null) return null; return Collections.singleton(v); } ValueFactory vf = con.getValueFactory(); ObjectFactory of = con.getObjectFactory(); if (of.isDatatype(ctype)) { URIImpl datatype = new URIImpl("java:" + ctype.getName()); return of.createValue(of.createObject(new LiteralImpl(value, datatype))); } return vf.createURI(value); }
/** * Packs the proxies created by the Anno4j instance into a JAR file. * @param commandLine The parsed command line arguments. * @param anno4j The Anno4j instance. * @throws RepositoryException Thrown if an error occurs while querying the repository. * @throws IOException Thrown if an error occurs while writing the JAR file. */ private static void packProxies(CommandLine commandLine, Anno4j anno4j) throws RepositoryException, IOException { ClassFactory factory = anno4j.getObjectRepository().getConnection().getObjectFactory().getResolver().getClassFactory(); JarPacker packer = new JarPacker(new File(getOutputPath(commandLine) + "proxies.jar")); packer.addFile(factory.getOutput()); packer.close(); }
private Object getDefaultValue(String value, Type type, ObjectConnection con) { Class<?> ctype = asClass(type); if (Set.class.equals(ctype)) { Object v = getDefaultValue(value, getComponentType(ctype, type), con); if (v == null) return null; return Collections.singleton(v); } ValueFactory vf = con.getValueFactory(); ObjectFactory of = con.getObjectFactory(); if (of.isDatatype(ctype)) { URIImpl datatype = new URIImpl("java:" + ctype.getName()); return of.createValue(of.createObject(new LiteralImpl(value, datatype))); } return vf.createURI(value); }