|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Objectjava.util.Observable
org.exist.collections.Collection
public class Collection
This class represents a collection in the database. A collection maintains a list of
sub-collections and documents, and provides the methods to store/remove resources.
Collections are shared between DBBroker instances. The caller
is responsible to lock/unlock the collection. Call DBBroker.openCollection(XmldbURI, int)
to get a collection with a read or write lock and release(int) to release the lock.
| Field Summary | |
|---|---|
static int |
LENGTH_COLLECTION_ID
|
static short |
UNKNOWN_COLLECTION_ID
|
| Fields inherited from interface org.exist.storage.cache.Cacheable |
|---|
MAX_REF |
| Constructor Summary | |
|---|---|
Collection()
|
|
Collection(XmldbURI path)
|
|
| Method Summary | |
|---|---|
BinaryDocument |
addBinaryResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
byte[] data,
String mimeType)
|
BinaryDocument |
addBinaryResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
byte[] data,
String mimeType,
Date created,
Date modified)
|
BinaryDocument |
addBinaryResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
InputStream is,
String mimeType,
int size)
|
BinaryDocument |
addBinaryResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
InputStream is,
String mimeType,
int size,
Date created,
Date modified)
|
void |
addCollection(DBBroker broker,
Collection child,
boolean isNew)
Add a new sub-collection to the collection. |
void |
addDocument(Txn transaction,
DBBroker broker,
DocumentImpl doc)
Add a document to the collection. |
void |
addObserver(Observer o)
|
DocumentSet |
allDocs(DBBroker broker,
DocumentSet docs,
boolean recursive,
boolean checkPermissions)
Retrieve all documents contained in this collections. |
boolean |
allowUnload()
Check if this collection may be safely removed from the cache. |
Iterator |
collectionIterator()
Return an iterator over all subcollections. |
int |
compareTo(Object obj)
|
int |
decReferenceCount()
Decrease the reference count of this object by one and return it. |
void |
deleteObservers()
|
boolean |
equals(Object obj)
|
long |
getAddress()
|
int |
getChildCollectionCount()
Return the number of child-collections managed by this collection. |
CollectionConfiguration |
getConfiguration(DBBroker broker)
|
long |
getCreationTime()
|
List |
getDescendants(DBBroker broker,
User user)
Load all collections below this collections and return them in a List. |
DocumentImpl |
getDocument(DBBroker broker,
XmldbURI path)
Get a child resource as identified by path. |
int |
getDocumentCount()
Returns the number of documents in this collection. |
DocumentSet |
getDocuments(DBBroker broker,
DocumentSet docs,
boolean checkPermissions)
Add all documents to the specified document set. |
DocumentImpl |
getDocumentWithLock(DBBroker broker,
XmldbURI name)
Deprecated. Use other method |
DocumentImpl |
getDocumentWithLock(DBBroker broker,
XmldbURI uri,
int lockMode)
Retrieve a child resource after putting a read lock on it. |
FulltextIndexSpec |
getFulltextIndexConfiguration(DBBroker broker)
|
short |
getId()
Get the internal id. |
GeneralRangeIndexSpec |
getIndexByPathConfiguration(DBBroker broker,
NodePath path)
|
QNameRangeIndexSpec |
getIndexByQNameConfiguration(DBBroker broker,
QName qname)
|
IndexSpec |
getIndexConfiguration(DBBroker broker)
Deprecated. Make private ASAP |
long |
getKey()
Get a unique key for the object. |
Lock |
getLock()
|
int |
getMemorySize()
Returns the estimated amount of memory used by this collection and its documents. |
XmldbURI |
getParentURI()
Returns the parent-collection. |
Permission |
getPermissions()
Gets the permissions attribute of the Collection object |
int |
getReferenceCount()
Get the current reference count. |
int |
getTimestamp()
Get the current timestamp marker. |
XmldbURI |
getURI()
Get the name of this collection. |
boolean |
hasChildCollection(XmldbURI path)
|
boolean |
hasDocument(XmldbURI uri)
Check if the collection has a child document. |
boolean |
hasSubcollection(XmldbURI name)
Check if the collection has a sub-collection. |
int |
incReferenceCount()
Increase the reference count of this object by one and return it. |
void |
invalidateConfiguration()
|
boolean |
isDirty()
|
boolean |
isTempCollection()
Returns true if this is a temporary collection. |
Iterator |
iterator(DBBroker broker)
Returns an iterator on the child-documents in this collection. |
void |
read(DBBroker broker,
VariableByteInput istream)
Read collection contents from the stream. |
void |
release(int mode)
Closes the collection, i.e. |
void |
releaseDocument(DocumentImpl doc)
Deprecated. Use other method |
void |
releaseDocument(DocumentImpl doc,
int mode)
Release any locks held on the document. |
void |
removeBinaryResource(Txn transaction,
DBBroker broker,
DocumentImpl doc)
|
void |
removeBinaryResource(Txn transaction,
DBBroker broker,
XmldbURI uri)
|
void |
removeCollection(XmldbURI name)
Remove the specified sub-collection. |
void |
removeXMLResource(Txn transaction,
DBBroker broker,
XmldbURI docUri)
Remove the specified document from the collection. |
InputSource |
resolveEntity(String publicId,
String systemId)
Try to resolve external entities. |
void |
setAddress(long addr)
Set the internal storage address of the collection data. |
void |
setConfigEnabled(boolean enabled)
Should the collection configuration document be enabled for this collection? Called by NativeBroker
before doing a reindex. |
void |
setCreationTime(long ms)
|
void |
setId(short id)
|
void |
setPath(XmldbURI path)
|
void |
setPermissions(int mode)
|
void |
setPermissions(Permission permissions)
Set permissions for the collection. |
void |
setPermissions(String mode)
|
void |
setReader(XMLReader reader)
set user-defined Reader |
void |
setReferenceCount(int count)
Set the reference count of this object. |
void |
setTimestamp(int timestamp)
Set the timestamp marker. |
void |
setTriggersEnabled(boolean enabled)
|
void |
store(Txn transaction,
DBBroker broker,
IndexInfo info,
InputSource source,
boolean privileged)
Stores an XML document in the database. |
void |
store(Txn transaction,
DBBroker broker,
IndexInfo info,
Node node,
boolean privileged)
Stores an XML document in the database. |
void |
store(Txn transaction,
DBBroker broker,
IndexInfo info,
String data,
boolean privileged)
Stores an XML document in the database. |
boolean |
sync(boolean syncJournal)
Called before the object is released by the cache. |
String |
toString()
|
void |
unlinkDocument(DocumentImpl doc)
Removes the document from the internal list of resources, but doesn't delete the document object itself. |
void |
update(Collection child)
Update the specified child-collection. |
IndexInfo |
validateXMLResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
InputSource source)
Validates an XML document et prepares it for further storage. |
IndexInfo |
validateXMLResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
Node node)
Validates an XML document et prepares it for further storage. |
IndexInfo |
validateXMLResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
String data)
Validates an XML document et prepares it for further storage. |
void |
write(DBBroker broker,
VariableByteOutputStream ostream)
Write collection contents to stream. |
| Methods inherited from class java.util.Observable |
|---|
countObservers, deleteObserver, hasChanged, notifyObservers, notifyObservers |
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static int LENGTH_COLLECTION_ID
public static final short UNKNOWN_COLLECTION_ID
| Constructor Detail |
|---|
public Collection()
public Collection(XmldbURI path)
| Method Detail |
|---|
public void setPath(XmldbURI path)
public Lock getLock()
public void addCollection(DBBroker broker,
Collection child,
boolean isNew)
public boolean hasChildCollection(XmldbURI path)
public boolean isTempCollection()
public void release(int mode)
public void update(Collection child)
child -
public void addDocument(Txn transaction,
DBBroker broker,
DocumentImpl doc)
doc - public void unlinkDocument(DocumentImpl doc)
doc - public Iterator collectionIterator()
public List getDescendants(DBBroker broker,
User user)
public DocumentSet allDocs(DBBroker broker,
DocumentSet docs,
boolean recursive,
boolean checkPermissions)
broker - docs - recursive - checkPermissions -
public DocumentSet getDocuments(DBBroker broker,
DocumentSet docs,
boolean checkPermissions)
docs - public boolean allowUnload()
allowUnload in interface Cacheablepublic int compareTo(Object obj)
compareTo in interface Comparablepublic boolean equals(Object obj)
equals in class Objectpublic int getMemorySize()
CollectionCacheManager to be able
to resize the caches.
public int getChildCollectionCount()
public DocumentImpl getDocument(DBBroker broker,
XmldbURI path)
broker - path - The name of the document (without collection path)
public DocumentImpl getDocumentWithLock(DBBroker broker,
XmldbURI name)
throws LockException
broker - name -
LockException
public DocumentImpl getDocumentWithLock(DBBroker broker,
XmldbURI uri,
int lockMode)
throws LockException
broker - uri - lockMode -
LockExceptionpublic void releaseDocument(DocumentImpl doc)
doc -
public void releaseDocument(DocumentImpl doc,
int mode)
doc - public int getDocumentCount()
public short getId()
public XmldbURI getURI()
public XmldbURI getParentURI()
public Permission getPermissions()
public boolean hasDocument(XmldbURI uri)
uri - the name (without path) of the document
public boolean hasSubcollection(XmldbURI name)
name - the name of the subcollection (without path).
public Iterator iterator(DBBroker broker)
public void read(DBBroker broker,
VariableByteInput istream)
throws IOException
istream -
IOException
public void removeCollection(XmldbURI name)
throws LockException
name - Description of the Parameter
LockException
public void removeXMLResource(Txn transaction,
DBBroker broker,
XmldbURI docUri)
throws PermissionDeniedException,
TriggerException,
LockException
transaction - broker - docUri -
PermissionDeniedException
TriggerException
LockException
public void removeBinaryResource(Txn transaction,
DBBroker broker,
XmldbURI uri)
throws PermissionDeniedException,
LockException,
TriggerException
PermissionDeniedException
LockException
TriggerException
public void removeBinaryResource(Txn transaction,
DBBroker broker,
DocumentImpl doc)
throws PermissionDeniedException,
LockException,
TriggerException
PermissionDeniedException
LockException
TriggerException
public void store(Txn transaction,
DBBroker broker,
IndexInfo info,
InputSource source,
boolean privileged)
throws EXistException,
PermissionDeniedException,
TriggerException,
SAXException,
LockException
validateXMLResourceInternal(Txn, DBBroker, XmldbURI, org.exist.collections.Collection.ValidateBlock)
should have been called previously in order to acquire a write lock for the document. Launches the finish trigger.
transaction - broker - info - source - privileged -
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException
public void store(Txn transaction,
DBBroker broker,
IndexInfo info,
String data,
boolean privileged)
throws EXistException,
PermissionDeniedException,
TriggerException,
SAXException,
LockException
validateXMLResourceInternal(Txn, DBBroker, XmldbURI, org.exist.collections.Collection.ValidateBlock)
should have been called previously in order to acquire a write lock for the document. Launches the finish trigger.
transaction - broker - info - data - privileged -
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException
public void store(Txn transaction,
DBBroker broker,
IndexInfo info,
Node node,
boolean privileged)
throws EXistException,
PermissionDeniedException,
TriggerException,
SAXException,
LockException
validateXMLResourceInternal(Txn, DBBroker, XmldbURI, org.exist.collections.Collection.ValidateBlock)
should have been called previously in order to acquire a write lock for the document. Launches the finish trigger.
transaction - broker - info - node - privileged -
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException
public IndexInfo validateXMLResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
String data)
throws EXistException,
PermissionDeniedException,
TriggerException,
SAXException,
LockException,
IOException
transaction - broker - docUri - data -
IndexInfo with a write lock on the document.
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException
IOException
public IndexInfo validateXMLResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
InputSource source)
throws EXistException,
PermissionDeniedException,
TriggerException,
SAXException,
LockException,
IOException
transaction - broker - docUri - source -
IndexInfo with a write lock on the document.
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException
IOException
public IndexInfo validateXMLResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
Node node)
throws EXistException,
PermissionDeniedException,
TriggerException,
SAXException,
LockException,
IOException
transaction - broker - docUri - node -
IndexInfo with a write lock on the document.
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException
IOException
public BinaryDocument addBinaryResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
byte[] data,
String mimeType)
throws EXistException,
PermissionDeniedException,
LockException,
TriggerException
EXistException
PermissionDeniedException
LockException
TriggerException
public BinaryDocument addBinaryResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
byte[] data,
String mimeType,
Date created,
Date modified)
throws EXistException,
PermissionDeniedException,
LockException,
TriggerException
EXistException
PermissionDeniedException
LockException
TriggerException
public BinaryDocument addBinaryResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
InputStream is,
String mimeType,
int size)
throws EXistException,
PermissionDeniedException,
LockException,
TriggerException
EXistException
PermissionDeniedException
LockException
TriggerException
public BinaryDocument addBinaryResource(Txn transaction,
DBBroker broker,
XmldbURI docUri,
InputStream is,
String mimeType,
int size,
Date created,
Date modified)
throws EXistException,
PermissionDeniedException,
LockException,
TriggerException
EXistException
PermissionDeniedException
LockException
TriggerExceptionpublic void setId(short id)
public void setPermissions(int mode)
throws LockException
LockException
public void setPermissions(String mode)
throws SyntaxException,
LockException
SyntaxException
LockException
public void setPermissions(Permission permissions)
throws LockException
permissions -
LockException
public void write(DBBroker broker,
VariableByteOutputStream ostream)
throws IOException
ostream -
IOExceptionpublic CollectionConfiguration getConfiguration(DBBroker broker)
public void setConfigEnabled(boolean enabled)
NativeBroker
before doing a reindex.
enabled - public void invalidateConfiguration()
public void setAddress(long addr)
addr - public long getAddress()
public void setCreationTime(long ms)
public long getCreationTime()
public void setTriggersEnabled(boolean enabled)
public void setReader(XMLReader reader)
public InputSource resolveEntity(String publicId,
String systemId)
throws SAXException,
IOException
resolveEntity in interface EntityResolverSAXException
IOExceptionEntityResolver.resolveEntity(java.lang.String, java.lang.String)public void addObserver(Observer o)
addObserver in class Observablepublic void deleteObservers()
deleteObservers in class Observablepublic long getKey()
Cacheable
getKey in interface Cacheablepublic int getReferenceCount()
Cacheable
getReferenceCount in interface Cacheablepublic int incReferenceCount()
Cacheable
incReferenceCount in interface Cacheablepublic int decReferenceCount()
Cacheable
decReferenceCount in interface Cacheablepublic void setReferenceCount(int count)
Cacheable
setReferenceCount in interface Cacheablepublic void setTimestamp(int timestamp)
Cacheable
setTimestamp in interface Cacheablepublic int getTimestamp()
Cacheable
getTimestamp in interface Cacheablepublic boolean sync(boolean syncJournal)
Cacheable
sync in in