org.exist.collections
Class Collection

java.lang.Object
  extended byorg.exist.collections.Collection
All Implemented Interfaces:
java.lang.Comparable

public class Collection
extends java.lang.Object
implements java.lang.Comparable

This class represents a collection in the database. A collection maintains a list of sub-collections and documents.

Author:
wolf

Constructor Summary
Collection(DBBroker broker)
           
Collection(DBBroker broker, java.lang.String name)
           
 
Method Summary
 void addCollection(Collection child)
          Add a new sub-collection to the collection.
 void addCollection(java.lang.String name)
          Add a new sub-collection to the collection.
 void addDocument(DocumentImpl doc)
          Add a document to the collection.
 void addDocument(User user, DocumentImpl doc)
          Add a document to the collection.
 DocumentSet allDocs(User user, boolean recursive)
          Retrieve all documents contained in this collections.
 java.util.Iterator collectionIterator()
          Return an iterator over all subcollections.
 int compareTo(java.lang.Object obj)
           
 void decRefCount()
           
 boolean equals(java.lang.Object obj)
           
protected  DBBroker getBroker()
          Returns the broker instance that created this collection.
 int getChildCollectionCount()
          Return the number of child-collections managed by this collection.
 long getCreationTime()
           
 java.util.List getDescendants(User user)
          Load all collections being descendants of this collections and return them in a List.
 DocumentImpl getDocument(java.lang.String name)
          Get a child-document.
 int getDocumentCount()
          Returns the number of documents in this collection.
 void getDocuments(DocumentSet docs)
          Add all documents to the specified document set.
 short getId()
          Get the internal id.
 java.lang.String getName()
          Get the name of this collection.
 Collection getParent()
          Returns the parent-collection.
 Permission getPermissions()
          Gets the permissions attribute of the Collection object
 int getRefCount()
           
 boolean hasDocument(java.lang.String name)
          Check if the collection has a child document.
 boolean hasSubcollection(java.lang.String name)
          Check if the collection has a sub-collection.
 void incRefCount()
           
 java.util.Iterator iterator()
          Returns an iterator on the child-documents in this collection.
 void read(VariableByteInputStream istream)
          Read collection contents from the stream.
 void removeCollection(java.lang.String name)
          Remove the specified sub-collection.
 void removeDocument(java.lang.String name)
          Remove the specified document from the collection.
 void renameDocument(java.lang.String oldName, java.lang.String newName)
           
 void setAddress(long addr)
          Set the internal storage address of the collection data.
 void setBroker(DBBroker newBroker)
           
 void setCreationTime(long ms)
           
 void setId(short id)
          Set the id of this collection.
 void setName(java.lang.String name)
          Set the name of this collection.
 void setPermissions(int mode)
          Set permissions for the collection.
 void setPermissions(Permission permissions)
          Set permissions for the collection.
 void setPermissions(java.lang.String mode)
          Set permissions for the collection.
 void setRefCount(int initialCount)
           
 void update(Collection child)
          Update the specified child-collection.
 void write(VariableByteOutputStream ostream)
          Write collection contents to stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Collection

public Collection(DBBroker broker)

Collection

public Collection(DBBroker broker,
                  java.lang.String name)
Method Detail

addCollection

public void addCollection(Collection child)
Add a new sub-collection to the collection.


addCollection

public void addCollection(java.lang.String name)
Add a new sub-collection to the collection.

Parameters:
name -

update

public void update(Collection child)
Update the specified child-collection.

Parameters:
child -

addDocument

public void addDocument(DocumentImpl doc)
Add a document to the collection.

Parameters:
doc -

addDocument

public void addDocument(User user,
                        DocumentImpl doc)
Add a document to the collection.

Parameters:
user -
doc -

renameDocument

public void renameDocument(java.lang.String oldName,
                           java.lang.String newName)

collectionIterator

public java.util.Iterator collectionIterator()
Return an iterator over all subcollections. The list of subcollections is copied first, so modifications via the iterator have no affect.

Returns:
Description of the Return Value

getDescendants

public java.util.List getDescendants(User user)
Load all collections being descendants of this collections and return them in a List.

Returns:
List

allDocs

public DocumentSet allDocs(User user,
                           boolean recursive)
Retrieve all documents contained in this collections. If recursive is true, documents from sub-collections are included.

Parameters:
user -
recursive -
Returns:

getDocuments

public void getDocuments(DocumentSet docs)
Add all documents to the specified document set.

Parameters:
docs -

compareTo

public int compareTo(java.lang.Object obj)
Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(java.lang.Object obj)

getChildCollectionCount

public int getChildCollectionCount()
Return the number of child-collections managed by this collection.

Returns:
The childCollectionCount value

getDocument

public DocumentImpl getDocument(java.lang.String name)
Get a child-document.

Parameters:
name - Description of the Parameter
Returns:
The document value

getDocumentCount

public int getDocumentCount()
Returns the number of documents in this collection.

Returns:
The documentCount value

getId

public short getId()
Get the internal id.

Returns:
The id value

getName

public java.lang.String getName()
Get the name of this collection.

Returns:
The name value

getParent

public Collection getParent()
Returns the parent-collection.

Returns:
The parent-collection or null if this is the root collection.

getBroker

protected DBBroker getBroker()
Returns the broker instance that created this collection.

Returns:

setBroker

public void setBroker(DBBroker newBroker)

getPermissions

public Permission getPermissions()
Gets the permissions attribute of the Collection object

Returns:
The permissions value

hasDocument

public boolean hasDocument(java.lang.String name)
Check if the collection has a child document.

Parameters:
name - the name (without path) of the document
Returns:

hasSubcollection

public boolean hasSubcollection(java.lang.String name)
Check if the collection has a sub-collection.

Parameters:
name - the name of the subcollection (without path).
Returns:

iterator

public java.util.Iterator iterator()
Returns an iterator on the child-documents in this collection.

Returns:

read

public void read(VariableByteInputStream istream)
          throws java.io.IOException
Read collection contents from the stream.

Parameters:
istream -
Throws:
java.io.IOException

removeCollection

public void removeCollection(java.lang.String name)
Remove the specified sub-collection.

Parameters:
name - Description of the Parameter

removeDocument

public void removeDocument(java.lang.String name)
Remove the specified document from the collection.

Parameters:
name - Description of the Parameter

setId

public void setId(short id)
Set the id of this collection.

Parameters:
id - The new id value

setName

public void setName(java.lang.String name)
Set the name of this collection.

Parameters:
name - The new name value

setPermissions

public void setPermissions(int mode)
Set permissions for the collection.

Parameters:
mode - The new permissions value

setPermissions

public void setPermissions(java.lang.String mode)
                    throws SyntaxException
Set permissions for the collection.

Parameters:
mode - The new permissions value
Throws:
SyntaxException - Description of the Exception

setPermissions

public void setPermissions(Permission permissions)
Set permissions for the collection.

Parameters:
permissions -

write

public void write(VariableByteOutputStream ostream)
           throws java.io.IOException
Write collection contents to stream.

Parameters:
ostream -
Throws:
java.io.IOException

setAddress

public void setAddress(long addr)
Set the internal storage address of the collection data.

Parameters:
addr -

incRefCount

public void incRefCount()

decRefCount

public void decRefCount()

setRefCount

public void setRefCount(int initialCount)

getRefCount

public int getRefCount()

setCreationTime

public void setCreationTime(long ms)

getCreationTime

public long getCreationTime()


Copyright (C) Wolfgang Meier. All rights reserved.