Package org.jibx.runtime.impl
Class InputStreamWrapper
- java.lang.Object
-
- org.jibx.runtime.impl.InputStreamWrapper
-
public class InputStreamWrapper extends Object
Wrapper for input buffer that supports multiple character encodings. This is needed because the XPP3 pull parser does not support detecting the character encoding for a document based on the content of the document. If used with a common encoding this performs the conversion to characters using an inner reader class; otherwise, this creates the appropriate reader type- Author:
- Dennis M. Sosnoski
-
-
Constructor Summary
Constructors Constructor Description InputStreamWrapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close document input.IInByteBuffergetBuffer()Get input buffer.StringgetEncoding()Get encoding for input document.ReadergetReader()Get reader for wrapped input stream.voidreset()Reset to initial state for reuse.voidsetBuffer(IInByteBuffer buff)Set the input buffer.voidsetEncoding(String enc)Set encoding for stream.
-
-
-
Method Detail
-
setBuffer
public void setBuffer(IInByteBuffer buff)
Set the input buffer.- Parameters:
buff- Buffer in
-
getBuffer
public IInByteBuffer getBuffer()
Get input buffer.- Returns:
- buffer,
nullif none set
-
setEncoding
public void setEncoding(String enc) throws IOException
Set encoding for stream. This call is only valid if the encoding has not been set previously, and if the encoding is a recognized type.- Parameters:
enc- character encoding used for input from stream (nullif to be determined from XML input)- Throws:
IOException- if unknown encoding, or encoding already set
-
getReader
public Reader getReader() throws IOException
Get reader for wrapped input stream. This creates and returns a reader using the appropriate encoding, if necessary reading and examining the first part of the stream (including the XML declaration, if present) to determine the encoding.- Returns:
- reader
- Throws:
IOException- if error reading from document or creating a reader for the encoding found
-
getEncoding
public String getEncoding()
Get encoding for input document. This call may not return an accurate result until aftergetReader()is called.- Returns:
- character encoding for input document
-
close
public void close() throws IOExceptionClose document input. Completes reading of document input, including closing the input medium.- Throws:
IOException- on error closing document
-
reset
public void reset()
Reset to initial state for reuse.
-
-