|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.exist.fluent.Database
public class Database
The global entry point to an embedded instance of the eXist database. The static methods on this class control the lifecycle of the database connection. It follows that there can be only one embedded database running in the JVM (or rather one per classloader, but that would probably be a bit confusing). To gain access to the contents of the database, you need to acquire a handle instance by logging in. All operations performed based on that instance will be executed using the permissions of the user associated with that instance. You can have any number of instances (including multiple ones for the same user), but cannot mix resources obtained from different instances. There is no need to explicitly release instances.
Here's a short example of how to start up the database, perform a query, and shut down:
Database.startup(new File("conf.xml")); Database db = Database.login("admin", null); for (String name : db.getFolder("/").query().all("//user/@name").values()) System.out.println("user: " + name); Database.shutdown();
Field Summary | |
---|---|
static String |
ROOT_PREFIX
|
Method Summary | |
---|---|
ItemList |
adopt(Node node)
|
static boolean |
checkConsistency()
Verify the internal consistency of the database's data structures. |
boolean |
contains(String path)
Check whether the database contains a document or a folder with the given absolute path. |
Folder |
createFolder(String path)
Create the folder for the given path. |
static void |
ensureStarted(File configFile)
Deprecated. Please use a combination of isStarted() and startup(File) . |
static void |
flush()
Flush the contents of the database to disk. |
Document |
getDocument(String path)
Get the document for the given absolute path. |
Folder |
getFolder(String path)
Get the folder for the given path. |
static boolean |
isStarted()
Return whether the database has been started and is currently running in this JVM. |
static Database |
login(String username,
String password)
Login to obtain access to the database. |
NamespaceMap |
namespaceBindings()
Return the namespace bindings for this database instance. |
QueryService |
query(Collection<? extends Resource> context)
Return a query service that runs queries over the given list of resources. |
QueryService |
query(Resource... context)
Return a query service that runs queries over the given list of resources. |
static void |
remove(Listener listener)
Remove the given listener from all trigger points on all sources. |
void |
setDefaultCharacterEncoding(String encoding)
Set the default character encoding to be used when exporting XML files from the database. |
void |
setDefaultExportEncoding(String encoding)
Deprecated. Renamed to setDefaultCharacterEncoding(String) . |
static void |
shutdown()
Shut down the database connection. |
static void |
startup(File configFile)
Start up the database, configured using the given config file. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ROOT_PREFIX
Method Detail |
---|
public static void startup(File configFile)
configFile
- the config file that specifies the database to use
IllegalStateException
- if the database has already been startedpublic static void shutdown()
@Deprecated public static void ensureStarted(File configFile)
isStarted()
and startup(File)
.
configFile
- the config file that specifies the database to use
IllegalStateException
- if the database was already started with a different config filepublic static boolean isStarted()
startup(File)
or ensureStarted(File)
was previously called
successfully and shutdown()
was not yet called.
true
if the database has been started with any configuration filepublic static void flush()
public static boolean checkConsistency()
true
if the database's internal data structures are consistent,
false
if the database is corruptedpublic static Database login(String username, String password)
null
.
Note that all newly created databases have a user admin
with no password set.
username
- the username of the user being logged inpassword
- the password corresponding to that user name, or null
if none
DatabaseException
- if the user could not be logged inpublic static void remove(Listener listener)
listener
- the listener to remove@Deprecated public void setDefaultExportEncoding(String encoding)
setDefaultCharacterEncoding(String)
.
public void setDefaultCharacterEncoding(String encoding)
encoding
- public NamespaceMap namespaceBindings()
public ItemList adopt(Node node)
public boolean contains(String path)
path
- the absolute path of the document or folder to check
true
if there is a document or folder at the given path, false
otherwisepublic Document getDocument(String path)
path
- the absolute path of the desired document
DatabaseException
- if the document is not found or something else goes wrongpublic Folder getFolder(String path)
path
- the address of the desired collection
DatabaseException
- if the path does not identify a valid collectionpublic Folder createFolder(String path)
path
- the address of the desired collection
public QueryService query(Resource... context)
context
- the arbitrary collection of database objects over which to query
public QueryService query(Collection<? extends Resource> context)
context
- the arbitrary collection of database objects over which to query;
the collection is not copied, and the collection's contents are re-read every time the query is performed
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |