Package net.sf.saxon.resource

## Class CatalogCollection

- java.lang.Object
- - net.sf.saxon.resource.AbstractResourceCollection
  - - net.sf.saxon.resource.CatalogCollection

- All Implemented Interfaces:
    `ResourceCollection`

      public class CatalogCollection
      extends AbstractResourceCollection

  A resource collection implemented by means of a catalog file.

  An example catalog file would be:

       <collection stable="true">
          <doc href="dir/contents.json"/>
          <doc href="dir/chap1.xml"/>
          <doc href="dir/chap2.xml"/>
          <doc href="dir/chap3.xml"/>
          <doc href="dir/chap4.xml"/>
          <doc href="dir/index.json"/>
       </collection>

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class net.sf.saxon.resource.AbstractResourceCollection

      `AbstractResourceCollection.InputDetails`

  - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.resource.AbstractResourceCollection

      `collectionURI, config, params`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CatalogCollection​(Configuration config, java.lang.String collectionURI)` | Create a catalog collection

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected java.util.Iterator<java.lang.String>` | `catalogContents​(java.lang.String href, XPathContext context)` | Return a collection defined as a list of URIs in a catalog file
    `java.util.Iterator<Resource>` | `getResources​(XPathContext context)` | Get the resources in the collection.
    `java.util.Iterator<java.lang.String>` | `getResourceURIs​(XPathContext context)` | Get the URIs of the resources in the collection.
    `boolean` | `isStable​(XPathContext context)` | Ask whether the collection is stable.
    `static java.lang.StringBuilder` | `makeStringBuilderFromStream​(java.io.InputStream in, java.lang.String encoding)` | Return a StringBuilder initialized to the contents of an InputStream

    - ### Methods inherited from class net.sf.saxon.resource.AbstractResourceCollection

      `getCollectionURI, getInputDetails, guessContentTypeFromContent, guessContentTypeFromName, makeResource, makeResource, makeTypedResource, optionsFromQueryParameters, registerContentType, setupErrorHandlingForCollection, stripWhitespace`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CatalogCollection

          public CatalogCollection​(Configuration config,
                                   java.lang.String collectionURI)

      Create a catalog collection
      Parameters:
        `config` - the Saxon Configuration
        `collectionURI` - the collection URI, which represents the location of the catalog file

  - ### Method Detail

    - #### getResourceURIs

          public java.util.Iterator<java.lang.String> getResourceURIs​(XPathContext context)
                                                               throws XPathException

      Description copied from interface: `ResourceCollection`
      Get the URIs of the resources in the collection. This supports the fn:uri-collection() function. It is not required that all collections expose a list of URIs in this way, or that the URIs bear any particular relationship to the resources returned by the getResources() method for the same collection URI. The URIs that are returned should be suitable for passing to the registered URIResolver (in the case of XML resources), or the `UnparsedTextURIResolver` (in the case of unparsed text and JSON resources), etc.
      Parameters:
        `context` - the XPath evaluation context
      Returns:
        an iterator over the URIs of the resources in the collection. The URIs are represented as Strings. They should preferably be absolute URIs.
      Throws:
        `XPathException` - in the event of any error (for example, if the collection URI is not recognized)

    - #### getResources

          public java.util.Iterator<Resource> getResources​(XPathContext context)
                                                    throws XPathException

      Description copied from interface: `ResourceCollection`
      Get the resources in the collection. This supports the fn:collection() function. It is not required that all collections expose a set of resources in this way, or that the resources returned bear any particular relationship to the URIs returned by the getResourceURIs() method for the same collection URI.
      Parameters:
        `context` - the XPath evaluation context
      Returns:
        an iterator over the resources in the collection. This returns objects of class `Resource`.
      Throws:
        `XPathException` - in the event of any error (for example, if the collection URI is not recognized)

    - #### isStable

          public boolean isStable​(XPathContext context)

      Description copied from class: `AbstractResourceCollection`
      Ask whether the collection is stable. This method should only be called after calling `ResourceCollection.getResources(XPathContext)` or `ResourceCollection.getResourceURIs(XPathContext)`
      Specified by:
        `isStable` in interface `ResourceCollection`
      Overrides:
        `isStable` in class `AbstractResourceCollection`
      Parameters:
        `context` - the XPath evaluation context.
      Returns:
        true if the collection is defined to be stable, that is, if a subsequent call on collection() with the same URI is guaranteed to return the same result. The method returns true if the query parameter stable=yes is present in the URI, or if the configuration property `FeatureKeys.STABLE_COLLECTION_URI` is set.

    - #### makeStringBuilderFromStream

          public static java.lang.StringBuilder makeStringBuilderFromStream​(java.io.InputStream in,
                                                                            java.lang.String encoding)
                                                                     throws java.io.IOException

      Return a StringBuilder initialized to the contents of an InputStream
      Parameters:
        `in` - the input stream (which is consumed by this method)
      Returns:
        the StringBuilder, initialized to the contents of this InputStream
      Throws:
        `java.io.IOException` - if an error occurs reading the resource

    - #### catalogContents

          protected java.util.Iterator<java.lang.String> catalogContents​(java.lang.String href,
                                                                         XPathContext context)
                                                                  throws XPathException

      Return a collection defined as a list of URIs in a catalog file
      Parameters:
        `href` - the absolute URI of the catalog file
        `context` - the dynamic evaluation context
      Returns:
        an iterator over the documents in the collection
      Throws:
        `XPathException` - if any failures occur