Class DocumentFactory


  • public abstract class DocumentFactory
    extends java.lang.Object
    The DocumentFactory class is an abstraction which is used to create Document objects from various sources of content (URLs, JCR nodes, etc.)
    • Constructor Detail

      • DocumentFactory

        public DocumentFactory()
    • Method Detail

      • setInstance

        public static void setInstance​(DocumentFactory instance)
        Sets the DocumentFactory implementation in the factory which can be used for the creation of Document objects
        Parameters:
        instance -
      • getInstance

        public static DocumentFactory getInstance()
        Returns the DocumentFactoryInstance from the factory
        Returns:
        DocumentFactory instance
      • newDocument

        public abstract Document newDocument​(byte[] data)
        Creates a Document from a byte-array.
        Parameters:
        data - The byte-array serving as the content-source for the Document.
        Returns:
        Document
      • newDocument

        public abstract Document newDocument​(java.io.File file)
        Creates a Document from a file. Equivalent to newDocument(file, false). See newDocument(java.io.File, boolean) for more details.
        Parameters:
        file - The file serving as the content-source for the Document.
        Returns:
        Document
      • newDocument

        public abstract Document newDocument​(java.io.File file,
                                             boolean ownFile)
        Creates a Document from a file. The Document also starts "managing" the file if the ownFile parameter is true,
        Parameters:
        file - The file serving as the content-source for the Document.
        ownFile - Whether the file is henceforth to be managed by the Document.
        Returns:
        Document
      • newDocument

        public abstract Document newDocument​(java.net.URL url)
        Creates a Document from a URL.
        Parameters:
        url - The URL serving as the content-source for the Document.
        Returns:
        Document
      • newDocument

        public abstract Document newDocument​(java.io.InputStream is)
        Creates a Document from an input-stream.
        Parameters:
        is - The input-stream serving as the content-source for the Document.
        Returns:
        Document
      • newDocument

        public abstract Document newDocument​(java.lang.String jcrPath)
        Creates a Document from the path of a JCR node.
        Parameters:
        jcrPath - The path of the JCR-node serving as the content-source for the Document.
        Returns:
        Document
      • newDocument

        public abstract Document newDocument​(java.lang.String jcrPath,
                                             ResourceResolver resolver)
        Creates a Document from the path of a JCR node. The Document uses the provided resource-resolver for resolving the given path. Equivalent to newDocument(jcrPath, resolver, false). See newDocument(String, org.apache.sling.api.resource.ResourceResolver, boolean) for more details.
        Parameters:
        jcrPath - The path of the JCR-node serving as the content-source for the Document.
        resolver - The resource-resolver to be used for resolving the given path.
        Returns:
        Document
      • newDocument

        public abstract Document newDocument​(java.lang.String jcrPath,
                                             ResourceResolver resolver,
                                             boolean manageResolver)
        Creates a Document from the path of a JCR node. The Document uses the provided resource-resolver for resolving the given path. The Document also starts "managing" the resolver if the manageResolver parameter is true
        Parameters:
        jcrPath - The path of the JCR-node serving as the content-source for the Document.
        resolver - The resource-resolver to be used for resolving the given path.
        manageResolver - Whether the resource-resolver is henceforth to be managed by the Document.
        Returns:
        Document