jxDBCon 0.9z

org.sourceforge.jxdbcon.postgresql
Class NetProtocol

java.lang.Object
  |
  +--org.sourceforge.jxdbcon.postgresql.NetProtocol
All Implemented Interfaces:
InfoKeys, PGConstants, PGInfoKeys, PGProtocol
Direct Known Subclasses:
NetProtocolV0, NetProtocolV1

public abstract class NetProtocol
extends Object
implements PGProtocol, PGConstants, PGInfoKeys

The NetProtocol encapsulates the common things of the socket based Backend/Frontend protocols. COPY IN / COPY OUT behaviour can be controlled by setting the member values. If set to null the data is silently discarded.

Version:
$Revision: 1.10 $
Author:
Keve Müller

Field Summary
protected  InputStream copyInStream
          The InputStream for COPY IN data.
protected  OutputStream copyOutStream
          The OutputStream for COPY OUT data.
protected  DataInputStream in
          The inputstream for reading from the backend.
protected  Object lock
          The lock.
protected  String messageEncoding
          The encoding to use to decode backend messages.
protected  DataOutputStream out
          The OutputStream for writing to the backend.
protected  Socket socket
          The Socket for communication with the backend.
 
Fields inherited from interface org.sourceforge.jxdbcon.postgresql.PGConstants
AUTH_REQ_CRYPT, AUTH_REQ_KRB4, AUTH_REQ_KRB5, AUTH_REQ_MD5, AUTH_REQ_OK, AUTH_REQ_PASSWORD, AUTH_REQ_SCM, NUMERIC_DSCALE_MASK, NUMERIC_NAN, NUMERIC_NEG, NUMERIC_POS, NUMERIC_SIGN_MASK, PG_VERSION_STR, PG_VERSION_STR1, TRIGGER_TYPE_BEFORE, TRIGGER_TYPE_DELETE, TRIGGER_TYPE_INSERT, TRIGGER_TYPE_ROW, TRIGGER_TYPE_UPDATE
 
Fields inherited from interface org.sourceforge.jxdbcon.postgresql.PGInfoKeys
FORCECLIENTENC, OPTIONS, PROTOVERSION, SETTIMEZONE, STRICTSCHEMA, TTY, USEASYNC, USECLIENTENC, USEDBENC, USESSL
 
Fields inherited from interface org.sourceforge.jxdbcon.InfoKeys
CATALOG, DESCRIPTION, DRIVER, HOST, PASSWORD, PORT, SUBDRIVER, USER
 
Constructor Summary
NetProtocol()
           
 
Method Summary
protected  void connectSocket(Properties info)
          Connect to the backend, set the socket, in and out members.
protected  void limString(int size, byte[] ba)
          Write a fixed length String to the stream.
protected  byte[] readCString()
          Read a C-style 0 terminated string (as bytes).
 void setCopyInStream(InputStream in)
          Accessor function for COPY IN
 void setCopyOutStream(OutputStream out)
          Accessor function for COPY OUT
 void setMessageEncoding(String messageEncoding)
          Accessor function for messageEncoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sourceforge.jxdbcon.postgresql.PGProtocol
close, connect, exec, requestCancel
 

Field Detail

copyInStream

protected InputStream copyInStream
The InputStream for COPY IN data.


copyOutStream

protected OutputStream copyOutStream
The OutputStream for COPY OUT data.


in

protected DataInputStream in
The inputstream for reading from the backend.


lock

protected Object lock
The lock.


messageEncoding

protected String messageEncoding
The encoding to use to decode backend messages.


out

protected DataOutputStream out
The OutputStream for writing to the backend. The OutputStream should be buffered.


socket

protected Socket socket
The Socket for communication with the backend.

Constructor Detail

NetProtocol

public NetProtocol()
Method Detail

connectSocket

protected void connectSocket(Properties info)
                      throws IOException,
                             UnknownHostException
Connect to the backend, set the socket, in and out members.

IOException
UnknownHostException

limString

protected final void limString(int size,
                               byte[] ba)
                        throws IOException
Write a fixed length String to the stream.

Parameters:
size - The string length.
ba - The string value.
IOException

readCString

protected final byte[] readCString()
                            throws IOException
Read a C-style 0 terminated string (as bytes). No limitations on the string length. The terminating null byte is not stored in the buffer.

IOException

setCopyInStream

public void setCopyInStream(InputStream in)
Accessor function for COPY IN

Specified by:
setCopyInStream in interface PGProtocol

setCopyOutStream

public void setCopyOutStream(OutputStream out)
Accessor function for COPY OUT

Specified by:
setCopyOutStream in interface PGProtocol

setMessageEncoding

public void setMessageEncoding(String messageEncoding)
Accessor function for messageEncoding.

Specified by:
setMessageEncoding in interface PGProtocol

jxDBCon 0.9z

Copyright © 2001,2002 Keve Müller; see LICENSE file for details.