Package com.norconex.importer.util.chunk
Class ChunkedTextReader
java.lang.Object
com.norconex.importer.util.chunk.ChunkedTextReader
Supplies chunks of text to the provided consumer. If a field matcher
is supplied, the text will be coming from matching document fields.
Otherwise, the document body is used. In either case, if the text
is greater than the
maxChunkSize, it is split and
read in chunks.
This class is a convenient way to apply similar logic whether the text
source is a document content, field, huge, or small.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuilder()static ChunkedTextReaderfrom(ChunkedTextSupport chunkedTextSupport) booleanread(@NonNull DocHandlerContext docCtx, @NonNull FailableFunction<TextChunk, Boolean, IOException> textConsumer) Handles the processing of document text, invoking the consumer as many times as necessary.
-
Method Details
-
from
-
read
public boolean read(@NonNull @NonNull DocHandlerContext docCtx, @NonNull @NonNull FailableFunction<TextChunk, Boolean, throws IOExceptionIOException> textConsumer) Handles the processing of document text, invoking the consumer as many times as necessary. If the field matcher is set, the streams to handle are coming from fields, otherwise it is the document content.- Parameters:
docCtx- document contexttextConsumer- text consumer- Returns:
trueif all chunks were read.falseif the chunk consumer ever returnedfalse.- Throws:
IOException- problem reading
-
builder
-