Interface BytesDocument
-
- All Superinterfaces:
FilterableDocument
,NoContentDocument
public interface BytesDocument extends FilterableDocument
A raw byte document.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BytesDocument
cloneWithContent(DocumentType documentType, Optional<Charset> charset, byte[] content)
Creates a clone of the document with the given content.BytesDocument
cloneWithMetadata(com.google.common.collect.ListMultimap<String,String> metadata)
Gets a clone of the document with the given metadata.BytesDocument
cloneWithURI(URI uri)
Gets a clone of the document with a different URI.InputStream
contentAsInputStream()
Gets the contents of the document as an input stream.-
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, Optional<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
FilterDocumentFactory.toStringDocument(FilterableDocument)
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 withDocumentTypeFactory.fromContentTypeHeader(String)
available from theFilterContext
.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
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.
-
cloneWithURI
BytesDocument cloneWithURI(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<String,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.
-
-