org.idoox.transport
Class RawInputMessage

java.lang.Object
  extended byjava.io.InputStream
      extended byorg.idoox.transport.InputMessage
          extended byorg.idoox.transport.RawInputMessage
All Implemented Interfaces:
Message
Direct Known Subclasses:
InputMessageWrapper

public abstract class RawInputMessage
extends InputMessage

Raw input message. This class is useful for transport implementation which needs wrap another input stream.

Component:
Core

Field Summary
protected  boolean isInited
          If this stream is initialized.
 
Fields inherited from interface org.idoox.transport.Message
CT_APPLICATION_DIME, CT_MULTIPART_ALTERNATIVE, CT_MULTIPART_MIXED, CT_MULTIPART_RELATED, CT_MUTLIPART_FORMDATA, SC_ACCEPTED, SC_BAD_MESSAGE, SC_CREATED, SC_FORBIDDEN, SC_INTERNAL_ERROR, SC_METHOD_NOT_ALLOWED, SC_NO_CONTENT, SC_NOT_FOUND, SC_OK, SC_PROTOCOL_NOT_SUPPORTED, SC_REQUEST_TIMEOUT, SC_SERVICE_UNAVAILABLE, SC_SOAP_ACTION_REQUIRED, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE
 
Constructor Summary
RawInputMessage(java.io.InputStream stream)
          Creates new raw input message.
 
Method Summary
 int available()
          Gets available bytes from the wrapped stream.
 void close()
          Closes the wrapped stream.
 java.io.InputStream getWrappedStream()
          Gets a wrapped input stream.
protected  void initStream()
          This method is called before the first operation with the stream is called.
 void mark(int readlimit)
          Marks the wrapped stream.
 boolean markSupported()
          Gets if there is mark supported in the wrapped stream.
 int read()
          Reads from the wrapped stream.
 int read(byte[] b)
          Reads from the wrapped stream.
 int read(byte[] b, int off, int len)
          Reads from the wrapped stream.
 void reset()
          Resets the wrapped stream.
 void setWrappedStream(java.io.InputStream stream)
          Sets new wrapped input stream.
 long skip(long n)
          Skips in the wrapped stream.
 
Methods inherited from class org.idoox.transport.InputMessage
getContentType, getDateHeader, getHeaderNames, getIntHeader, getMultipartType, getStatusCode, getStringHeader, nextPart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isInited

protected boolean isInited
If this stream is initialized.

Constructor Detail

RawInputMessage

public RawInputMessage(java.io.InputStream stream)
Creates new raw input message.

Parameters:
stream - the stream which is wrapped
Method Detail

setWrappedStream

public void setWrappedStream(java.io.InputStream stream)
Sets new wrapped input stream.

Parameters:
stream - wrapped stream

getWrappedStream

public java.io.InputStream getWrappedStream()
Gets a wrapped input stream.

Returns:
wrapped stream

read

public int read()
         throws java.io.IOException
Reads from the wrapped stream.

Returns:
the next byte of data, or -1 if the end of the stream is reached
Throws:
java.io.IOException - if an I/O error occurs

read

public int read(byte[] b)
         throws java.io.IOException
Reads from the wrapped stream.

Parameters:
b - the buffer into which the data is read
Returns:
the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached
Throws:
java.io.IOException - if an I/O error occurs

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads from the wrapped stream.

Parameters:
b - the buffer into which the data is read
off - the start offset in array b at which the data is written
len - the maximum number of bytes to read
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached
Throws:
java.io.IOException - if an I/O error occurs

skip

public long skip(long n)
          throws java.io.IOException
Skips in the wrapped stream.

Parameters:
n - the number of bytes to be skipped
Returns:
the actual number of bytes skipped
Throws:
java.io.IOException - if an I/O error occurs

available

public int available()
              throws java.io.IOException
Gets available bytes from the wrapped stream.

Returns:
the number of bytes that can be read from this input stream without blocking
Throws:
java.io.IOException - if an I/O error occurs

close

public void close()
           throws java.io.IOException
Closes the wrapped stream.

Throws:
java.io.IOException - if an I/O error occurs

mark

public void mark(int readlimit)
Marks the wrapped stream.

Parameters:
readlimit - the maximum limit of bytes that can be read before the mark position becomes invalid

reset

public void reset()
           throws java.io.IOException
Resets the wrapped stream.

Throws:
java.io.IOException - if this stream has not been marked or if the mark has been invalidated

markSupported

public boolean markSupported()
Gets if there is mark supported in the wrapped stream.

Returns:
true if this true type supports the mark and reset method; false otherwise

initStream

protected void initStream()
                   throws java.io.IOException
This method is called before the first operation with the stream is called.

Throws:
java.io.IOException