Interface BytesDocument

    • Method Detail

      • cloneWithContent

        BytesDocument cloneWithContent​(DocumentType documentType,
                                       java.util.Optional<java.nio.charset.Charset> charset,
                                       byte[] content)
        Creates a clone of the document with the given content.

        If the charset is known, it usually better to create a new StringDocument using StringDocument.from(FilterableDocument, DocumentType, String) as most filters work on Strings.

        Parameters:
        documentType - the type of content. Typically a predefined type from DocumentType should be used, otherwise a custom value can be built with DocumentType.fromContentType(String).
        charset - The charset of the content for example Optional.of(StandardCharsets.UTF_8) if the charset is unknown set Optional.empty().
        content - The content to set the document to.
        Returns:
        a clone of this document with the given content.
      • contentAsInputStream

        java.io.InputStream contentAsInputStream()
        Gets the contents of the document as an input stream.

        This is probably cheaper than getting a copy of the bytes and wrapping that in your own input stream.

        Returns:
        the contents of the document as an input stream.
      • from

        static BytesDocument from​(FilterableDocument filterableDocument)
        Converts a FilterableDocument into a RawFilterableDocument
        Parameters:
        filterableDocument - used to construct the ByteDocument.
        Returns:
        a ByteDocument constructed from the given document.
      • cloneWithURI

        BytesDocument cloneWithURI​(java.net.URI uri)
        Gets a clone of the document with a different URI.
        Specified by:
        cloneWithURI in interface FilterableDocument
        Parameters:
        uri - the document returned document will have.
        Returns:
        A new document with the given URI.
      • cloneWithMetadata

        BytesDocument cloneWithMetadata​(com.google.common.collect.ListMultimap<java.lang.String,​java.lang.String> metadata)
        Gets a clone of the document with the given metadata.

        Note that the returned document will only have the metadata given as a paramater to this method. Typically the result of NoContentDocument.getCopyOfMetadata() should be manipulated then passed to this function to preserve existing metadata.

        Specified by:
        cloneWithMetadata in interface FilterableDocument
        Parameters:
        metadata - The only metadata that the returbed document will have.
        Returns:
        A new document with the given headers.