gradeview.net
Class GradeViewSession

java.lang.Object
  |
  +--gradeview.net.GradeViewSession

public class GradeViewSession
extends java.lang.Object

GradeViewSession provides the GradeView client applet with a simple set of functions through which client-to-server communication (and vice-versa) can take place.


Field Summary
static int CONNECTION_CLOSED
           
static int CONNECTION_READY
           
static java.lang.String PROFESSOR_LOGIN
           
static java.lang.String STUDENT_LOGIN
           
static java.lang.String TA_LOGIN
           
 
Method Summary
 void disconnect()
          Closes the currently active session.
 boolean establish(java.lang.String serverAddress, java.lang.String username, java.lang.String password)
          Establishes a new session, provided one isn't already set up.
 java.lang.String getConnectionType()
          Returns what sort of user (student, TA, or professor) is using the system.
static GradeViewSession getCurrentSession()
          Retrieves the currently active GradeViewSession object.
 java.lang.String getServerAddress()
          Returns the URL of the session's server.
 boolean isEstablished()
          Checks if the session is active.
static org.w3c.dom.Node parseToNode(java.lang.String parseMe)
           
 org.w3c.dom.Node sendData(org.w3c.dom.Node dataNode)
          Sends a block of XML-encoded data to the server, waits for a reply, and then parses it.
 org.w3c.dom.Node sendData(java.lang.String dataToSend)
          Sends a block of XML-encoded data to the server, waits for a reply, and then parses it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONNECTION_CLOSED

public static final int CONNECTION_CLOSED

CONNECTION_READY

public static final int CONNECTION_READY

STUDENT_LOGIN

public static final java.lang.String STUDENT_LOGIN

TA_LOGIN

public static final java.lang.String TA_LOGIN

PROFESSOR_LOGIN

public static final java.lang.String PROFESSOR_LOGIN
Method Detail

getCurrentSession

public static GradeViewSession getCurrentSession()
Retrieves the currently active GradeViewSession object. If one does not exist, then it will be created.
Returns:
The currently active GradeViewSession object.

disconnect

public void disconnect()
Closes the currently active session.

establish

public boolean establish(java.lang.String serverAddress,
                         java.lang.String username,
                         java.lang.String password)
Establishes a new session, provided one isn't already set up.
Parameters:
serverAddress - The URL to connect to.
username - The username to log in with.
password - The password to log in with.
Returns:
Returns 'true' if the session was established, false otherwise.

getServerAddress

public java.lang.String getServerAddress()
Returns the URL of the session's server.
Returns:
The URL of the session's server.

isEstablished

public boolean isEstablished()
Checks if the session is active. I.e., if it is currently connected to a server.
Returns:
True if connected, false otherwise.

getConnectionType

public java.lang.String getConnectionType()
Returns what sort of user (student, TA, or professor) is using the system.
Returns:
A string specifying the type of user connected (which is represented by one of the constants GradeViewSession.STUDENT_LOGIN, GradeViewSession.TA_LOGIN, or GradeViewSession.PROF_LOGIN. If no connection has been established, then this will return null.

sendData

public org.w3c.dom.Node sendData(org.w3c.dom.Node dataNode)
Sends a block of XML-encoded data to the server, waits for a reply, and then parses it. NOTE: Data will only be sent if a session has been established (this can be done using the establish() method.)
Parameters:
dataNode - The XML-encoded data to send to the server.
Returns:
XML-encoded data returned from the server.

sendData

public org.w3c.dom.Node sendData(java.lang.String dataToSend)
Sends a block of XML-encoded data to the server, waits for a reply, and then parses it. NOTE: Data will only be sent if a session has been established (this can be done using the establish() method.)
Parameters:
dataNode - The XML-encoded data to send to the server, represented as a String.
Returns:
XML-encoded data returned from the server.

parseToNode

public static org.w3c.dom.Node parseToNode(java.lang.String parseMe)
                                    throws java.io.IOException,
                                           org.xml.sax.SAXException