kevinross    2003/07/10 14:44:44

  Modified:    java/src/org/apache/xindice/client/xmldb
                        XindiceCollection.java
  Log:
  formatting, organize imports
  
  Revision  Changes    Path
  1.8       +274 -276  
xml-xindice/java/src/org/apache/xindice/client/xmldb/XindiceCollection.java
  
  Index: XindiceCollection.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/XindiceCollection.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XindiceCollection.java    10 Jul 2003 14:43:52 -0000      1.7
  +++ XindiceCollection.java    10 Jul 2003 21:44:44 -0000      1.8
  @@ -84,280 +84,278 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Kimbro Staken</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">James Bates</a>
    */
  -public abstract class XindiceCollection extends CommonConfigurable 
implements Collection {      
  -    /* Instantiated named services map */
  -    protected Hashtable services = null;
  -    
  -    /* Xindice query result meta-info namespace */
  -    public static final String QUERY_NS = 
"http://xml.apache.org/xindice/Query";;
  -    
  -    /* path to collection on target server */
  -    protected String collPath;    
  -
  -    /**
  -     * Creates new <code>CollectionImpl</code> instance representing 
connection
  -     * to server collection.
  -     *
  -     * @exception XMLDBException thrown if a connection could not be 
established,
  -     *            because of URL syntax errors, or connection failure, or if 
no
  -     *            collection with path <code>collPath</code> could be 
located.
  -     */
  -    public XindiceCollection(String collPath) throws XMLDBException {
  -        
  -        this.collPath = collPath.endsWith("/") ? collPath.substring(0, 
collPath.length() - 1) : collPath;
  -
  -        services = new Hashtable();
  -        
  -        // Register all services supported by this collection implementation.
  -        XPathQueryServiceImpl xpath = new XPathQueryServiceImpl();
  -        xpath.setCollection(this);
  -//        xpath.setSymbolDeserializer(syms);
  -        registerService(xpath);
  -
  -        XUpdateQueryServiceImpl xupdate = new XUpdateQueryServiceImpl();
  -        xupdate.setCollection(this);
  -        registerService(xupdate);
  -
  -        try {
  -           CollectionManagementServiceImpl manager = new 
CollectionManagementServiceImpl();
  -           manager.setCollection(this);
  -           registerService(manager);
  -
  -           // CollectionManagementServiceImpl provides both standard access 
as a
  -           // CollectionManagementService and Xindice specific access as a
  -           // CollectionManager and DatabaseInstanceManager.
  -           // We need to register it explicitly to make it available
  -           services.put("CollectionManager" + manager.getVersion(), manager);
  -           services.put("DatabaseInstanceManager" + manager.getVersion(), 
manager);           
  -        }
  -        catch (Exception e) {
  -           throw FaultCodes.createXMLDBException(e);
  -        }
  -    }
  -
  -   /**
  -    * Provides a list of all services known to the collection. If no services
  -    * are known an empty list is returned.
  -    *
  -    * @return An array of registered <code>Service</code> implementations.
  -    * @exception XMLDBException with expected error codes.<br />
  -    *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -    *  specific errors that occur.<br />
  -    *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -    *  method has been called on the <code>Collection</code><br />
  -    */
  -     public Service[] getServices() throws XMLDBException {
  -        checkOpen();
  -
  -        Enumeration e = services.elements();
  -        Service[] result = new Service[services.size()];
  -
  -        int i = 0;
  -        while (e.hasMoreElements()) {
  -           result[i] = (Service) e.nextElement();
  -           i++;
  -        }
  -
  -        return result;
  -     }
  -
  -   /**
  -    * Returns a <code>Service</code> instance for the requested service name 
and version. If
  -    * no <code>Service</code> exists for those parameters a null value is 
returned.
  -    *
  -    * @param name Description of Parameter
  -    * @param version Description of Parameter
  -    * @return the Service instance or null if no Service could be found.
  -    * @exception XMLDBException with expected error codes.<br />
  -    *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -    *  specific errors that occur.<br />
  -    *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -    *  method has been called on the <code>Collection</code><br />
  -    */
  -     public org.xmldb.api.base.Service getService(String name, String 
version) throws XMLDBException {
  -        checkOpen();
  -
  -        Service result = (Service) services.get(name + version);
  -
  -        return result;
  -     }
  -
  -     /**
  -      * Registers a new Service with this Collection.
  -      *
  -      * @param service Description of Parameter
  -      * @exception XMLDBException
  -      */
  -     public void registerService(org.xmldb.api.base.Service service) throws 
XMLDBException {
  -        //checkOpen();
  -
  -        service.setCollection(this);
  -        services.put(service.getName() + service.getVersion(), service);
  -     }
  -
  -     /**
  -     * Checks if the collection is still open. Only open collections are safe
  -      * to work with.
  -      *
  -      * @return whether the collection is still open
  -      */
  -     public abstract boolean isOpen();
  -     
  -    /**
  -     * Throws an exception if collection is no longer open
  -     *
  -     * @exception XMLDBException thrown if collection is closed
  -     */
  -    protected void checkOpen() throws XMLDBException {
  -       
  -        if (!isOpen()) {
  -            
  -            throw new XMLDBException(ErrorCodes.COLLECTION_CLOSED);
  -        }
  -    }
  -    
  -   /**
  -    * Returns the name associated with the <code>Collection</code> instance.
  -    *
  -    * @return the name of the object.
  -    */
  -    public String getName() {
  -        return collPath.substring(collPath.lastIndexOf('/') + 1);
  -    }
  -        
  -    /**
  -     * Returns complete path to collection
  -     *
  -     * @return the collection path
  -     */
  -    public String getCanonicalName() {
  -        
  -        return collPath;
  -    }
  -    
  -    /**
  -     * Returns XML:DB URI that would retrieve this collection
  -     *
  -     * @return a complete XML:DB URI
  -     */
  -    public abstract String getURI(); 
  -    
  -    /**
  -     * Constructs a new resource that will belong in this collection.
  -     *
  -     * Only XML resources are supported. To save the resource to the 
database, you
  -     * must first set the resource's XML data, and then call
  -     * <code>storeResource()</code>.
  -     *
  -     * @param name name for new resource. If empty or <code>null</code>, a 
name
  -     *        will be assigned when storing the resource in the database.
  -     * @param type must be <code>XMLResource</code>.
  -     * @exception XMLDBException thrown in case of an invalid resource type 
or name
  -     */
  -    public Resource createResource( String name, String type ) throws 
XMLDBException {
  -        if ( !"XMLResource".equals( type ) ) {
  -            throw new XMLDBException( ErrorCodes.UNKNOWN_RESOURCE_TYPE, 
"only XMLResources supported" );
  -        }
  -        
  -        if ( name == null || name.length() == 0 ) {
  -            // fulfill contract stating
  -            // "If id is null or its value is empty then an id is generated 
by calling createId()."
  -            name = createId();
  -        } else if ( name.indexOf('/') != -1 ) {
  -            throw new XMLDBException( ErrorCodes.INVALID_RESOURCE, "Name 
cannot contain '/'" );
  -        }
  -        
  -        return new XMLResourceImpl(name, this);
  -    }
  -    
  -    /**
  -     * Queries the entire collection and resturns the result
  -     *
  -     * @param queryLang <code>XUpdate</code> or <code>XPath</code>
  -     * @param query the text of the query statement
  -     * @param nsMap namespace bindings to use when evaluating query
  -     * @return set containing result of query
  -     * @throws XMLDBException thrown in case of invalid query or other error
  -     */
  -    public ResourceSet query(String queryLang, String query, Hashtable nsMap)
  -            throws XMLDBException {
  -                
  -        return query(null, queryLang, query, nsMap);
  -    }
  -
  -    /**
  -     * Queries a specific document or the entire collection and returns 
result
  -     *
  -     * @param name name of document to query, or <code>null</code> to query
  -     *        entire collection.
  -     * @param queryLang <code>XUpdate</code> or <code>XPath</code>.
  -     * @param query the text of the query statement
  -     * @param nsMap namespace bindings to use when evaluating query
  -     * @return set containing result of query
  -     * @throws XMLDBException thrown in case of invalid query or other error
  -     */
  -    public abstract ResourceSet query(String name, String queryLang, String 
query, Hashtable nsMap)
  -            throws XMLDBException;
  -     
  -    /**
  -     * Creates a new child collection in this collection
  -     *
  -     * @param name The name for new child collection
  -     * @return object representing newly created collection
  -     * @exception XMLDBException thrown if collection createion fails for 
some
  -     *                           reason
  -     */
  -    public abstract Collection createCollection(String name)
  -            throws XMLDBException;
  -
  -   /**
  -    * Creates a new child collection in this collection
  -    *
  -    * @param name The name for new child collection
  -    * @return object representing newly created collection
  -    * @exception XMLDBException thrown if collection createion fails for some
  -    *                           reason
  -    */
  -    public abstract Collection createCollection(String name, Document 
configuration) throws XMLDBException;
  -     
  -    /**
  -     * Removes child collection from this collection
  -     *
  -     * @param childName name of child collection
  -     * @exception XMLDBException thrown if collection createion fails for 
some
  -     *                           reason
  -     */
  -    public abstract void removeCollection(String childName) throws 
XMLDBException;
  -     
  -     /**
  -      * Returns a list of all indexers for this collection.
  -      *
  -      * @return the list of indexers
  -      * @exception XMLDBException
  -      */
  -     public abstract String[] listIndexers() throws XMLDBException;
  -
  -     /**
  -      * Creates a new Indexer for this collection.
  -      *
  -      * @param configuration The configuration to use for this indexer.
  -      * @exception XMLDBException
  -      */
  -     public abstract void createIndexer(Document configuration) throws 
XMLDBException;
  -
  -     /**
  -      * Drops the indexer from the collection
  -      *
  -      * @param name The name of the indexer to drop.
  -      * @exception XMLDBException
  -      */
  -     public abstract void dropIndexer(String name) throws XMLDBException;
  -
  -     /**
  -      * Shutsdown the Database instance
  -      *
  -      * @exception XMLDBException
  -      */
  -     public abstract void shutdown() throws XMLDBException;
  +public abstract class XindiceCollection extends CommonConfigurable 
implements Collection {
  +     /* Instantiated named services map */
  +     protected Hashtable services = null;
  +
  +     /* Xindice query result meta-info namespace */
  +     public static final String QUERY_NS = 
"http://xml.apache.org/xindice/Query";;
  +
  +     /* path to collection on target server */
  +     protected String collPath;
  +
  +     /**
  +      * Creates new <code>CollectionImpl</code> instance representing 
connection
  +      * to server collection.
  +      *
  +      * @exception XMLDBException thrown if a connection could not be 
established,
  +      *            because of URL syntax errors, or connection failure, or 
if no
  +      *            collection with path <code>collPath</code> could be 
located.
  +      */
  +     public XindiceCollection(String collPath) throws XMLDBException {
  +
  +             this.collPath = collPath.endsWith("/") ? collPath.substring(0, 
collPath.length() - 1) : collPath;
  +
  +             services = new Hashtable();
  +
  +             // Register all services supported by this collection 
implementation.
  +             XPathQueryServiceImpl xpath = new XPathQueryServiceImpl();
  +             xpath.setCollection(this);
  +             //        xpath.setSymbolDeserializer(syms);
  +             registerService(xpath);
  +
  +             XUpdateQueryServiceImpl xupdate = new XUpdateQueryServiceImpl();
  +             xupdate.setCollection(this);
  +             registerService(xupdate);
  +
  +             try {
  +                     CollectionManagementServiceImpl manager = new 
CollectionManagementServiceImpl();
  +                     manager.setCollection(this);
  +                     registerService(manager);
  +
  +                     // CollectionManagementServiceImpl provides both 
standard access as a
  +                     // CollectionManagementService and Xindice specific 
access as a
  +                     // CollectionManager and DatabaseInstanceManager.
  +                     // We need to register it explicitly to make it 
available
  +                     services.put("CollectionManager" + 
manager.getVersion(), manager);
  +                     services.put("DatabaseInstanceManager" + 
manager.getVersion(), manager);
  +             }
  +             catch (Exception e) {
  +                     throw FaultCodes.createXMLDBException(e);
  +             }
  +     }
  +
  +     /**
  +      * Provides a list of all services known to the collection. If no 
services
  +      * are known an empty list is returned.
  +      *
  +      * @return An array of registered <code>Service</code> implementations.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public Service[] getServices() throws XMLDBException {
  +             checkOpen();
  +
  +             Enumeration e = services.elements();
  +             Service[] result = new Service[services.size()];
  +
  +             int i = 0;
  +             while (e.hasMoreElements()) {
  +                     result[i] = (Service) e.nextElement();
  +                     i++;
  +             }
  +
  +             return result;
  +     }
  +
  +     /**
  +      * Returns a <code>Service</code> instance for the requested service 
name and version. If
  +      * no <code>Service</code> exists for those parameters a null value is 
returned.
  +      *
  +      * @param name Description of Parameter
  +      * @param version Description of Parameter
  +      * @return the Service instance or null if no Service could be found.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public org.xmldb.api.base.Service getService(String name, String 
version) throws XMLDBException {
  +             checkOpen();
  +
  +             Service result = (Service) services.get(name + version);
  +
  +             return result;
  +     }
  +
  +     /**
  +      * Registers a new Service with this Collection.
  +      *
  +      * @param service Description of Parameter
  +      * @exception XMLDBException
  +      */
  +     public void registerService(org.xmldb.api.base.Service service) throws 
XMLDBException {
  +             //checkOpen();
  +
  +             service.setCollection(this);
  +             services.put(service.getName() + service.getVersion(), service);
  +     }
  +
  +     /**
  +     * Checks if the collection is still open. Only open collections are safe
  +      * to work with.
  +      *
  +      * @return whether the collection is still open
  +      */
  +     public abstract boolean isOpen();
  +
  +     /**
  +      * Throws an exception if collection is no longer open
  +      *
  +      * @exception XMLDBException thrown if collection is closed
  +      */
  +     protected void checkOpen() throws XMLDBException {
  +
  +             if (!isOpen()) {
  +
  +                     throw new XMLDBException(ErrorCodes.COLLECTION_CLOSED);
  +             }
  +     }
  +
  +     /**
  +      * Returns the name associated with the <code>Collection</code> 
instance.
  +      *
  +      * @return the name of the object.
  +      */
  +     public String getName() {
  +             return collPath.substring(collPath.lastIndexOf('/') + 1);
  +     }
  +
  +     /**
  +      * Returns complete path to collection
  +      *
  +      * @return the collection path
  +      */
  +     public String getCanonicalName() {
  +
  +             return collPath;
  +     }
  +
  +     /**
  +      * Returns XML:DB URI that would retrieve this collection
  +      *
  +      * @return a complete XML:DB URI
  +      */
  +     public abstract String getURI();
  +
  +     /**
  +      * Constructs a new resource that will belong in this collection.
  +      *
  +      * Only XML resources are supported. To save the resource to the 
database, you
  +      * must first set the resource's XML data, and then call
  +      * <code>storeResource()</code>.
  +      *
  +      * @param name name for new resource. If empty or <code>null</code>, a 
name
  +      *        will be assigned when storing the resource in the database.
  +      * @param type must be <code>XMLResource</code>.
  +      * @exception XMLDBException thrown in case of an invalid resource type 
or name
  +      */
  +     public Resource createResource(String name, String type) throws 
XMLDBException {
  +             if (!"XMLResource".equals(type)) {
  +                     throw new 
XMLDBException(ErrorCodes.UNKNOWN_RESOURCE_TYPE, "only XMLResources supported");
  +             }
  +
  +             if (name == null || name.length() == 0) {
  +                     // fulfill contract stating
  +                     // "If id is null or its value is empty then an id is 
generated by calling createId()."
  +                     name = createId();
  +             }
  +             else if (name.indexOf('/') != -1) {
  +                     throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, 
"Name cannot contain '/'");
  +             }
  +
  +             return new XMLResourceImpl(name, this);
  +     }
  +
  +     /**
  +      * Queries the entire collection and resturns the result
  +      *
  +      * @param queryLang <code>XUpdate</code> or <code>XPath</code>
  +      * @param query the text of the query statement
  +      * @param nsMap namespace bindings to use when evaluating query
  +      * @return set containing result of query
  +      * @throws XMLDBException thrown in case of invalid query or other error
  +      */
  +     public ResourceSet query(String queryLang, String query, Hashtable 
nsMap) throws XMLDBException {
  +
  +             return query(null, queryLang, query, nsMap);
  +     }
  +
  +     /**
  +      * Queries a specific document or the entire collection and returns 
result
  +      *
  +      * @param name name of document to query, or <code>null</code> to query
  +      *        entire collection.
  +      * @param queryLang <code>XUpdate</code> or <code>XPath</code>.
  +      * @param query the text of the query statement
  +      * @param nsMap namespace bindings to use when evaluating query
  +      * @return set containing result of query
  +      * @throws XMLDBException thrown in case of invalid query or other error
  +      */
  +     public abstract ResourceSet query(String name, String queryLang, String 
query, Hashtable nsMap) throws XMLDBException;
  +
  +     /**
  +      * Creates a new child collection in this collection
  +      *
  +      * @param name The name for new child collection
  +      * @return object representing newly created collection
  +      * @exception XMLDBException thrown if collection createion fails for 
some
  +      *                           reason
  +      */
  +     public abstract Collection createCollection(String name) throws 
XMLDBException;
  +
  +     /**
  +      * Creates a new child collection in this collection
  +      *
  +      * @param name The name for new child collection
  +      * @return object representing newly created collection
  +      * @exception XMLDBException thrown if collection createion fails for 
some
  +      *                           reason
  +      */
  +     public abstract Collection createCollection(String name, Document 
configuration) throws XMLDBException;
  +
  +     /**
  +      * Removes child collection from this collection
  +      *
  +      * @param childName name of child collection
  +      * @exception XMLDBException thrown if collection createion fails for 
some
  +      *                           reason
  +      */
  +     public abstract void removeCollection(String childName) throws 
XMLDBException;
  +
  +     /**
  +      * Returns a list of all indexers for this collection.
  +      *
  +      * @return the list of indexers
  +      * @exception XMLDBException
  +      */
  +     public abstract String[] listIndexers() throws XMLDBException;
  +
  +     /**
  +      * Creates a new Indexer for this collection.
  +      *
  +      * @param configuration The configuration to use for this indexer.
  +      * @exception XMLDBException
  +      */
  +     public abstract void createIndexer(Document configuration) throws 
XMLDBException;
  +
  +     /**
  +      * Drops the indexer from the collection
  +      *
  +      * @param name The name of the indexer to drop.
  +      * @exception XMLDBException
  +      */
  +     public abstract void dropIndexer(String name) throws XMLDBException;
  +
  +     /**
  +      * Shutsdown the Database instance
  +      *
  +      * @exception XMLDBException
  +      */
  +     public abstract void shutdown() throws XMLDBException;
   
   }
  
  
  

Reply via email to