| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.sourceforge.jtds.jdbc.ResponseStream
Implements an input stream for the server response.
Implementation note:
| Nested Class Summary | |
| private static class | ResponseStream.TdsInputStreamSimple inner class implementing an InputStreamover the
 server response. | 
| Field Summary | |
| private  byte[] | bufferThe Input packet buffer. | 
| private  int | bufferLenThe length of current input packet. | 
| private  int | bufferPtrThe offset of the next byte to read. | 
| private  byte[] | byteBufferA shared byte buffer. | 
| private  char[] | charBufferA shared char buffer. | 
| private  boolean | isClosedTrue if stream is closed. | 
| private  SharedSocket | socketThe shared network socket. | 
| private  int | streamIdThe unique stream id. | 
| Constructor Summary | |
| (package private) | ResponseStream(SharedSocket socket,
               int streamId,
               int bufferSize)Constructs a RequestStreamobject. | 
| Method Summary | |
| (package private)  void | close()Closes this response stream. | 
| (package private)  java.io.InputStream | getInputStream(int len)Creates a simple InputStreamover the server response. | 
| private  void | getPacket()Read the next TDS packet from the network. | 
| (package private)  int | getServerType()Retrieves the server type. | 
| (package private)  int | getStreamId()Retrieves the unique stream id. | 
| (package private)  int | getTdsVersion()Retrieves the TDS version number. | 
| (package private)  int | peek()Retrieves the next input byte without reading forward. | 
| (package private)  int | read()Reads the next input byte from the server response stream. | 
| (package private)  int | read(byte[] b)Reads a byte array from the server response stream. | 
| (package private)  int | read(byte[] b,
     int off,
     int len)Reads a byte array from the server response stream, specifying a start offset and length. | 
| (package private)  int | read(char[] c)Reads a char array from the server response stream. | 
| (package private)  int | readInt()Reads an intvalue from the server response stream. | 
| (package private)  long | readLong()Reads a longvalue from the server response stream. | 
| (package private)  java.lang.String | readNonUnicodeString(int len)Reads a non Unicode Stringfrom the server response stream,
 creating theStringfrom a translatedbytearray. | 
| (package private)  java.lang.String | readNonUnicodeString(int len,
                     CharsetInfo charsetInfo)Reads a Stringfrom the server response stream, translating
 it from abytearray using the specified character set. | 
| (package private)  short | readShort()Reads a shortvalue from the server response stream. | 
| (package private)  java.lang.String | readString(int len)Reads a Stringobject from the server response stream. | 
| (package private)  java.lang.String | readString(int len,
           CharsetInfo info)Reads a Stringfrom the server response stream, creating
 it from a translatedbytearray. | 
| (package private)  java.lang.String | readUnicodeString(int len)Reads a UCS2-LE (Unicode) encoded String object from the server response stream. | 
| (package private)  java.math.BigDecimal | readUnsignedLong()Reads an unsigned longvalue from the server response stream. | 
| (package private)  int | skip(int skip)Discards bytes from the server response stream. | 
| (package private)  void | skipString(int len)Skips a Stringfrom the server response stream. | 
| (package private)  void | skipToEnd()Consumes the rest of the server response, without parsing it. | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
private final SharedSocket socket
private byte[] buffer
private int bufferPtr
private int bufferLen
private final int streamId
private boolean isClosed
private final byte[] byteBuffer
private final char[] charBuffer
| Constructor Detail | 
ResponseStream(SharedSocket socket,
               int streamId,
               int bufferSize)
RequestStream object.
socket - the shared socket object to write tostreamId - the unique id for this stream (from ResponseStream)bufferSize - the initial buffer size| Method Detail | 
int getStreamId()
intint peek() throws java.io.IOException
int
java.io.IOException - if an I/O error occursint read() throws java.io.IOException
int
java.io.IOException - if an I/O error occursint read(byte[] b) throws java.io.IOException
b - the byte array to read into
int
java.io.IOException - if an I/O error occurs
int read(byte[] b,
         int off,
         int len)
   throws java.io.IOException
b - the byte arrayoff - the starting offset in the arraylen - the number of bytes to read
int
java.io.IOException - if an I/O error occursint read(char[] c) throws java.io.IOException
c - the char array
byte[]
java.io.IOException - if an I/O error occurs
java.lang.String readString(int len)
                      throws java.io.IOException
String object from the server response stream. If
 the TDS protocol version is 4.2 or 5.0 decode the string use the default
 server charset, otherwise use UCS2-LE (Unicode).
len - the length of the string to read in bytes in the case
            of TDS 4.2/5.0 and in characters for TDS 7.0+
            (UCS2-LE encoded strings)
String
java.io.IOException - if an I/O error occurs
void skipString(int len)
          throws java.io.IOException
String from the server response stream. If the TDS
 protocol version is 4.2 or 5.0 len is the length in bytes,
 otherwise it's the length in UCS2-LE characters (length in bytes == 2 *
 len).
len - the length of the string to skip in bytes in the case
            of TDS 4.2/5.0 and in characters for TDS 7.0+
            (UCS2-LE encoded strings)
java.io.IOException - if an I/O error occurs
java.lang.String readUnicodeString(int len)
                             throws java.io.IOException
len - the length of the string to read in characters
String
java.io.IOException - if an I/O error occurs
java.lang.String readNonUnicodeString(int len)
                                throws java.io.IOException
String from the server response stream,
 creating the String from a translated byte
 array.
len - the length of the string to read in bytes
String
java.io.IOException - if an I/O error occurs
java.lang.String readNonUnicodeString(int len,
                                      CharsetInfo charsetInfo)
                                throws java.io.IOException
String from the server response stream, translating
 it from a byte array using the specified character set.
len - the length of the string to read in bytes
String
java.io.IOException - if an I/O error occurs
java.lang.String readString(int len,
                            CharsetInfo info)
                      throws java.io.IOException
String from the server response stream, creating
 it from a translated byte array.
len - the length of the string to read in bytesinfo - descriptor of the charset to use
String
java.io.IOException - if an I/O error occurs
short readShort()
          throws java.io.IOException
short value from the server response stream.
short
java.io.IOException - if an I/O error occurs
int readInt()
      throws java.io.IOException
int value from the server response stream.
int
java.io.IOException - if an I/O error occurs
long readLong()
        throws java.io.IOException
long value from the server response stream.
long
java.io.IOException - if an I/O error occurs
java.math.BigDecimal readUnsignedLong()
                                throws java.io.IOException
unsigned long value from the server response stream.
BigDecimal
java.io.IOException - if an I/O error occursint skip(int skip) throws java.io.IOException
skip - the number of bytes to discard
java.io.IOExceptionvoid skipToEnd()
void close()
int getTdsVersion()
intint getServerType()
intjava.io.InputStream getInputStream(int len)
InputStream over the server response.
 
 This method can be used to obtain a stream which can be passed to
 InputStreamReaders to assist in reading multi byte
 character sets.
len - the number of bytes available in the server response
InputStream built over the server response
private void getPacket()
                throws java.io.IOException
java.io.IOException - if an I/O error occurs| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||