com.marklogic.xcc.examples

## Class ContentFetcher

- java.lang.Object
- - com.marklogic.xcc.examples.ContentFetcher

-     public class ContentFetcher
      extends java.lang.Object

  This class fetches documents from the conentbase and writes their serialized contents to a provided `OutputStream`.

  Click here for the source code for this class

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ContentFetcher(java.net.URI serverUri)` Construct an instance that may be used to fetch documents.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `main(java.lang.String[] args)` Command-line main() method to fetch a document.
    `void` | `setRequestOptions(RequestOptions options)` Set (or clear) the `RequestOptions` instance to associate with submitted queries.

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

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

- - ### Constructor Detail

    - #### ContentFetcher

          public ContentFetcher(java.net.URI serverUri)
                         throws XccConfigException

      Construct an instance that may be used to fetch documents.
      Parameters:
        `serverUri` - A URI identifying a `ContentSource`, in the format expected by `ContentSourceFactory.newContentSource(java.net.URI)`.
      Throws:
        `XccConfigException` - Thrown if a `Session` cannot be created. This usually indicates that the host/port or user credentials are incorrect.

  - ### Method Detail

    - #### setRequestOptions

          public void setRequestOptions(RequestOptions options)

      Set (or clear) the `RequestOptions` instance to associate with submitted queries.

      Note: It's a good idea to set CachedResult=false. Since the data is being written straight out to an `OutputStream` there is no need to buffer the document first. Streaming will also accommodate arbitrarily large documents without running out of memory. Setting an options value of null will use defaults, which includes cached result mode.

      Parameters:
        `options` - An instance of `RequestOptions` or null.

    - #### main

          public static void main(java.lang.String[] args)
                           throws java.lang.Exception

      Command-line main() method to fetch a document.
      Parameters:
        `args` - Arg 1: A server URL as per `ContentSourceFactory.newContentSource(java.net.URI)`. Arg 2: A document URI. Optional Args 3&4: "-o outputfilename"
      Throws:
        `java.lang.Exception` - No exceptions are handled, anything that goes wrong will spew out a stack trace and exit.

Copyright © 2025 MarkLogic Corporation

Complete online documentation for MarkLogic Server, XQuery and related components may be found at docs.progress.com