/** * Constructs a new instance of this class. * @param dbName The database name. * @param createDbIfNotExist To create a new database if it does not already exist. * @param protocol The protocol to use (i.e http or https) * @param host The database host address * @param port The database listening port * @param username The Username credential * @param password The Password credential */ public CouchDbClient(String dbName, boolean createDbIfNotExist, String protocol, String host, int port, String username, String password) { super(new CouchDbConfig(new CouchDbProperties(dbName, createDbIfNotExist, protocol, host, port, username, password))); }
/** * Constructs a new client instance. * @param dbName The database name. * @param createDbIfNotExist To create a new database if it does not already exist. * @param protocol The protocol to use (i.e http or https) * @param host The database host address * @param port The database listening port * @param username The Username credential * @param password The Password credential */ public CouchDbClientAndroid(String dbName, boolean createDbIfNotExist, String protocol, String host, int port, String username, String password) { super(new CouchDbConfig(new CouchDbProperties(dbName, createDbIfNotExist, protocol, host, port, username, password))); }
private static CouchDbProperties props(String dbname) { return new CouchDbProperties(dbname, true, CouchDbConfig.INSTANCE.getProtocol(), CouchDbConfig.INSTANCE.getHost(), CouchDbConfig.INSTANCE.getPort(), null, null); } }
private void readProperties() { try { // required dbProperties = new CouchDbProperties(); dbProperties.setDbName(getProperty("couchdb.name", true)); dbProperties.setCreateDbIfNotExist(new Boolean(getProperty("couchdb.createdb.if-not-exist", true))); dbProperties.setProtocol(getProperty("couchdb.protocol", true)); dbProperties.setHost(getProperty("couchdb.host", true)); dbProperties.setPort(Integer.parseInt(getProperty("couchdb.port", true))); dbProperties.setUsername(getProperty("couchdb.username", true)); dbProperties.setPassword(getProperty("couchdb.password", true)); // optional dbProperties.setPath(getProperty("couchdb.path", false)); dbProperties.setSocketTimeout(getPropertyAsInt("couchdb.http.socket.timeout", false)); dbProperties.setConnectionTimeout(getPropertyAsInt("couchdb.http.connection.timeout", false)); dbProperties.setMaxConnections(getPropertyAsInt("couchdb.max.connections", false)); dbProperties.setProxyHost(getProperty("couchdb.proxy.host", false)); dbProperties.setProxyPort(getPropertyAsInt("couchdb.proxy.port", false)); } catch (Exception e) { throw new IllegalStateException(e); } properties = null; }