Public Member Functions | |
CJDBCInputStream (InputStream in) throws IOException, StreamCorruptedException | |
CJDBCInputStream (Socket socket) throws IOException, StreamCorruptedException | |
Object | readObject () throws ClassNotFoundException, IOException, OptionalDataException |
void | close () throws IOException |
boolean | readBoolean () throws IOException |
int | readInt () throws IOException |
long | readLong () throws IOException |
String | readUTF () throws IOException |
int | available () throws IOException |
long | getBytesRead () |
Socket | getSocket () |
boolean | getUseCompression () |
long | getDateCreated () |
long | getSpeed () |
useCompression
can be set to on or off anytime.
Definition at line 45 of file CJDBCInputStream.java.
|
Creates a new CJDBCInputStream from the given input stream.
Definition at line 62 of file CJDBCInputStream.java. 00064 { 00065 input = new ObjectInputStream(new BufferedInputStream(in)); 00066 bytesRead = 0; 00067 }
|
|
Useful constructor for statistics on sockets ..
Definition at line 76 of file CJDBCInputStream.java. 00078 { 00079 this(socket.getInputStream()); 00080 this.socket = socket; 00081 dateCreated = System.currentTimeMillis(); 00082 }
|
|
Definition at line 199 of file CJDBCInputStream.java. 00200 {
00201 return input.available();
00202 }
|
|
Definition at line 134 of file CJDBCInputStream.java. 00135 { 00136 input.close(); 00137 }
|
|
Definition at line 207 of file CJDBCInputStream.java. 00208 {
00209 return bytesRead;
00210 }
|
|
Definition at line 231 of file CJDBCInputStream.java. 00232 {
00233 return dateCreated;
00234 }
|
|
Definition at line 215 of file CJDBCInputStream.java. 00216 {
00217 return socket;
00218 }
|
|
Definition at line 239 of file CJDBCInputStream.java. 00240 {
00241 return speed;
00242 }
|
|
Definition at line 223 of file CJDBCInputStream.java. 00224 {
00225 return useCompression;
00226 }
|
|
Definition at line 144 of file CJDBCInputStream.java. 00145 {
00146 bytesRead++;
00147 return input.readBoolean();
00148 }
|
|
Definition at line 155 of file CJDBCInputStream.java. Referenced by org.objectweb.cjdbc.controller.core.ControllerWorkerThread.run(). 00156 {
00157 bytesRead += 4;
00158 return input.readInt();
00159 }
|
|
Definition at line 166 of file CJDBCInputStream.java. 00167 {
00168 bytesRead += 8;
00169 return input.readLong();
00170 }
|
|
Definition at line 91 of file CJDBCInputStream.java. Referenced by org.objectweb.cjdbc.driver.Driver.connect(), org.objectweb.cjdbc.driver.Connection.getControllerVersionNumber(), org.objectweb.cjdbc.driver.Connection.getPrimaryKeys(), org.objectweb.cjdbc.driver.Connection.getStaticMetadata(), and org.objectweb.cjdbc.driver.Connection.getTables(). 00093 { 00094 if (useCompression) 00095 { 00096 int len = input.readInt(); 00097 byte[] read = new byte[len]; 00098 input.readFully(read); 00099 00100 bytesRead += len + 4; 00101 // we read an integer in the pipe for the size of the array. 00102 return CJDBCStream.decompressObject(read); 00103 } 00104 else 00105 { 00106 int objectType = input.readInt(); 00107 switch (objectType) 00108 { 00109 case CJDBCStream.OBJECT : 00110 // Use the unshared version to prevent the stream to keep references 00111 // on objects. This prevents objects sent through the channel from 00112 // being garbage collected and results in memory leaks. 00113 return input.readUnshared(); 00114 case CJDBCStream.NULL : 00115 return null; 00116 case CJDBCStream.STRING_OBJECT : 00117 return input.readUTF(); 00118 case CJDBCStream.INTEGER_OBJECT : 00119 return new Integer(input.readInt()); 00120 case CJDBCStream.LONG_OBJECT : 00121 return new Long(input.readLong()); 00122 case CJDBCStream.BOOLEAN_OBJECT : 00123 return input.readBoolean() ? Boolean.TRUE : Boolean.FALSE; 00124 default : 00125 throw new RuntimeException("Unhandled type on stream: " + objectType); 00126 } 00127 } 00128 }
|
|
Definition at line 177 of file CJDBCInputStream.java. Referenced by org.objectweb.cjdbc.driver.Driver.connect(), and org.objectweb.cjdbc.controller.core.ControllerWorkerThread.run(). 00178 { 00179 Object read; 00180 try 00181 { 00182 read = this.readObject(); 00183 } 00184 catch (Exception e) 00185 { 00186 throw new IOException(e.getMessage()); 00187 } 00188 if (read == null) 00189 return null; 00190 bytesRead += ((String) read).length(); 00191 return (String) read; 00192 }
|