org.exist.xmldb
Class LocalCollection

java.lang.Object
  extended by java.util.Observable
      extended by org.exist.xmldb.LocalCollection
All Implemented Interfaces:
CollectionImpl, org.xmldb.api.base.Collection, org.xmldb.api.base.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(User user, BrokerPool brokerPool, LocalCollection parent, XmldbURI name, AccessContext accessCtx)
          Create a collection identified by its name.
LocalCollection(User 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
 org.xmldb.api.base.Resource createResource(String id, String type)
           
 AccessContext getAccessContext()
           
 org.xmldb.api.base.Collection getChildCollection(String name)
           
 int getChildCollectionCount()
           
 String[] getChildCollections()
           
 Date getCreationTime()
          Returns the time of creation of the collection.
 String getName()
           
 org.xmldb.api.base.Collection getParentCollection()
           
 String getPath()
           
 XmldbURI getPathURI()
           
 String getProperty(String property)
           
 org.xmldb.api.base.Resource getResource(String id)
           
 int getResourceCount()
           
 String[] getResources()
           
 org.xmldb.api.base.Service getService(String name, String version)
          Possible services: XPathQueryService, XQueryService, CollectionManagementService (CollectionManager), UserManagementService, DatabaseInstanceManager, XUpdateQueryService, IndexQueryService, ValidationService.
 org.xmldb.api.base.Service[] getServices()
           
 XmldbURI getURI()
           
 boolean isOpen()
           
 boolean isRemoteCollection()
           
 String[] listChildCollections()
           
 String[] listResources()
           
 void registerService(org.xmldb.api.base.Service serv)
           
 void removeResource(org.xmldb.api.base.Resource res)
           
 void setProperty(String property, String value)
           
 void setReader(XMLReader reader)
          set user-defined Reader
 void storeResource(org.xmldb.api.base.Resource resource)
           
 void storeResource(org.xmldb.api.base.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(User user,
                       BrokerPool brokerPool,
                       XmldbURI collection,
                       AccessContext accessCtx)
                throws org.xmldb.api.base.XMLDBException
Create a collection with no parent (root collection).

Parameters:
user -
brokerPool -
collection -
Throws:
org.xmldb.api.base.XMLDBException

LocalCollection

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

Parameters:
user -
brokerPool -
parent -
name -
Throws:
org.xmldb.api.base.XMLDBException
Method Detail

getAccessContext

public AccessContext getAccessContext()

close

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

Specified by:
close in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

createId

public String createId()
                throws org.xmldb.api.base.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 org.xmldb.api.base.Collection
Returns:
the unique resource name
Throws:
org.xmldb.api.base.XMLDBException

createResource

public org.xmldb.api.base.Resource createResource(String id,
                                                  String type)
                                           throws org.xmldb.api.base.XMLDBException
Specified by:
createResource in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

getChildCollection

public org.xmldb.api.base.Collection getChildCollection(String name)
                                                 throws org.xmldb.api.base.XMLDBException
Specified by:
getChildCollection in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

getChildCollectionCount

public int getChildCollectionCount()
                            throws org.xmldb.api.base.XMLDBException
Specified by:
getChildCollectionCount in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

getName

public String getName()
               throws org.xmldb.api.base.XMLDBException
Specified by:
getName in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

getParentCollection

public org.xmldb.api.base.Collection getParentCollection()
                                                  throws org.xmldb.api.base.XMLDBException
Specified by:
getParentCollection in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

getPath

public String getPath()
               throws org.xmldb.api.base.XMLDBException
Throws:
org.xmldb.api.base.XMLDBException

getPathURI

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

getProperty

public String getProperty(String property)
                   throws org.xmldb.api.base.XMLDBException
Specified by:
getProperty in interface org.xmldb.api.base.Configurable
Throws:
org.xmldb.api.base.XMLDBException

getResource

public org.xmldb.api.base.Resource getResource(String id)
                                        throws org.xmldb.api.base.XMLDBException
Specified by:
getResource in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

getResourceCount

public int getResourceCount()
                     throws org.xmldb.api.base.XMLDBException
Specified by:
getResourceCount in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

getService

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

Specified by:
getService in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

getServices

public org.xmldb.api.base.Service[] getServices()
                                         throws org.xmldb.api.base.XMLDBException
Specified by:
getServices in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

isOpen

public boolean isOpen()
               throws org.xmldb.api.base.XMLDBException
Specified by:
isOpen in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

listChildCollections

public String[] listChildCollections()
                              throws org.xmldb.api.base.XMLDBException
Specified by:
listChildCollections in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

getChildCollections

public String[] getChildCollections()
                             throws org.xmldb.api.base.XMLDBException
Specified by:
getChildCollections in interface CollectionImpl
Throws:
org.xmldb.api.base.XMLDBException

listResources

public String[] listResources()
                       throws org.xmldb.api.base.XMLDBException
Specified by:
listResources in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

getResources

public String[] getResources()
                      throws org.xmldb.api.base.XMLDBException
Specified by:
getResources in interface CollectionImpl
Throws:
org.xmldb.api.base.XMLDBException

registerService

public void registerService(org.xmldb.api.base.Service serv)
                     throws org.xmldb.api.base.XMLDBException
Throws:
org.xmldb.api.base.XMLDBException

removeResource

public void removeResource(org.xmldb.api.base.Resource res)
                    throws org.xmldb.api.base.XMLDBException
Specified by:
removeResource in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

setProperty

public void setProperty(String property,
                        String value)
                 throws org.xmldb.api.base.XMLDBException
Specified by:
setProperty in interface org.xmldb.api.base.Configurable
Throws:
org.xmldb.api.base.XMLDBException

storeResource

public void storeResource(org.xmldb.api.base.Resource resource)
                   throws org.xmldb.api.base.XMLDBException
Specified by:
storeResource in interface org.xmldb.api.base.Collection
Throws:
org.xmldb.api.base.XMLDBException

storeResource

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

getCreationTime

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

Specified by:
getCreationTime in interface CollectionImpl
Throws:
org.xmldb.api.base.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 org.xmldb.api.base.XMLDBException
Specified by:
isRemoteCollection in interface CollectionImpl
Throws:
org.xmldb.api.base.XMLDBException

setReader

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

Parameters:
reader -

getURI

public XmldbURI getURI()


Copyright (C) Wolfgang Meier. All rights reserved.