org.jafer.zclient
Class ZSession

java.lang.Object
  extended by org.jafer.zclient.ZSession
All Implemented Interfaces:
Session

public class ZSession
extends java.lang.Object
implements Session

Manages a zclient session and sets up connection with zserver using org.jafer.util.PDUDriver. A session can be anonymous or if authentication is required by target, the client sets properties for user/group/password. Changing these properties will terminate an existing session and establish a new one.

Version:
1.0
Author:
Antony Corfield; Matthew Dovey; Colin Tatham

Field Summary
private  java.lang.String group
           
private  java.lang.String host
           
private static java.util.logging.Logger logger
           
private  java.lang.String name
           
private  java.lang.String password
           
private  PDUDriver pduDriver
           
private  int port
           
private static int sessionId
           
private  java.net.Socket socket
           
private static int SOCKET_CONNECT_TIMEOUT
          double SOCKET_CONNECT_TIMEOUT Timeout in milliseconds for the Socket.connect () function.
private  java.lang.String targetInfo
           
private  int targetVersion
           
private  int timeout
           
private  java.lang.String username
           
 
Constructor Summary
ZSession(java.lang.String host, int port, int timeout)
           
 
Method Summary
 void close()
          This method closes the current connection and any underlying binding classes
private  void connect()
           
 java.lang.String getGroup()
          Returns the group for this session.
 int getId()
          Return the session Identifier
 java.lang.String getName()
          Return the name allocatted to this session
 java.lang.String getPassword()
          Return the password for the user connecting via this session
 PDUDriver getPDUDriver()
           
 java.lang.String getUsername()
          Return the username for the user connecting via this session
 void init(java.lang.String group, java.lang.String username, java.lang.String password)
          Initalise the session
 java.util.Vector present(int nRecord, int nRecords, int[] recordOID, java.lang.String eSpec, java.lang.String resultSetName)
          Obtain the requested records via the sessions connection to the server and return them to the caller
 java.util.Vector scan(java.lang.String[] databases, int nTerms, int step, int position, org.w3c.dom.Node term)
          Performs a scan on the sessions connection to the sever to retrieve a list of related terms
 java.util.Vector scan(java.lang.String[] databases, int nTerms, int step, int position, java.lang.Object termObject)
          Performs a scan on the sessions connection to the sever to retrieve a list of related terms
 SearchResult[] search(java.lang.Object queryObject, java.lang.String[] databases, java.lang.String resultSetName)
          Performs a search on the sessions connection to the sever to work out how many results would be returned for the search query
private  void setName(java.lang.String group, java.lang.String username, java.lang.String password)
           
 void setPDUDriver(PDUDriver pduDriver)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static java.util.logging.Logger logger

sessionId

private static int sessionId

pduDriver

private PDUDriver pduDriver

socket

private java.net.Socket socket

name

private java.lang.String name

host

private java.lang.String host

group

private java.lang.String group

username

private java.lang.String username

password

private java.lang.String password

targetInfo

private java.lang.String targetInfo

port

private int port

timeout

private int timeout

targetVersion

private int targetVersion

SOCKET_CONNECT_TIMEOUT

private static final int SOCKET_CONNECT_TIMEOUT
double SOCKET_CONNECT_TIMEOUT Timeout in milliseconds for the Socket.connect () function. The default value for this on a Windows 2000 machine appears to be approximately 23 seconds. If a host isn't responding for some reason then a search will wait for the socket connect () to timeout. Added by Ashley Sanders, University of Manchester, 9/10/2003.

See Also:
Constant Field Values
Constructor Detail

ZSession

public ZSession(java.lang.String host,
                int port,
                int timeout)
Method Detail

connect

private void connect()
              throws ConnectionException
Throws:
ConnectionException

init

public void init(java.lang.String group,
                 java.lang.String username,
                 java.lang.String password)
          throws ConnectionException
Description copied from interface: Session
Initalise the session

Specified by:
init in interface Session
Parameters:
group - The group name for this session
username - The username of the user connecting via this session
password - The password of the user connecting via this session
Throws:
ConnectionException

close

public void close()
Description copied from interface: Session
This method closes the current connection and any underlying binding classes

Specified by:
close in interface Session

search

public SearchResult[] search(java.lang.Object queryObject,
                             java.lang.String[] databases,
                             java.lang.String resultSetName)
                      throws JaferException,
                             ConnectionException
Description copied from interface: Session
Performs a search on the sessions connection to the sever to work out how many results would be returned for the search query

Specified by:
search in interface Session
Parameters:
queryObject - The query object to search against. Normally RPNNode or a simple Node that represents a JaferQuery
databases - The list of databases to be searched
resultSetName - The name to be given to the result set
Returns:
An array of search result objects that identify the number of results for each database searched
Throws:
JaferException
ConnectionException

present

public java.util.Vector present(int nRecord,
                                int nRecords,
                                int[] recordOID,
                                java.lang.String eSpec,
                                java.lang.String resultSetName)
                         throws PresentException,
                                ConnectionException
Description copied from interface: Session
Obtain the requested records via the sessions connection to the server and return them to the caller

Specified by:
present in interface Session
Parameters:
nRecord - The index of the record that the retrieve should start at
nRecords - The maximum number of records that should be returned
recordOID - The record object identifier
eSpec - The element spec attribute of the ZClient
resultSetName - The result set name
Returns:
A Vector of DataObject returned from the server
Throws:
PresentException
ConnectionException

scan

public java.util.Vector scan(java.lang.String[] databases,
                             int nTerms,
                             int step,
                             int position,
                             org.w3c.dom.Node term)
                      throws JaferException,
                             ConnectionException
Description copied from interface: Session
Performs a scan on the sessions connection to the sever to retrieve a list of related terms

Specified by:
scan in interface Session
Parameters:
databases - An array of database names that are being scanned
nTerms - The maximum number of terms to return
step - ?????????????????????????????????????????????????????????
position - ?????????????????????????????????????????????????????
term - ?????????????????????????????????????????????????????????
Returns:
A vector of DataObjects representing the terms found
Throws:
JaferException
ConnectionException

scan

public java.util.Vector scan(java.lang.String[] databases,
                             int nTerms,
                             int step,
                             int position,
                             java.lang.Object termObject)
                      throws JaferException,
                             ConnectionException
Description copied from interface: Session
Performs a scan on the sessions connection to the sever to retrieve a list of related terms

Specified by:
scan in interface Session
Parameters:
databases - An array of database names that are being scanned
nTerms - The maximum number of terms to return
step - ?????????????????????????????????????????????????????????
position - ?????????????????????????????????????????????????????
termObject - ???????????????????????????????????????????????????
Returns:
A vector of DataObjects representing the terms found
Throws:
JaferException
ConnectionException

setPDUDriver

public void setPDUDriver(PDUDriver pduDriver)

getPDUDriver

public PDUDriver getPDUDriver()

setName

private void setName(java.lang.String group,
                     java.lang.String username,
                     java.lang.String password)

getId

public int getId()
Description copied from interface: Session
Return the session Identifier

Specified by:
getId in interface Session
Returns:
The session identifier

getName

public java.lang.String getName()
Description copied from interface: Session
Return the name allocatted to this session

Specified by:
getName in interface Session
Returns:
The name of this session

getGroup

public java.lang.String getGroup()
Description copied from interface: Session
Returns the group for this session. TODO NEED MORE DETAIL HERE

Specified by:
getGroup in interface Session
Returns:
The string representation of the group for this session.

getUsername

public java.lang.String getUsername()
Description copied from interface: Session
Return the username for the user connecting via this session

Specified by:
getUsername in interface Session
Returns:
The users username for the connection

getPassword

public java.lang.String getPassword()
Description copied from interface: Session
Return the password for the user connecting via this session

Specified by:
getPassword in interface Session
Returns:
The users password for the connection