com.infoengine.SAK
Class ContentInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended bycom.infoengine.SAK.ContentInputStream

public class ContentInputStream
extends InputStream

This class implements an input stream class for reading contents from MIME multipart streams.


Field Summary
private  String boundary
           
private  String contentType
           
private  String disposition
           
private  boolean eof
           
private  String fileName
           
private  Hashtable headers
           
private  byte[] inputBuffer
           
private  int inputBufferCursor
           
private  int inputBufferLimit
           
private  InputStream inputStream
           
private  String name
           
 
Fields inherited from class java.io.InputStream
 
Constructor Summary
ContentInputStream(InputStream inputStream, String boundary, boolean firstContent)
          Constructor that initializes the instance to read from a multipart stream.
 
Method Summary
 int available()
          Return the number of bytes that can be read without blocking.
 void close()
          Close the input stream.
 String getContentType()
           
 String getDisposition()
           
 boolean getEof()
           
 String getFileName()
           
 String getHeader(String key)
           
 Enumeration getHeaderKeys()
           
 Hashtable getHeaders()
           
 InputStream getInputStream()
           
 String getName()
           
 void mark(int readLimit)
          Mark the current position in the input stream.
 boolean markSupported()
          Return an indication of support for input stream marking.
private  void parseContentType(String heading)
           
private  void parseDisposition(String heading)
           
 int read()
          Return a byte from the input stream.
 int read(byte[] b)
          Read bytes from the input stream into an array.
 int read(byte[] buf, int off, int len)
          Read bytes from the input stream into an array or subarray.
 String readLine()
          Read a line of text from the client connection using the default character encoding for the platform.
private  int readLine(byte[] buf)
          Read until a specified buffer is full, or a newline ('\n') is encountered.
private  int readLine(byte[] buf, int start, int end)
           
 String readLine(String encoding)
          Read a line of text from the client connection using a specified character encoding.
 void reset()
          Reset input stream position to last mark.
 long skip(long n)
          Read and discard bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

boundary

private String boundary

contentType

private String contentType

disposition

private String disposition

eof

private boolean eof

fileName

private String fileName

headers

private Hashtable headers

inputStream

private InputStream inputStream

name

private String name

inputBuffer

private byte[] inputBuffer

inputBufferCursor

private int inputBufferCursor

inputBufferLimit

private int inputBufferLimit
Constructor Detail

ContentInputStream

public ContentInputStream(InputStream inputStream,
                          String boundary,
                          boolean firstContent)
                   throws IOException
Constructor that initializes the instance to read from a multipart stream.

Method Detail

parseDisposition

private void parseDisposition(String heading)
                       throws IOException
Throws:
IOException

parseContentType

private void parseContentType(String heading)
                       throws IOException
Throws:
IOException

available

public int available()
              throws IOException
Return the number of bytes that can be read without blocking.

Returns:
int number of bytes that can be read
Throws:
IOException

close

public void close()
           throws IOException
Close the input stream.

Throws:
IOException

mark

public void mark(int readLimit)
Mark the current position in the input stream.

Parameters:
readLimit - position to mark

markSupported

public boolean markSupported()
Return an indication of support for input stream marking.

Returns:
boolean mark support indication

read

public int read()
         throws IOException
Return a byte from the input stream.

Returns:
int next byte from input stream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException
Read bytes from the input stream into an array.

Parameters:
b - array
Returns:
int number of bytes read
Throws:
IOException

read

public int read(byte[] buf,
                int off,
                int len)
         throws IOException
Read bytes from the input stream into an array or subarray.

Parameters:
buf - array
off - offset of array at which to read bytes
len - maximum number of bytes to read
Returns:
int number of bytes read
Throws:
IOException

readLine

public String readLine()
                throws IOException
Read a line of text from the client connection using the default character encoding for the platform.

Returns:
String line of text, with end of line sequence removed
Throws:
IOException

readLine

public String readLine(String encoding)
                throws IOException
Read a line of text from the client connection using a specified character encoding.

Parameters:
encoding - the character encoding to apply to the connection
Returns:
String line of text, with end of line sequence removed
Throws:
IOException

reset

public void reset()
           throws IOException
Reset input stream position to last mark.

Throws:
IOException

skip

public long skip(long n)
          throws IOException
Read and discard bytes.

Parameters:
n - number of bytes to read and discard
Returns:
long actual number of bytes read and discarded
Throws:
IOException

getContentType

public String getContentType()

getDisposition

public String getDisposition()

getName

public String getName()

getFileName

public String getFileName()

getHeaders

public Hashtable getHeaders()

getHeader

public String getHeader(String key)

getHeaderKeys

public Enumeration getHeaderKeys()

getInputStream

public InputStream getInputStream()

getEof

public boolean getEof()

readLine

private int readLine(byte[] buf)
              throws IOException
Read until a specified buffer is full, or a newline ('\n') is encountered. The newline is included in the buffer if encountered.

Throws:
IOException

readLine

private int readLine(byte[] buf,
                     int start,
                     int end)
              throws IOException
Throws:
IOException