public class ParsingReader
extends java.io.Reader
Parser
(AutoDetectParser
by default) to parse the text content from
a given input stream. The BodyContentHandler
class and a pipe
is used to convert the push-based SAX event stream to the pull-based
character stream defined by the Reader
interface.Constructor and Description |
---|
ParsingReader(java.io.File file)
Creates a reader for the text content of the given file.
|
ParsingReader(java.io.InputStream stream)
Creates a reader for the text content of the given binary stream.
|
ParsingReader(java.io.InputStream stream,
java.lang.String name)
Creates a reader for the text content of the given binary stream
with the given name.
|
ParsingReader(Parser parser,
java.io.InputStream stream,
Metadata metadata,
ParseContext context)
Creates a reader for the text content of the given binary stream
with the given document metadata.
|
ParsingReader(Parser parser,
java.io.InputStream stream,
Metadata metadata,
ParseContext context,
java.util.concurrent.Executor executor)
Creates a reader for the text content of the given binary stream
with the given document metadata.
|
ParsingReader(java.nio.file.Path path)
Creates a reader for the text content of the file at the given path.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the read end of the pipe.
|
int |
read(char[] cbuf,
int off,
int len)
Reads parsed text from the pipe connected to the parsing thread.
|
public ParsingReader(java.io.InputStream stream) throws java.io.IOException
stream
- binary streamjava.io.IOException
- if the document can not be parsedpublic ParsingReader(java.io.InputStream stream, java.lang.String name) throws java.io.IOException
stream
- binary streamname
- document namejava.io.IOException
- if the document can not be parsedpublic ParsingReader(java.nio.file.Path path) throws java.io.IOException
path
- pathjava.io.FileNotFoundException
- if the given file does not existjava.io.IOException
- if the document can not be parsedpublic ParsingReader(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException
file
- filejava.io.FileNotFoundException
- if the given file does not existjava.io.IOException
- if the document can not be parsedParsingReader(Path)
public ParsingReader(Parser parser, java.io.InputStream stream, Metadata metadata, ParseContext context) throws java.io.IOException
The created reader will be responsible for closing the given stream.
The stream and any associated resources will be closed at or before
the time when the close()
method is called on this reader.
parser
- parser instancestream
- binary streammetadata
- document metadatajava.io.IOException
- if the document can not be parsedpublic ParsingReader(Parser parser, java.io.InputStream stream, Metadata metadata, ParseContext context, java.util.concurrent.Executor executor) throws java.io.IOException
Reader
interface.
The created reader will be responsible for closing the given stream.
The stream and any associated resources will be closed at or before
the time when the close()
method is called on this reader.
parser
- parser instancestream
- binary streammetadata
- document metadatacontext
- parsing contextexecutor
- executor for the parsing taskjava.io.IOException
- if the document can not be parsedpublic int read(char[] cbuf, int off, int len) throws java.io.IOException
read
in class java.io.Reader
cbuf
- character bufferoff
- start offset within the bufferlen
- maximum number of characters to readjava.io.IOException
- if the parsing thread has failed or
if for some reason the pipe does not work properlypublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Reader
java.io.IOException
- if the pipe can not be closedCopyright © 2010 - 2020 Adobe. All Rights Reserved