org.exist.storage
Class NativeBroker

java.lang.Object
  extended byjava.util.Observable
      extended byorg.exist.storage.DBBroker
          extended byorg.exist.storage.NativeBroker
Direct Known Subclasses:
NativeClusterBroker

public class NativeBroker
extends DBBroker

Main class for the native XML storage backend. By "native" it is meant file-based, embedded backend. Provides access to all low-level operations required by the database. Extends DBBroker. Observer Design Pattern: role : this class is the subject (alias observable) for various classes that generate indices for the database content :

Author:
Wolfgang Meier

Nested Class Summary
static class NativeBroker.NodeRef
           
 
Field Summary
static int BUFFERS
          default buffer size setting
static java.lang.String COLLECTIONS_DBX
           
static byte COLLECTIONS_DBX_ID
           
protected  CollectionStore collectionsDb
          the database files
protected  java.lang.String dataDir
           
protected  BFile dbWords
           
 java.lang.String DEFAULT_DATA_DIR
           
 int DEFAULT_INDEX_DEPTH
           
 int DEFAULT_MIN_MEMORY
           
static int DEFAULT_NODES_BEFORE_MEMORY_CHECK
          check available memory after storing DEFAULT_NODES_BEFORE_MEMORY_CHECK nodes
 int DEFAULT_PAGE_SIZE
           
 double DEFAULT_VALUE_CACHE_GROWTH
           
 double DEFAULT_VALUE_KEY_THRESHOLD
           
 double DEFAULT_VALUE_VALUE_THRESHOLD
           
 double DEFAULT_WORD_CACHE_GROWTH
           
 double DEFAULT_WORD_KEY_THRESHOLD
           
 double DEFAULT_WORD_VALUE_THRESHOLD
           
protected  int defaultIndexDepth
           
static java.lang.String DOM_DBX
           
static byte DOM_DBX_ID
           
protected  DOMFile domDb
           
protected  NativeElementIndex elementIndex
           
static java.lang.String ELEMENTS_DBX
           
static byte ELEMENTS_DBX_ID
           
protected  BFile elementsDb
           
protected  IndexSpec idxConf
           
protected  int memMinFree
           
protected  int nodesCount
          used to count the nodes inserted after the last memory check
protected  int pageSize
           
protected  NativeValueIndexByQName qnameValueIndex
           
protected  boolean readOnly
           
static long TEMP_FRAGMENT_TIMEOUT
           
protected  NativeTextEngine textEngine
          the index processors
protected  NativeValueIndex valueIndex
           
static java.lang.String VALUES_DBX
           
static byte VALUES_DBX_ID
           
static java.lang.String VALUES_QNAME_DBX
           
static byte VALUES_QNAME_DBX_ID
           
protected  BFile valuesDb
           
protected  BFile valuesDbQname
           
static java.lang.String WORDS_DBX
           
static byte WORDS_DBX_ID
           
protected  Serializer xmlSerializer
           
 
Fields inherited from class org.exist.storage.DBBroker
caseSensitive, config, docFragmentationLimit, id, MATCH_EXACT, MATCH_REGEXP, MATCH_WILDCARDS, NATIVE, NATIVE_CLUSTER, pool, ROOT_COLLECTION, ROOT_COLLECTION_NAME, symbols, symbolsFile, SYSTEM_COLLECTION, TEMP_COLLECTION, user, xqueryService, xupdateConsistencyChecks, xupdateGrowthFactor
 
Constructor Summary
NativeBroker(BrokerPool pool, Configuration config)
          initialize database; read configuration, etc.
 
Method Summary
 void addContentLoadingObserver(ContentLoadingObserver observer)
          Observer Design Pattern: add an observer.
 void addObserver(java.util.Observer o)
           
 void checkXMLResourceConsistency(DocumentImpl doc)
          consistency Check of the database; useful after XUpdates; called if xupdate.consistency-checks is true in configuration
 void checkXMLResourceTree(DocumentImpl doc)
          consistency Check of the database; useful after XUpdates; called by #checkResourceConsistency()
 void cleanUpTempCollection()
          remove temporary collection
 void cleanUpTempResources()
          remove all documents from temporary collection
 void cleanUpTempResources(java.util.List docs)
          remove from the temporary collection of the database a given list of Documents.
 void clearContentLoadingObservers()
          Remove all observers
 void closeDocument()
           
 void copyCollection(Txn transaction, Collection collection, Collection destination, java.lang.String newName)
          Copy a collection to the destination collection and rename it.
 void copyXMLResource(Txn transaction, DocumentImpl doc, Collection destination, java.lang.String newName)
          Copy a resource to the destination collection and rename it.
 void defragXMLResource(Txn transaction, DocumentImpl doc)
          Defragment pages of this document.
 void deleteObservers()
           
 void dropCollectionIndex(Collection collection)
           
 void endElement(StoredNode node, NodePath currentPath, java.lang.String content, long oldAddress)
          Update indexes for the given element node.
 void endRemove()
          Takes care of actually remove entries from the indices; must be called after one or more call to #removeNode().
 void flush()
          Flush all data that has not been written before.
protected  void freeCollectionId(Txn transaction, short id)
          Release the collection id assigned to a collection so it can be reused later.
protected  void freeResourceId(Txn transaction, int id)
          Release the document id reserved for a document so it can be reused.
 DocumentSet getAllXMLResources(DocumentSet docs)
          Adds all the documents in the database to the specified DocumentSet.
 int getBackendType()
           
 byte[] getBinaryResource(BinaryDocument blob)
          Retrieve the binary data stored under the resource descriptor BinaryDocument.
 Collection getCollection(java.lang.String name)
          Returns the database collection identified by the specified path.
 Collection getCollection(java.lang.String name, long addr)
          Returns the database collection identified by the specified path.
 void getCollectionResources(Collection collection)
           
 DOMFile getDOMFile()
           
 java.util.Iterator getDOMIterator(NodeProxy proxy)
          Return a DOMFileIterator starting at the specified node.
 ElementIndex getElementIndex()
           
 short getFreeCollectionId(Txn transaction)
          Get the next free collection id.
 int getFreeResourceId(Txn transaction)
          Get the next unused document id.
 IndexSpec getIndexConfiguration()
           
 short getNextCollectionId(Txn transaction)
          Get the next available unique collection id.
 int getNextResourceId(Txn transaction, Collection collection)
          get next Free Doc Id
 java.util.Iterator getNodeIterator(NodeProxy proxy)
          Return a NodeIterator starting at the specified node.
 org.w3c.dom.NodeList getNodeRange(org.w3c.dom.Document doc, long first, long last)
          Get a range of nodes with given owner document from the database, starting at first and ending at last.
 NodeSet getNodesEqualTo(NodeSet context, DocumentSet docs, int relation, int truncation, java.lang.String expr, java.text.Collator collator)
          Find all Nodes whose string value is equal to expr in the document set.
 java.lang.String getNodeValue(NodeProxy proxy, boolean addWhitespace)
          Get the string value of the specified node.
 Collection getOrCreateCollection(Txn transaction, java.lang.String name)
          Returns the database collection identified by the specified path.
 int getPageSize()
           
 NativeValueIndexByQName getQNameValueIndex()
           
 void getResourceMetadata(DocumentImpl doc)
           
 Serializer getSerializer()
          Get an instance of the Serializer used for converting nodes back to XML.
 BTree getStorage(byte id)
           
 byte[] getStorageFileIds()
           
 TextSearchEngine getTextEngine()
          Get the TextSearchEngine associated with this broker.
 NativeValueIndex getValueIndex()
           
 org.w3c.dom.Document getXMLResource(java.lang.String fileName)
          get a document by its file name.
 DocumentImpl getXMLResource(java.lang.String fileName, int lockMode)
           
 DocumentSet getXMLResourcesByDoctype(java.lang.String doctypeName, DocumentSet result)
          get all the documents in this database matching the given document-type's name.
 void indexNode(Txn transaction, StoredNode node, NodePath currentPath)
          Index a single node, which has been added through an XUpdate operation.
 void indexNode(Txn transaction, StoredNode node, NodePath currentPath, boolean repairMode)
           
 void insertNodeAfter(Txn transaction, StoredNode previous, StoredNode node)
          Physically insert a node into the DOM storage.
 boolean isReadOnly()
          Is the database running read-only? Returns false by default.
 void moveCollection(Txn transaction, Collection collection, Collection destination, java.lang.String newName)
          Move a collection and all its subcollections to another collection and rename it.
 void moveXMLResource(Txn transaction, DocumentImpl doc, Collection destination, java.lang.String newName)
          move Resource to another collection, with possible rename
 Serializer newSerializer()
           
 org.w3c.dom.Node objectWith(org.w3c.dom.Document doc, long gid)
          Get a node with given owner document and id from the database.
 org.w3c.dom.Node objectWith(NodeProxy p)
           
 Collection openCollection(java.lang.String name, int lockMode)
          Open a collection for reading or writing.
 Collection openCollection(java.lang.String name, long addr, int lockMode)
          Get collection object.
 void reindexCollection(Collection collection, boolean repairMode)
           
 void reindexCollection(java.lang.String collectionName)
          Reindex a collection.
 void reindexCollection(Txn transaction, Collection collection, boolean repairMode)
           
 void reindexXMLResource(Txn transaction, DocumentImpl oldDoc, DocumentImpl doc, StoredNode node)
          Reindex the nodes in the document.
 void removeAllNodes(Txn transaction, StoredNode node, NodePath currentPath)
           
 void removeBinaryResource(Txn transaction, BinaryDocument blob)
          Completely delete this binary document (descriptor and binary data).
 boolean removeCollection(Txn transaction, Collection collection)
          Remove the collection and all its subcollections from the database.
 void removeContentLoadingObserver(ContentLoadingObserver observer)
          Observer Design Pattern: remove an observer.
 void removeNode(Txn transaction, StoredNode node, NodePath currentPath, java.lang.String content)
          Removes the Node Reference from the database.
 void removeXMLResource(Txn transaction, DocumentImpl document, boolean freeDocId)
           
 void repair()
           
 void saveCollection(Txn transaction, Collection collection)
          Saves the specified collection to storage.
protected  NodeSet scanNodesSequential(NodeSet context, DocumentSet doc, int relation, int truncation, java.lang.String expr, java.text.Collator collator)
          Do a sequential search through the DOM-file.
 void shutdown()
          Shut down the database instance.
 void storeBinaryResource(Txn transaction, BinaryDocument blob, byte[] data)
          Stores the given data under the given binary resource descriptor (BinaryDocument).
 void storeNode(Txn transaction, StoredNode node, NodePath currentPath, boolean index)
          Store a node into the database.
 DocumentImpl storeTempResource(DocumentImpl doc)
          store into the temporary collection of the database a given in-memory Document
 void storeXMLResource(Txn transaction, DocumentImpl doc)
          store Document entry into its collection.
 void sync(int syncEvent)
          Sync dom and collection state data (pages) to disk.
 void updateNode(Txn transaction, StoredNode node)
          Update a node's data.
 
Methods inherited from class org.exist.storage.DBBroker
backupSymbolsTo, consistencyChecksEnabled, decReferenceCount, endElement, getBrokerPool, getConfiguration, getDOMIterator, getFragmentationLimit, getId, getReferenceCount, getSymbols, getUser, getXQueryService, getXUpdateGrowthFactor, incReferenceCount, indexNode, isCaseSensitive, loadSymbols, removeXMLResource, saveSymbols, setId, setUser, storeNode, toString
 
Methods inherited from class java.util.Observable
clearChanged, countObservers, deleteObserver, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COLLECTIONS_DBX_ID

public static final byte COLLECTIONS_DBX_ID
See Also:
Constant Field Values

ELEMENTS_DBX_ID

public static final byte ELEMENTS_DBX_ID
See Also:
Constant Field Values

VALUES_DBX_ID

public static final byte VALUES_DBX_ID
See Also:
Constant Field Values

WORDS_DBX_ID

public static final byte WORDS_DBX_ID
See Also:
Constant Field Values

DOM_DBX_ID

public static final byte DOM_DBX_ID
See Also:
Constant Field Values

VALUES_QNAME_DBX_ID

public static final byte VALUES_QNAME_DBX_ID
See Also:
Constant Field Values

ELEMENTS_DBX

public static final java.lang.String ELEMENTS_DBX
See Also:
Constant Field Values

VALUES_DBX

public static final java.lang.String VALUES_DBX
See Also:
Constant Field Values

VALUES_QNAME_DBX

public static final java.lang.String VALUES_QNAME_DBX
See Also:
Constant Field Values

DOM_DBX

public static final java.lang.String DOM_DBX
See Also:
Constant Field Values

COLLECTIONS_DBX

public static final java.lang.String COLLECTIONS_DBX
See Also:
Constant Field Values

WORDS_DBX

public static final java.lang.String WORDS_DBX
See Also:
Constant Field Values

DEFAULT_DATA_DIR

public final java.lang.String DEFAULT_DATA_DIR
See Also:
Constant Field Values

DEFAULT_PAGE_SIZE

public final int DEFAULT_PAGE_SIZE
See Also:
Constant Field Values

DEFAULT_INDEX_DEPTH

public final int DEFAULT_INDEX_DEPTH
See Also:
Constant Field Values

DEFAULT_MIN_MEMORY

public final int DEFAULT_MIN_MEMORY
See Also:
Constant Field Values

TEMP_FRAGMENT_TIMEOUT

public static final long TEMP_FRAGMENT_TIMEOUT
See Also:
Constant Field Values

BUFFERS

public static final int BUFFERS
default buffer size setting

See Also:
Constant Field Values

DEFAULT_NODES_BEFORE_MEMORY_CHECK

public static final int DEFAULT_NODES_BEFORE_MEMORY_CHECK
check available memory after storing DEFAULT_NODES_BEFORE_MEMORY_CHECK nodes

See Also:
Constant Field Values

DEFAULT_VALUE_CACHE_GROWTH

public final double DEFAULT_VALUE_CACHE_GROWTH
See Also:
Constant Field Values

DEFAULT_VALUE_KEY_THRESHOLD

public final double DEFAULT_VALUE_KEY_THRESHOLD
See Also:
Constant Field Values

DEFAULT_VALUE_VALUE_THRESHOLD

public final double DEFAULT_VALUE_VALUE_THRESHOLD
See Also:
Constant Field Values

DEFAULT_WORD_CACHE_GROWTH

public final double DEFAULT_WORD_CACHE_GROWTH
See Also:
Constant Field Values

DEFAULT_WORD_KEY_THRESHOLD

public final double DEFAULT_WORD_KEY_THRESHOLD
See Also:
Constant Field Values

DEFAULT_WORD_VALUE_THRESHOLD

public final double DEFAULT_WORD_VALUE_THRESHOLD
See Also:
Constant Field Values

collectionsDb

protected CollectionStore collectionsDb
the database files


domDb

protected DOMFile domDb

elementsDb

protected BFile elementsDb

valuesDb

protected BFile valuesDb

dbWords

protected BFile dbWords

valuesDbQname

protected BFile valuesDbQname

textEngine

protected NativeTextEngine textEngine
the index processors


elementIndex

protected NativeElementIndex elementIndex

valueIndex

protected NativeValueIndex valueIndex

qnameValueIndex

protected NativeValueIndexByQName qnameValueIndex

idxConf

protected IndexSpec idxConf

defaultIndexDepth

protected int defaultIndexDepth

xmlSerializer

protected Serializer xmlSerializer

readOnly

protected boolean readOnly

memMinFree

protected int memMinFree

nodesCount

protected int nodesCount
used to count the nodes inserted after the last memory check


dataDir

protected java.lang.String dataDir

pageSize

protected int pageSize
Constructor Detail

NativeBroker

public NativeBroker(BrokerPool pool,
                    Configuration config)
             throws EXistException
initialize database; read configuration, etc.

Method Detail

addObserver

public void addObserver(java.util.Observer o)

deleteObservers

public void deleteObservers()

clearContentLoadingObservers

public void clearContentLoadingObservers()
Remove all observers


addContentLoadingObserver

public void addContentLoadingObserver(ContentLoadingObserver observer)
Observer Design Pattern: add an observer.


removeContentLoadingObserver

public void removeContentLoadingObserver(ContentLoadingObserver observer)
Observer Design Pattern: remove an observer.


endElement

public void endElement(StoredNode node,
                       NodePath currentPath,
                       java.lang.String content,
                       long oldAddress)
Update indexes for the given element node. This method is called when the indexer encounters a closing element tag. It updates any range indexes defined on the element value and adds the element id to the structural index.

Specified by:
endElement in class DBBroker
Parameters:
node - the current element node
currentPath - node path leading to the element
content - contains the string value of the element. Needed if a range index is defined on it.
oldAddress - when copying a node, contains the storage address of the old node.

endRemove

public void endRemove()
Takes care of actually remove entries from the indices; must be called after one or more call to #removeNode().

Specified by:
endRemove in class DBBroker

getBackendType

public int getBackendType()
Specified by:
getBackendType in class DBBroker

isReadOnly

public boolean isReadOnly()
Description copied from class: DBBroker
Is the database running read-only? Returns false by default. Storage backends should override this if they support read-only mode.

Overrides:
isReadOnly in class DBBroker
Returns:
boolean

getPageSize

public int getPageSize()
Specified by:
getPageSize in class DBBroker

getDOMFile

public DOMFile getDOMFile()

getStorage

public BTree getStorage(byte id)

getStorageFileIds

public byte[] getStorageFileIds()

getIndexConfiguration

public IndexSpec getIndexConfiguration()
Specified by:
getIndexConfiguration in class DBBroker

getSerializer

public Serializer getSerializer()
Description copied from class: DBBroker
Get an instance of the Serializer used for converting nodes back to XML. Subclasses of DBBroker may have specialized subclasses of Serializer to convert a node into an XML-string

Specified by:
getSerializer in class DBBroker

newSerializer

public Serializer newSerializer()
Specified by:
newSerializer in class DBBroker

getElementIndex

public ElementIndex getElementIndex()
Specified by:
getElementIndex in class DBBroker

getValueIndex

public NativeValueIndex getValueIndex()
Specified by:
getValueIndex in class DBBroker

getQNameValueIndex

public NativeValueIndexByQName getQNameValueIndex()
Specified by:
getQNameValueIndex in class DBBroker

getTextEngine

public TextSearchEngine getTextEngine()
Description copied from class: DBBroker
Get the TextSearchEngine associated with this broker. Every subclass of DBBroker will have it's own implementation of TextSearchEngine.

Specified by:
getTextEngine in class DBBroker

getDOMIterator

public java.util.Iterator getDOMIterator(NodeProxy proxy)
Description copied from class: DBBroker
Return a DOMFileIterator starting at the specified node.

Overrides:
getDOMIterator in class DBBroker

getNodeIterator

public java.util.Iterator getNodeIterator(NodeProxy proxy)
Description copied from class: DBBroker
Return a NodeIterator starting at the specified node.

Overrides:
getNodeIterator in class DBBroker
Parameters:
proxy -
Returns:

cleanUpTempCollection

public void cleanUpTempCollection()
remove temporary collection

Specified by:
cleanUpTempCollection in class DBBroker

getOrCreateCollection

public Collection getOrCreateCollection(Txn transaction,
                                        java.lang.String name)
                                 throws PermissionDeniedException
Description copied from class: DBBroker
Returns the database collection identified by the specified path. If the collection does not yet exist, it is created - including all ancestors. The path should be absolute, e.g. /db/shakespeare.

Overrides:
getOrCreateCollection in class DBBroker
Returns:
collection or null if no collection matches the path
Throws:
PermissionDeniedException

getCollection

public Collection getCollection(java.lang.String name)
Description copied from class: DBBroker
Returns the database collection identified by the specified path. The path should be absolute, e.g. /db/shakespeare.

Specified by:
getCollection in class DBBroker
Returns:
collection or null if no collection matches the path

getCollection

public Collection getCollection(java.lang.String name,
                                long addr)
Description copied from class: DBBroker
Returns the database collection identified by the specified path. The storage address is used to locate the collection without looking up the path in the btree.

Specified by:
getCollection in class DBBroker
Returns:

openCollection

public Collection openCollection(java.lang.String name,
                                 int lockMode)
Description copied from class: DBBroker
Open a collection for reading or writing. The collection is identified by its absolute path, e.g. /db/shakespeare. It will be loaded and locked according to the lockMode argument. The caller should take care to release the collection lock properly.

Specified by:
openCollection in class DBBroker
Parameters:
name - the collection path
lockMode - one of the modes specified in class Lock
Returns:
collection or null if no collection matches the path

openCollection

public Collection openCollection(java.lang.String name,
                                 long addr,
                                 int lockMode)
Get collection object. If the collection does not exist, null is returned.

Parameters:
name - collection name
Returns:
The collection value

copyCollection

public void copyCollection(Txn transaction,
                           Collection collection,
                           Collection destination,
                           java.lang.String newName)
                    throws PermissionDeniedException,
                           LockException
Description copied from class: DBBroker
Copy a collection to the destination collection and rename it.

Specified by:
copyCollection in class DBBroker
Parameters:
destination - the destination collection
Throws:
PermissionDeniedException
LockException

moveCollection

public void moveCollection(Txn transaction,
                           Collection collection,
                           Collection destination,
                           java.lang.String newName)
                    throws PermissionDeniedException,
                           LockException
Description copied from class: DBBroker
Move a collection and all its subcollections to another collection and rename it. Moving a collection just modifies the collection path and all resource paths. The data itself remains in place.

Specified by:
moveCollection in class DBBroker
Parameters:
collection - the collection to move
destination - the destination collection
newName - the new name the collection should have in the destination collection
Throws:
PermissionDeniedException
LockException

removeCollection

public boolean removeCollection(Txn transaction,
                                Collection collection)
                         throws PermissionDeniedException
Description copied from class: DBBroker
Remove the collection and all its subcollections from the database.

Specified by:
removeCollection in class DBBroker
Throws:
PermissionDeniedException

saveCollection

public void saveCollection(Txn transaction,
                           Collection collection)
                    throws PermissionDeniedException
Saves the specified collection to storage. Collections are usually cached in memory. If a collection is modified, this method needs to be called to make the changes persistent. Note: appending a new document to a collection does not require a save. Instead, #addDocument(Collection, DocumentImpl) is called.

Specified by:
saveCollection in class DBBroker
Parameters:
collection - to store
Throws:
PermissionDeniedException

freeCollectionId

protected void freeCollectionId(Txn transaction,
                                short id)
                         throws PermissionDeniedException
Release the collection id assigned to a collection so it can be reused later.

Parameters:
id -
Throws:
PermissionDeniedException

getFreeCollectionId

public short getFreeCollectionId(Txn transaction)
                          throws ReadOnlyException
Get the next free collection id. If a collection is removed, its collection id is released so it can be reused.

Returns:
Throws:
ReadOnlyException

getNextCollectionId

public short getNextCollectionId(Txn transaction)
                          throws ReadOnlyException
Get the next available unique collection id.

Returns:
Throws:
ReadOnlyException

reindexCollection

public void reindexCollection(java.lang.String collectionName)
                       throws PermissionDeniedException
Description copied from class: DBBroker
Reindex a collection.

Specified by:
reindexCollection in class DBBroker
Parameters:
collectionName -
Throws:
PermissionDeniedException

reindexCollection

public void reindexCollection(Collection collection,
                              boolean repairMode)
                       throws PermissionDeniedException
Throws:
PermissionDeniedException

reindexCollection

public void reindexCollection(Txn transaction,
                              Collection collection,
                              boolean repairMode)
                       throws PermissionDeniedException
Throws:
PermissionDeniedException

dropCollectionIndex

public void dropCollectionIndex(Collection collection)
                         throws PermissionDeniedException
Throws:
PermissionDeniedException

storeTempResource

public DocumentImpl storeTempResource(DocumentImpl doc)
                               throws EXistException,
                                      PermissionDeniedException,
                                      LockException
store into the temporary collection of the database a given in-memory Document

Specified by:
storeTempResource in class DBBroker
Returns:
Throws:
PermissionDeniedException
EXistException
LockException

cleanUpTempResources

public void cleanUpTempResources()
remove all documents from temporary collection

Specified by:
cleanUpTempResources in class DBBroker

cleanUpTempResources

public void cleanUpTempResources(java.util.List docs)
remove from the temporary collection of the database a given list of Documents.

Specified by:
cleanUpTempResources in class DBBroker
Parameters:
docs -

storeXMLResource

public void storeXMLResource(Txn transaction,
                             DocumentImpl doc)
store Document entry into its collection.

Specified by:
storeXMLResource in class DBBroker
Parameters:
doc - the document's metadata to store.

storeBinaryResource

public void storeBinaryResource(Txn transaction,
                                BinaryDocument blob,
                                byte[] data)
Description copied from class: DBBroker
Stores the given data under the given binary resource descriptor (BinaryDocument).

Specified by:
storeBinaryResource in class DBBroker
Parameters:
blob - the binary document descriptor
data - the document binary data

getXMLResource

public org.w3c.dom.Document getXMLResource(java.lang.String fileName)
                                    throws PermissionDeniedException
get a document by its file name. The document's file name is used to identify a document.

Specified by:
getXMLResource in class DBBroker
Parameters:
fileName - absolute file name in the database; name can be given with or without the leading path /db/shakespeare.
Returns:
The document value
Throws:
PermissionDeniedException

getXMLResource

public DocumentImpl getXMLResource(java.lang.String fileName,
                                   int lockMode)
                            throws PermissionDeniedException
Specified by:
getXMLResource in class DBBroker
Throws:
PermissionDeniedException

getBinaryResource

public byte[] getBinaryResource(BinaryDocument blob)
Description copied from class: DBBroker
Retrieve the binary data stored under the resource descriptor BinaryDocument.

Specified by:
getBinaryResource in class DBBroker
Parameters:
blob - the binary document descriptor
Returns:
the document binary data

getCollectionResources

public void getCollectionResources(Collection collection)
Specified by:
getCollectionResources in class DBBroker

getXMLResourcesByDoctype

public DocumentSet getXMLResourcesByDoctype(java.lang.String doctypeName,
                                            DocumentSet result)
get all the documents in this database matching the given document-type's name.

Specified by:
getXMLResourcesByDoctype in class DBBroker
Parameters:
doctypeName - Description of the Parameter
Returns:
The documentsByDoctype value

getAllXMLResources

public DocumentSet getAllXMLResources(DocumentSet docs)
Adds all the documents in the database to the specified DocumentSet.

Specified by:
getAllXMLResources in class DBBroker
Parameters:
docs - a (possibly empty) document set to which the found documents are added.

getResourceMetadata

public void getResourceMetadata(DocumentImpl doc)
Specified by:
getResourceMetadata in class DBBroker

copyXMLResource

public void copyXMLResource(Txn transaction,
                            DocumentImpl doc,
                            Collection destination,
                            java.lang.String newName)
                     throws PermissionDeniedException,
                            LockException
Description copied from class: DBBroker
Copy a resource to the destination collection and rename it.

Specified by:
copyXMLResource in class DBBroker
Parameters:
doc - the resource to copy
destination - the destination collection
newName - the new name the resource should have in the destination collection
Throws:
LockException
PermissionDeniedException

moveXMLResource

public void moveXMLResource(Txn transaction,
                            DocumentImpl doc,
                            Collection destination,
                            java.lang.String newName)
                     throws PermissionDeniedException,
                            LockException
move Resource to another collection, with possible rename

Specified by:
moveXMLResource in class DBBroker
Parameters:
doc - the resource to move
destination - the destination collection
Throws:
PermissionDeniedException
LockException

removeXMLResource

public void removeXMLResource(Txn transaction,
                              DocumentImpl document,
                              boolean freeDocId)
                       throws PermissionDeniedException
Specified by:
removeXMLResource in class DBBroker
Throws:
PermissionDeniedException

removeBinaryResource

public void removeBinaryResource(Txn transaction,
                                 BinaryDocument blob)
                          throws PermissionDeniedException
Description copied from class: DBBroker
Completely delete this binary document (descriptor and binary data).

Specified by:
removeBinaryResource in class DBBroker
Parameters:
blob - the binary document descriptor
Throws:
PermissionDeniedException - if you don't have the right to do this

freeResourceId

protected void freeResourceId(Txn transaction,
                              int id)
                       throws PermissionDeniedException
Release the document id reserved for a document so it can be reused.

Parameters:
id -
Throws:
PermissionDeniedException

getFreeResourceId

public int getFreeResourceId(Txn transaction)
                      throws ReadOnlyException
Get the next unused document id. If a document is removed, its doc id is released, so it can be reused.

Returns:
Throws:
ReadOnlyException

getNextResourceId

public int getNextResourceId(Txn transaction,
                             Collection collection)
get next Free Doc Id

Specified by:
getNextResourceId in class DBBroker

reindexXMLResource

public void reindexXMLResource(Txn transaction,
                               DocumentImpl oldDoc,
                               DocumentImpl doc,
                               StoredNode node)
Reindex the nodes in the document. This method will either reindex all descendant nodes of the passed node, or all nodes below some level of the document if node is null.

Specified by:
reindexXMLResource in class DBBroker

defragXMLResource

public void defragXMLResource(Txn transaction,
                              DocumentImpl doc)
Description copied from class: DBBroker
Defragment pages of this document. This will minimize the number of split pages.

Specified by:
defragXMLResource in class DBBroker
Parameters:
doc - to defrag

checkXMLResourceConsistency

public void checkXMLResourceConsistency(DocumentImpl doc)
                                 throws EXistException
consistency Check of the database; useful after XUpdates; called if xupdate.consistency-checks is true in configuration

Specified by:
checkXMLResourceConsistency in class DBBroker
Throws:
EXistException

checkXMLResourceTree

public void checkXMLResourceTree(DocumentImpl doc)
consistency Check of the database; useful after XUpdates; called by #checkResourceConsistency()

Specified by:
checkXMLResourceTree in class DBBroker
Parameters:
doc -

storeNode

public void storeNode(Txn transaction,
                      StoredNode node,
                      NodePath currentPath,
                      boolean index)
Store a node into the database. This method is called by the parser to write a node to the storage backend.

Specified by:
storeNode in class DBBroker
Parameters:
node - the node to be stored
currentPath - path expression which points to this node's element-parent or to itself if it is an element (currently used by the Broker to determine if a node's content should be fulltext-indexed). @param index switch to activate fulltext indexation

updateNode

public void updateNode(Txn transaction,
                       StoredNode node)
Description copied from class: DBBroker
Update a node's data. To keep nodes in a correct sequential order, it is sometimes necessary to update a previous written node. Warning: don't use it for other purposes.

Specified by:
updateNode in class DBBroker
Parameters:
node - Description of the Parameter

insertNodeAfter

public void insertNodeAfter(Txn transaction,
                            StoredNode previous,
                            StoredNode node)
Physically insert a node into the DOM storage.

Specified by:
insertNodeAfter in class DBBroker

removeNode

public void removeNode(Txn transaction,
                       StoredNode node,
                       NodePath currentPath,
                       java.lang.String content)
Removes the Node Reference from the database. The index will be updated later, i.e. after all nodes have been physically removed. See endRemove(). removeNode() just adds the node ids to the list in elementIndex for later removal.

Specified by:
removeNode in class DBBroker

removeAllNodes

public void removeAllNodes(Txn transaction,
                           StoredNode node,
                           NodePath currentPath)
Specified by:
removeAllNodes in class DBBroker

indexNode

public void indexNode(Txn transaction,
                      StoredNode node,
                      NodePath currentPath)
Index a single node, which has been added through an XUpdate operation. This method is only called if inserting the node is possible without changing the node identifiers of sibling or parent nodes. In other cases, reindex will be called.

Specified by:
indexNode in class DBBroker

indexNode

public void indexNode(Txn transaction,
                      StoredNode node,
                      NodePath currentPath,
                      boolean repairMode)

scanNodesSequential

protected NodeSet scanNodesSequential(NodeSet context,
                                      DocumentSet doc,
                                      int relation,
                                      int truncation,
                                      java.lang.String expr,
                                      java.text.Collator collator)
Do a sequential search through the DOM-file.

Parameters:
context - Description of the Parameter
doc - Description of the Parameter
relation - Description of the Parameter
truncation - Description of the Parameter
expr - Description of the Parameter
Returns:
Description of the Return Value

getNodeValue

public java.lang.String getNodeValue(NodeProxy proxy,
                                     boolean addWhitespace)
Description copied from class: DBBroker
Get the string value of the specified node. If addWhitespace is set to true, an extra space character will be added between adjacent elements in mixed content nodes.

Overrides:
getNodeValue in class DBBroker

getNodesEqualTo

public NodeSet getNodesEqualTo(NodeSet context,
                               DocumentSet docs,
                               int relation,
                               int truncation,
                               java.lang.String expr,
                               java.text.Collator collator)
Description copied from class: DBBroker
Find all Nodes whose string value is equal to expr in the document set.

Specified by:
getNodesEqualTo in class DBBroker
Parameters:
context - the set of nodes to process
docs - the current set of documents
relation - less-than, equal etc. One of the constants specified in Constants
expr - the string value to search for

getNodeRange

public org.w3c.dom.NodeList getNodeRange(org.w3c.dom.Document doc,
                                         long first,
                                         long last)
Description copied from class: DBBroker
Get a range of nodes with given owner document from the database, starting at first and ending at last.

Specified by:
getNodeRange in class DBBroker
Parameters:
doc - the document the nodes belong to
first - unique id of the first node to retrieve
last - unique id of the last node to retrieve

objectWith

public org.w3c.dom.Node objectWith(org.w3c.dom.Document doc,
                                   long gid)
Description copied from class: DBBroker
Get a node with given owner document and id from the database.

Specified by:
objectWith in class DBBroker
Parameters:
doc - the document the node belongs to
gid - the node's unique identifier

objectWith

public org.w3c.dom.Node objectWith(NodeProxy p)
Specified by:
objectWith in class DBBroker

repair

public void repair()
            throws PermissionDeniedException
Specified by:
repair in class DBBroker
Throws:
PermissionDeniedException

flush

public void flush()
Description copied from class: DBBroker
Flush all data that has not been written before.

Overrides:
flush in class DBBroker

sync

public void sync(int syncEvent)
Description copied from class: DBBroker
Sync dom and collection state data (pages) to disk. In case of org.exist.storage.sync.Sync.MAJOR_SYNC, sync all states (dom, collection, text and element) to disk.

Specified by:
sync in class DBBroker
Parameters:
syncEvent - Sync.MAJOR_SYNC or Sync.MINOR_SYNC

shutdown

public void shutdown()
Description copied from class: DBBroker
Shut down the database instance. All open files, jdbc connections etc. should be closed.

Overrides:
shutdown in class DBBroker

closeDocument

public void closeDocument()
Overrides:
closeDocument in class DBBroker


<oXygen/> XML Editor provides support for editing and debugging XQuery expressions against the eXist XML Database.