public final class Manager
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static ManagerOptions |
DEFAULT_OPTIONS |
static java.lang.String |
FORESTDB_STORAGE |
protected static java.lang.String |
kDBExtension |
protected static java.lang.String |
kV1DBExtension |
static java.lang.String |
LEGAL_CHARACTERS |
static java.lang.String |
PRODUCT_NAME |
static java.lang.String |
SQLITE_STORAGE |
static java.lang.String |
USER_AGENT |
static java.lang.String |
VERSION |
| Constructor and Description |
|---|
Manager()
Constructor
|
Manager(Context context,
ManagerOptions options)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Collection<Database> |
allOpenDatabases() |
void |
close()
Releases all resources used by the Manager instance and closes all its databases.
|
static void |
enableLogging(java.lang.String tag,
int logLevel)
Enable logging for a particular tag / loglevel combo
|
protected void |
forgetDatabase(Database db) |
java.util.List<java.lang.String> |
getAllDatabaseNames()
An array of the names of all existing databases.
|
Context |
getContext() |
Database |
getDatabase(java.lang.String name)
Returns the database with the given name, or creates it if it doesn't exist.
|
Database |
getDatabase(java.lang.String name,
boolean mustExist)
Instantiates a database but doesn't open the file yet.
|
HttpClientFactory |
getDefaultHttpClientFactory() |
java.io.File |
getDirectory()
The root directory of this manager (as specified at initialization time.)
|
java.util.Map<java.lang.String,java.lang.Object> |
getEncryptionKeys() |
int |
getExecutorThreadPoolSize() |
Database |
getExistingDatabase(java.lang.String name)
Returns the database with the given name, or null if it doesn't exist.
|
static java.lang.String |
getFullVersionInfo() |
static ObjectMapper |
getObjectMapper() |
Replication |
getReplicator(java.util.Map<java.lang.String,java.lang.Object> properties) |
static Manager |
getSharedInstance()
Get shared instance
|
java.lang.String |
getStorageType()
Get the default storage type.
|
static java.lang.String |
getUserAgent()
Return User-Agent value
Format: ex: CouchbaseLite/1.2 (Java Linux/MIPS 1.2.1/3382EFA)
|
java.util.concurrent.ScheduledExecutorService |
getWorkExecutor() |
protected boolean |
isAutoMigrateBlobStoreFilename() |
static boolean |
isValidDatabaseName(java.lang.String databaseName)
Returns YES if the given name is a valid database name.
|
Database |
openDatabase(java.lang.String name,
DatabaseOptions options)
Returns the database with the given name.
|
boolean |
registerEncryptionKey(java.lang.Object keyOrPassword,
java.lang.String databaseName)
This method has been superseded by
openDatabase(String, DatabaseOptions). |
void |
replaceDatabase(java.lang.String databaseName,
java.io.InputStream databaseStream,
java.util.Map<java.lang.String,java.io.InputStream> attachmentStreams)
Replaces or installs a database from a file.
|
boolean |
replaceDatabase(java.lang.String databaseName,
java.lang.String databaseDir)
Replaces or installs a database from a file.
|
protected java.util.concurrent.Future |
runAsync(java.lang.Runnable runnable) |
java.util.concurrent.Future |
runAsync(java.lang.String databaseName,
AsyncTask function)
Asynchronously dispatches a callback to run on a background thread.
|
void |
setDefaultHttpClientFactory(HttpClientFactory defaultHttpClientFactory) |
void |
setStorageType(java.lang.String storageType)
Set default storage engine type for newly-created databases.
|
public static final java.lang.String PRODUCT_NAME
protected static final java.lang.String kV1DBExtension
protected static final java.lang.String kDBExtension
public static final ManagerOptions DEFAULT_OPTIONS
public static final java.lang.String LEGAL_CHARACTERS
public static java.lang.String USER_AGENT
public static final java.lang.String SQLITE_STORAGE
public static final java.lang.String FORESTDB_STORAGE
public static final java.lang.String VERSION
public Manager()
java.lang.UnsupportedOperationException - - not currently supportedpublic Manager(Context context, ManagerOptions options) throws java.io.IOException
java.lang.SecurityException - - Runtime exception that can be thrown by File.mkdirs()java.io.IOExceptionpublic static Manager getSharedInstance()
java.lang.UnsupportedOperationException - - not currently supportedpublic java.lang.String getStorageType()
public void setStorageType(java.lang.String storageType)
storageType - public static void enableLogging(java.lang.String tag,
int logLevel)
tag - Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.logLevel - The loglevel to enable. Anything matching this loglevel
or having a more urgent loglevel will be emitted. Eg, Log.VERBOSE.public static boolean isValidDatabaseName(java.lang.String databaseName)
public java.util.List<java.lang.String> getAllDatabaseNames()
public java.io.File getDirectory()
public void close()
public Database getDatabase(java.lang.String name) throws CouchbaseLiteException
Returns the database with the given name, or creates it if it doesn't exist.
Multiple calls with the same name will return the same Database instance.
This is equivalent to calling openDatabase(String, DatabaseOptions)
with a default set of options with the `Create` flag set.
NOTE: Database names may not contain capital letters.
CouchbaseLiteExceptionpublic Database getExistingDatabase(java.lang.String name) throws CouchbaseLiteException
Returns the database with the given name, or null if it doesn't exist.
Multiple calls with the same name will return the same Database instance.
This is equivalent to calling openDatabase(String, DatabaseOptions)
with a default set of options.
CouchbaseLiteExceptionpublic Database openDatabase(java.lang.String name, DatabaseOptions options) throws CouchbaseLiteException
Database instance.name - The name of the database. May NOT contain capital letters!options - Options to use when opening, such as the encryption key; if null, a default
set of options will be used.CouchbaseLiteException - thrown when there is an error.public boolean registerEncryptionKey(java.lang.Object keyOrPassword,
java.lang.String databaseName)
openDatabase(String, DatabaseOptions).
Registers an encryption key for a database. This must be called _before_ opening an encrypted
database, or before creating a database that's to be encrypted.
If the key is incorrect (or no key is given for an encrypted database), the subsequent call
to open the database will fail with an error with code 401.
To use this API, the database storage engine must support encryption, and the
ManagerOptions.EnableStorageEncryption property must be set to true. Otherwise opening
the database will fail with an error.keyOrPassword - The encryption key in the form of an String (a password) or an
byte[] object exactly 32 bytes in length (a raw AES key.)
If a string is given, it will be internally converted to a raw key
using 64,000 rounds of PBKDF2 hashing.
A null value is legal, and clears a previously-registered key.databaseName - The name of the database.public void replaceDatabase(java.lang.String databaseName,
java.io.InputStream databaseStream,
java.util.Map<java.lang.String,java.io.InputStream> attachmentStreams)
throws CouchbaseLiteException
databaseName - The name of the target Database to replace or create.databaseStream - InputStream on the source Database file.attachmentStreams - Map of the associated source Attachments, or null if there are no attachments.
The Map key is the name of the attachment, the map value is an InputStream for
the attachment contents. If you wish to control the order that the attachments
will be processed, use a LinkedHashMap, SortedMap or similar and the iteration order
will be honoured.CouchbaseLiteExceptionpublic boolean replaceDatabase(java.lang.String databaseName,
java.lang.String databaseDir)
databaseName - The name of the database to replace.databaseDir - Path of the database directory that should replace it.public static ObjectMapper getObjectMapper()
public HttpClientFactory getDefaultHttpClientFactory()
public void setDefaultHttpClientFactory(HttpClientFactory defaultHttpClientFactory)
public java.util.Collection<Database> allOpenDatabases()
public java.util.Map<java.lang.String,java.lang.Object> getEncryptionKeys()
public java.util.concurrent.Future runAsync(java.lang.String databaseName,
AsyncTask function)
throws CouchbaseLiteException
CouchbaseLiteExceptionpublic Database getDatabase(java.lang.String name, boolean mustExist)
public Replication getReplicator(java.util.Map<java.lang.String,java.lang.Object> properties) throws CouchbaseLiteException
CouchbaseLiteExceptionpublic java.util.concurrent.ScheduledExecutorService getWorkExecutor()
public Context getContext()
public int getExecutorThreadPoolSize()
protected java.util.concurrent.Future runAsync(java.lang.Runnable runnable)
protected void forgetDatabase(Database db)
protected boolean isAutoMigrateBlobStoreFilename()
public static java.lang.String getUserAgent()
public static java.lang.String getFullVersionInfo()