Class CollectionImpl

    • Constructor Detail

      • CollectionImpl

        public CollectionImpl​(java.lang.String path)
                       throws java.io.FileNotFoundException,
                              XMLDBException
        Throws:
        java.io.FileNotFoundException
        XMLDBException
    • Method Detail

      • getName

        public java.lang.String getName()
                                 throws XMLDBException
        Returns the name of the collection
        Specified by:
        getName in interface Collection
        Overrides:
        getName in class SimpleCollection
        Returns:
        the name of the object.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
      • getParentCollection

        public Collection getParentCollection()
                                       throws XMLDBException
        Returns the parent collection for this collection or null if no parent collection exists.
        Specified by:
        getParentCollection in interface Collection
        Overrides:
        getParentCollection in class SimpleCollection
        Returns:
        the parent Collection instance.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
        ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection
      • getChildCollectionCount

        public int getChildCollectionCount()
                                    throws XMLDBException
        Returns the number of child collections under this Collection.
        Specified by:
        getChildCollectionCount in interface Collection
        Overrides:
        getChildCollectionCount in class SimpleCollection
        Returns:
        the number of child collections.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
        ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection
      • listChildCollections

        public java.lang.String[] listChildCollections()
                                                throws XMLDBException
        Returns a list of collection names naming all child collections of the current collection.
        Specified by:
        listChildCollections in interface Collection
        Overrides:
        listChildCollections in class SimpleCollection
        Returns:
        an array containing collection names for all child collections.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
        ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection
      • getChildCollection

        public Collection getChildCollection​(java.lang.String name)
                                      throws XMLDBException
        Returns a Collection instance for the requested child collection if it exists.
        Specified by:
        getChildCollection in interface Collection
        Overrides:
        getChildCollection in class SimpleCollection
        Parameters:
        name - the name of the child collection to retrieve.
        Returns:
        the requested child collection or null if it couldn't be found.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
        ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection
      • getResourceCount

        public int getResourceCount()
                             throws XMLDBException
        Returns the number of resources currently stored in this collection or 0 if the collection is empty.
        Specified by:
        getResourceCount in interface Collection
        Overrides:
        getResourceCount in class SimpleCollection
        Returns:
        the number of resources in the collection.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
      • listResources

        public java.lang.String[] listResources()
                                         throws XMLDBException
        Returns a list of the ids for all resources stored in the collection.
        Specified by:
        listResources in interface Collection
        Overrides:
        listResources in class SimpleCollection
        Returns:
        a string array containing the names for all Resources in the collection.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
      • createResource

        public Resource createResource​(java.lang.String id,
                                       java.lang.String type)
                                throws XMLDBException
        Creates a new empty Resource with the provided id.
        Specified by:
        createResource in interface Collection
        Overrides:
        createResource in class SimpleCollection
        Parameters:
        id - the unique id to associate with the created Resource.
        type - the Resource type to create.
        Returns:
        an empty Resource instance.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
        ErrorCodes.UNKNOWN_RESOURCE_TYPE if the type parameter is not a known Resource type.
      • removeResource

        public void removeResource​(Resource res)
                            throws XMLDBException
        Removes the Resource from the database.
        Specified by:
        removeResource in interface Collection
        Overrides:
        removeResource in class SimpleCollection
        Parameters:
        res - the resource to remove.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
        ErrorCodes.INVALID_RESOURCE if the Resource is not valid.
        ErrorCodes.NO_SUCH_RESOURCE if the Resource is not known to this Collection.
      • storeResource

        public void storeResource​(Resource res)
                           throws XMLDBException
        Stores the provided resource into the database.
        Specified by:
        storeResource in interface Collection
        Overrides:
        storeResource in class SimpleCollection
        Parameters:
        res - the resource to store in the database.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
        ErrorCodes.INVALID_RESOURCE if the Resource is not valid.
      • getResource

        public Resource getResource​(java.lang.String id)
                             throws XMLDBException
        Retrieves a Resource from the database.
        Specified by:
        getResource in interface Collection
        Overrides:
        getResource in class SimpleCollection
        Parameters:
        id - the unique id for the requested resource.
        Returns:
        The retrieved Resource instance.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
      • createId

        public java.lang.String createId()
                                  throws XMLDBException
        Creates a new unique ID within the context of the Collection
        Specified by:
        createId in interface Collection
        Overrides:
        createId in class SimpleCollection
        Returns:
        the created id as a string.
        Throws:
        XMLDBException - with expected error codes.
        ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.