org.exist.xmldb
Class LocalCollection

java.lang.Object
  extended by java.util.Observable
      extended by org.exist.xmldb.LocalCollection
All Implemented Interfaces:
CollectionImpl, Collection, Configurable

public class LocalCollection
extends Observable
implements CollectionImpl

A local implementation of the Collection interface. This is used when the database is running in embedded mode. Extends Observable to allow status callbacks during indexing. Methods storeResource notifies registered observers about the progress of the indexer by passing an object of type ProgressIndicator to the observer.

Author:
wolf

Field Summary
static String NORMALIZE_HTML
          Property to be passed to setProperty(String, String).
 
Constructor Summary
LocalCollection(Subject user, BrokerPool brokerPool, LocalCollection parent, XmldbURI name, AccessContext accessCtx)
          Create a collection identified by its name.
LocalCollection(Subject user, BrokerPool brokerPool, XmldbURI collection, AccessContext accessCtx)
          Create a collection with no parent (root collection).
 
Method Summary
 void addObserver(Observer o)
          Add a new observer to the list.
 void close()
          Close the current collection.
 String createId()
          Creates a unique name for a database resource Uniqueness is only guaranteed within the eXist instance The name is based on a hex encoded string of a random integer and will have the format xxxxxxxx.xml where x is in the range 0 to 9 and a to f
 Resource createResource(String id, String type)
           
 AccessContext getAccessContext()
           
 Collection getChildCollection(String name)
           
 int getChildCollectionCount()
           
 String[] getChildCollections()
           
 Date getCreationTime()
          Returns the time of creation of the collection.
 String getName()
           
 Collection getParentCollection()
           
 String getPath()
           
 XmldbURI getPathURI()
           
 String getProperty(String property)
           
 Resource getResource(String id)
           
 int getResourceCount()
           
 String[] getResources()
           
 Service getService(String name, String version)
          Possible services: XPathQueryService, XQueryService, CollectionManagementService (CollectionManager), UserManagementService, DatabaseInstanceManager, XUpdateQueryService, IndexQueryService, ValidationService.
 Service[] getServices()
           
 XmldbURI getURI()
           
 boolean isOpen()
           
 boolean isRemoteCollection()
           
 String[] listChildCollections()
           
 String[] listResources()
          Retrieve the list of resources in the collection
 void registerService(Service serv)
           
 void removeResource(Resource res)
           
 void setProperty(String property, String value)
           
 void setReader(XMLReader reader)
          set user-defined Reader
 void setTriggersEnabled(boolean triggersEnabled)
           
 void storeResource(Resource resource)
           
 void storeResource(Resource resource, Date a, Date b)
           
 
Methods inherited from class java.util.Observable
countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORMALIZE_HTML

public static final String NORMALIZE_HTML
Property to be passed to setProperty(String, String). When storing documents, pass HTML files through an HTML parser (NekoHTML) instead of the XML parser. The HTML parser will normalize the HTML into well-formed XML.

See Also:
Constant Field Values
Constructor Detail

LocalCollection

public LocalCollection(Subject user,
                       BrokerPool brokerPool,
                       XmldbURI collection,
                       AccessContext accessCtx)
                throws XMLDBException
Create a collection with no parent (root collection).

Parameters:
user -
brokerPool -
collection -
Throws:
XMLDBException

LocalCollection

public LocalCollection(Subject user,
                       BrokerPool brokerPool,
                       LocalCollection parent,
                       XmldbURI name,
                       AccessContext accessCtx)
                throws XMLDBException
Create a collection identified by its name. Load the collection from the database.

Parameters:
user -
brokerPool -
parent -
name -
Throws:
XMLDBException
Method Detail

getAccessContext

public AccessContext getAccessContext()

close

public void close()
           throws XMLDBException
Close the current collection. Calling this method will flush all open buffers to disk.

Specified by:
close in interface Collection
Throws:
XMLDBException

createId

public String createId()
                throws XMLDBException
Creates a unique name for a database resource Uniqueness is only guaranteed within the eXist instance The name is based on a hex encoded string of a random integer and will have the format xxxxxxxx.xml where x is in the range 0 to 9 and a to f

Specified by:
createId in interface Collection
Returns:
the unique resource name
Throws:
XMLDBException

createResource

public Resource createResource(String id,
                               String type)
                        throws XMLDBException
Specified by:
createResource in interface Collection
Throws:
XMLDBException

getChildCollection

public Collection getChildCollection(String name)
                              throws XMLDBException
Specified by:
getChildCollection in interface Collection
Parameters:
name -
Returns:
Throws:
XMLDBException

getChildCollectionCount

public int getChildCollectionCount()
                            throws XMLDBException
Specified by:
getChildCollectionCount in interface Collection
Throws:
XMLDBException

getName

public String getName()
               throws XMLDBException
Specified by:
getName in interface Collection
Throws:
XMLDBException

getParentCollection

public Collection getParentCollection()
                               throws XMLDBException
Specified by:
getParentCollection in interface Collection
Throws:
XMLDBException

getPath

public String getPath()
               throws XMLDBException
Throws:
XMLDBException

getPathURI

public XmldbURI getPathURI()
Specified by:
getPathURI in interface CollectionImpl

getProperty

public String getProperty(String property)
                   throws XMLDBException
Specified by:
getProperty in interface Configurable
Throws:
XMLDBException

getResource

public Resource getResource(String id)
                     throws XMLDBException
Specified by:
getResource in interface Collection
Throws:
XMLDBException

getResourceCount

public int getResourceCount()
                     throws XMLDBException
Specified by:
getResourceCount in interface Collection
Throws:
XMLDBException

getService

public Service getService(String name,
                          String version)
                   throws XMLDBException
Possible services: XPathQueryService, XQueryService, CollectionManagementService (CollectionManager), UserManagementService, DatabaseInstanceManager, XUpdateQueryService, IndexQueryService, ValidationService.

Specified by:
getService in interface Collection
Throws:
XMLDBException

getServices

public Service[] getServices()
                      throws XMLDBException
Specified by:
getServices in interface Collection
Throws:
XMLDBException

isOpen

public boolean isOpen()
               throws XMLDBException
Specified by:
isOpen in interface Collection
Throws:
XMLDBException

listChildCollections

public String[] listChildCollections()
                              throws XMLDBException
Specified by:
listChildCollections in interface Collection
Throws:
XMLDBException

getChildCollections

public String[] getChildCollections()
                             throws XMLDBException
Specified by:
getChildCollections in interface CollectionImpl
Throws:
XMLDBException

listResources

public String[] listResources()
                       throws XMLDBException
Retrieve the list of resources in the collection

Specified by:
listResources in interface Collection
Throws:
XMLDBException - if and invalid collection was specified, or if permission is denied

getResources

public String[] getResources()
                      throws XMLDBException
Specified by:
getResources in interface CollectionImpl
Throws:
XMLDBException

registerService

public void registerService(Service serv)
                     throws XMLDBException
Throws:
XMLDBException

removeResource

public void removeResource(Resource res)
                    throws XMLDBException
Specified by:
removeResource in interface Collection
Throws:
XMLDBException

setProperty

public void setProperty(String property,
                        String value)
                 throws XMLDBException
Specified by:
setProperty in interface Configurable
Throws:
XMLDBException

storeResource

public void storeResource(Resource resource)
                   throws XMLDBException
Specified by:
storeResource in interface Collection
Throws:
XMLDBException

storeResource

public void storeResource(Resource resource,
                          Date a,
                          Date b)
                   throws XMLDBException
Specified by:
storeResource in interface CollectionImpl
Throws:
XMLDBException

getCreationTime

public Date getCreationTime()
                     throws XMLDBException
Description copied from interface: CollectionImpl
Returns the time of creation of the collection.

Specified by:
getCreationTime in interface CollectionImpl
Throws:
XMLDBException

addObserver

public void addObserver(Observer o)
Add a new observer to the list. Observers are just passed on to the indexer to be notified about the indexing progress.

Overrides:
addObserver in class Observable

isRemoteCollection

public boolean isRemoteCollection()
                           throws XMLDBException
Specified by:
isRemoteCollection in interface CollectionImpl
Throws:
XMLDBException

setReader

public void setReader(XMLReader reader)
set user-defined Reader

Parameters:
reader -

getURI

public XmldbURI getURI()

setTriggersEnabled

public void setTriggersEnabled(boolean triggersEnabled)
                        throws XMLDBException
Specified by:
setTriggersEnabled in interface CollectionImpl
Throws:
XMLDBException


Copyright (C) The eXist-db Project. All rights reserved.