|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.jtds.jdbc.ResponseStream
Implements an input stream for the server response.
Implementation note:
Nested Class Summary | |
private static class |
ResponseStream.TdsInputStream
Simple inner class implementing an InputStream over the
server response. |
Field Summary | |
private SharedSocket.VirtualSocket |
_VirtualSocket
The VirtualSocket used by this stream. |
private byte[] |
buffer
The Input packet buffer. |
private int |
bufferLen
The length of current input packet. |
private int |
bufferPtr
The offset of the next byte to read. |
private byte[] |
byteBuffer
A shared byte buffer. |
private char[] |
charBuffer
A shared char buffer. |
private boolean |
isClosed
True if stream is closed. |
private SharedSocket |
socket
The shared network socket. |
Constructor Summary | |
(package private) |
ResponseStream(SharedSocket socket,
SharedSocket.VirtualSocket vsock,
int bufferSize)
Constructs a RequestStream object. |
Method Summary | |
(package private) void |
close()
Closes this response stream. |
(package private) java.io.InputStream |
getInputStream(int len)
Creates a simple InputStream over 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 |
getTdsVersion()
Retrieves the TDS version number. |
(package private) SharedSocket.VirtualSocket |
getVirtualSocket()
Retrieves the VirtualSocket used by this stream id. |
(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 int value from the server response stream. |
(package private) long |
readLong()
Reads a long value from the server response stream. |
(package private) java.lang.String |
readNonUnicodeString(int len)
Reads a non Unicode String from the server response stream,
creating the String from a translated byte
array. |
(package private) java.lang.String |
readNonUnicodeString(int len,
CharsetInfo charsetInfo)
Reads a String from the server response stream, translating
it from a byte array using the specified character set. |
(package private) short |
readShort()
Reads a short value from the server response stream. |
(package private) java.lang.String |
readString(int len)
Reads a String object from the server response stream. |
(package private) java.lang.String |
readString(int len,
CharsetInfo info)
Reads a String from the server response stream, creating
it from a translated byte array. |
(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 long value 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 String from 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 SharedSocket.VirtualSocket _VirtualSocket
VirtualSocket
used by this stream.
private boolean isClosed
private final byte[] byteBuffer
private final char[] charBuffer
Constructor Detail |
ResponseStream(SharedSocket socket, SharedSocket.VirtualSocket vsock, int bufferSize)
RequestStream
object.
socket
- the shared socket object to write tovsock
- the VirtualSocket
used by this stream (from ResponseStream)bufferSize
- the initial buffer sizeMethod Detail |
SharedSocket.VirtualSocket getVirtualSocket()
VirtualSocket
used by this stream id.
int
int 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 occursint 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 occursjava.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 occursvoid 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 occursjava.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 occursjava.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 occursjava.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 occursjava.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 occursshort readShort() throws java.io.IOException
short
value from the server response stream.
short
java.io.IOException
- if an I/O error occursint readInt() throws java.io.IOException
int
value from the server response stream.
int
java.io.IOException
- if an I/O error occurslong readLong() throws java.io.IOException
long
value from the server response stream.
long
java.io.IOException
- if an I/O error occursjava.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.IOException
void skipToEnd()
void close()
int getTdsVersion()
int
int getServerType()
int
java.io.InputStream getInputStream(int len)
InputStream
over the server response.
This method can be used to obtain a stream which can be passed to
InputStreamReader
s to assist in reading multi byte
character sets.
len
- the number of bytes available in the server response
InputStream
built over the server responseprivate 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 |