InputStreamWrapper (JiBX Java data binding to XML - Version 1.1.6a)
Date: 2008-06-08

Overview | Package | Class | Deprecated
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jibx.runtime.impl
Class InputStreamWrapper

    java.lang.Object
      org.jibx.runtime.impl.InputStreamWrapper

    public class InputStreamWrapper

extends java.lang.Object

Wrapper for input stream 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

Field Summary
`static int` | `DEFAULT_BUFFER_SIZE` Default input buffer size.

Constructor Summary
`InputStreamWrapper()` Constructor using default buffer size.
`InputStreamWrapper(int size)` Constructor.

Method Summary
`void` | `close()` Close document input.
`java.lang.String` | `getEncoding()` Get encoding for input document.
`java.io.Reader` | `getReader()` Get reader for wrapped input stream.
`void` | `reset()` Reset to initial state for reuse.
`void` | `setEncoding(java.lang.String enc)` Set encoding for stream.
`void` | `setInput(java.io.InputStream ins)` Set input stream with encoding to be defined later.
`void` | `setInput(java.io.InputStream ins, java.lang.String enc)` Set input stream with specified encoding.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_BUFFER_SIZE

    public static final int DEFAULT_BUFFER_SIZE

  Default input buffer size.

  See Also:
    Constant Field Values

Constructor Detail

### InputStreamWrapper

    public InputStreamWrapper(int size)

  Constructor.

### InputStreamWrapper

    public InputStreamWrapper()

  Constructor using default buffer size.

Method Detail

### setInput

    public void setInput(java.io.InputStream ins)

  Set input stream with encoding to be defined later. If an input stream is currently open when this is called the existing stream is closed, with any errors ignored.

  Parameters:
    `ins` - stream for document data input

### setInput

    public void setInput(java.io.InputStream ins,
                         java.lang.String enc)
                  throws java.io.IOException

  Set input stream with specified encoding. If an input stream is currently open when this is called the existing stream is closed, with any errors ignored.

  Parameters:
    `ins` - stream for document data input
    `enc` - character encoding used for input from stream (`null` if to be determined from XML input)
  Throws:
    `java.io.IOException`

### setEncoding

    public void setEncoding(java.lang.String enc)
                     throws java.io.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 (`null` if to be determined from XML input)
  Throws:
    `java.io.IOException` - if unknown encoding, or encoding already set

### getReader

    public java.io.Reader getReader()
                             throws java.io.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:
    `java.io.IOException` - if error reading from document or creating a reader for the encoding found

### getEncoding

    public java.lang.String getEncoding()

  Get encoding for input document. This call may not return an accurate result until after `getReader()` is called.

  Returns:
    character encoding for input document

### close

    public void close()
               throws java.io.IOException

  Close document input. Completes reading of document input, including closing the input medium.

  Throws:
    `java.io.IOException` - on error closing document

### reset

    public void reset()

  Reset to initial state for reuse.

Overview | Package | Class | Deprecated
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Project Web Site |