Class ParserPipe
- All Implemented Interfaces:
- Closeable,- AutoCloseable
For character-based parsers, the input object can be any of the following:
- Reader
- CharSequence
- InputStream
- byte []
- File
- null 
For stream-based parsers, the input object can be any of the following:
- InputStream
- byte []
- File
- String- Hex-encoded bytes. (not BASE-64!)
- null 
 Note that Readers and InputStreams will NOT be automatically closed when close() is called, but
 streams and readers created from other types (e.g. Files) WILL be automatically closed.
 
See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionParserPipe(Object input) Shortcut constructor, typically for straight string input.ParserPipe(Object input, boolean debug, boolean strict, boolean autoCloseStreams, boolean unbuffered, Charset streamCharset, Charset fileCharset) Constructor for reader-based parsers.ParserPipe(Object input, boolean debug, boolean autoCloseStreams, boolean unbuffered, BinaryFormat binaryFormat) Constructor for stream-based parsers.
- 
Method SummaryModifier and TypeMethodDescriptionasString()Returns the contents of this pipe as a string.voidclose()Returns the contents of this pipe as a buffered reader.Returns the input to this parser as a plain string.Wraps the specified input object inside an input stream.Converts this pipe into aParserReader.Wraps the specified input object inside a reader.booleanisString()Returnstrue if the contents passed into this pipe was aCharSequence.voidsetPositionable(Positionable positionable) Sets the ParserReader/ParserInputStream/XmlReader constructed from this pipe.
- 
Constructor Details- 
ParserPipepublic ParserPipe(Object input, boolean debug, boolean strict, boolean autoCloseStreams, boolean unbuffered, Charset streamCharset, Charset fileCharset) Constructor for reader-based parsers.- Parameters:
- input- The parser input object.
- debug- If- true , the input contents will be copied locally and accessible via the- getInputAsString()method. This allows the contents of the pipe to be accessed when a problem occurs.
- strict- If- true , sets- CodingErrorAction.REPORTon- CharsetDecoder.onMalformedInput(CodingErrorAction)and- CharsetDecoder.onUnmappableCharacter(CodingErrorAction). Otherwise, sets them to- CodingErrorAction.REPLACE.
- autoCloseStreams- Automatically close- InputStreamsand- Readerswhen passed in as input.
- unbuffered- If- true , we read one character at a time from underlying readers when the readers are expected to be parsed multiple times.
 Otherwise, we read character data into a reusable buffer.
- fileCharset- The charset to expect when reading from- Files.
- streamCharset- The charset to expect when reading from- InputStreams.
 
- 
ParserPipepublic ParserPipe(Object input, boolean debug, boolean autoCloseStreams, boolean unbuffered, BinaryFormat binaryFormat) Constructor for stream-based parsers.- Parameters:
- input- The parser input object.
- debug- If- true , the input contents will be copied locally and accessible via the- getInputAsString()method. This allows the contents of the pipe to be accessed when a problem occurs.
- autoCloseStreams- Automatically close- InputStreamsand- Readerswhen passed in as input.
- unbuffered- If- true , we read one character at a time from underlying readers when the readers are expected to be parsed multiple times.
 Otherwise, we read character data into a reusable buffer.
- binaryFormat- The binary format of input strings when converted to bytes.
 
- 
ParserPipeShortcut constructor, typically for straight string input.Equivalent to calling new ParserPipe(input,false ,false ,null ,null );- Parameters:
- input- The input object.
 
 
- 
- 
Method Details- 
getInputStreamWraps the specified input object inside an input stream.Subclasses can override this method to implement their own input streams. - Returns:
- The input object wrapped in an input stream, or null if the object is null.
- Throws:
- IOException- If object could not be converted to an input stream.
 
- 
getReaderWraps the specified input object inside a reader.Subclasses can override this method to implement their own readers. - Returns:
- The input object wrapped in a Reader, or null if the object is null.
- Throws:
- IOException- If object could not be converted to a reader.
 
- 
getBufferedReaderReturns the contents of this pipe as a buffered reader.If the reader passed into this pipe is already a buffered reader, that reader will be returned. - Returns:
- The contents of this pipe as a buffered reader.
- Throws:
- IOException- Thrown by underlying stream.
 
- 
getInputAsStringReturns the input to this parser as a plain string.This method only returns a value if Context.Builder.debug()is enabled.- Returns:
- The input as a string, or null if debug mode not enabled.
 
- 
asStringReturns the contents of this pipe as a string.- Returns:
- The contents of this pipe as a string.
- Throws:
- IOException- If thrown from inner reader.
 
- 
getParserReaderConverts this pipe into aParserReader.- Returns:
- The converted pipe.
- Throws:
- IOException- Thrown by underlying stream.
 
- 
isStringReturnstrue if the contents passed into this pipe was aCharSequence.- Returns:
- true if the contents passed into this pipe was a- CharSequence.
 
- 
setPositionableSets the ParserReader/ParserInputStream/XmlReader constructed from this pipe.Used for gathering the failure position when ParseExceptionis thrown.- Parameters:
- positionable- The ParserReader/ParserInputStream/XmlReader constructed from this pipe.
 
- 
close- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
 
-