Interface BytesDocument
-
- All Superinterfaces:
FilterableDocument
,NoContentDocument
public interface BytesDocument extends FilterableDocument
A raw byte document.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description BytesDocument
cloneWithContent(DocumentType documentType, java.util.Optional<java.nio.charset.Charset> charset, byte[] content)
Creates a clone of the document with the given content.BytesDocument
cloneWithMetadata(com.google.common.collect.ListMultimap<java.lang.String,java.lang.String> metadata)
Gets a clone of the document with the given metadata.BytesDocument
cloneWithURI(java.net.URI uri)
Gets a clone of the document with a different URI.java.io.InputStream
contentAsInputStream()
Gets the contents of the document as an input stream.static BytesDocument
from(FilterableDocument filterableDocument)
Converts a FilterableDocument into a RawFilterableDocument-
Methods inherited from interface com.funnelback.filter.api.documents.FilterableDocument
cloneWithDocumentType, getCopyOfContents
-
Methods inherited from interface com.funnelback.filter.api.documents.NoContentDocument
getCharset, getCopyOfMetadata, getDocumentType, getMetadata, getURI
-
-
-
-
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 fromDocumentType
should be used, otherwise a custom value can be built withDocumentType.fromContentType(String)
.charset
- The charset of the content for exampleOptional.of(StandardCharsets.UTF_8)
if the charset is unknown setOptional.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 interfaceFilterableDocument
- 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 interfaceFilterableDocument
- Parameters:
metadata
- The only metadata that the returbed document will have.- Returns:
- A new document with the given headers.
-
-