com.maplesoft.client
Class MapleStatement

java.lang.Object
  |
  +--com.maplesoft.client.MapleStatement
Direct Known Subclasses:
MapleImageBase, MapleToMathML, MathMLToMaple

public class MapleStatement
extends java.lang.Object

Creates an object that can execute a Maple Statement at the MapleNet server.
In order to interact with the MapleNet server a MapleStatement object is created, and both Host (i.e. hostname and port) and User (i.e. username and password) information is supplied.
The execute method will pass Maple commands to the server and return a response.
The connection exists only during the execute method and is then closed.

Note: Each request passed to execute() must be self-contained and complete as each request is independent. No state information in Maple is maintained between call.


Constructor Summary
MapleStatement()
          Create a default MapleStatement and set up a default connection (localhost) and an empty user.
MapleStatement(HostInfo hostinfo, UserInfo userinfo)
          Creates a MapleStatement for a given HostInfo and UserInfo.
MapleStatement(java.lang.String sHost, int iPort, java.lang.String sUser, java.lang.String sPassword)
          Create a MapleStatement for a specific host, port, user and password.
 
Method Summary
 java.lang.Object[] doMaple(java.lang.String[] saRequest)
          Sends maple commands to the server and returns an object, text or plot, associated with each command.
 java.lang.String execute(java.lang.String sRequest)
          Pass the command contained in the string to the Maple Server.
 java.lang.String[] execute(java.lang.String[] saRequest)
          Pass the sequence of commands contained in the string array to the Maple Server.
 HostInfo getHost()
          Returns the HostInfo object for this MapleStatement
 void getLock()
          Obtain a session lock from the MapleNet server.
 java.lang.String getResponse()
          Returns the Server response to the last execute() invocation.
 java.lang.String[] getResponseArray()
          Returns the Server response to the last execute() invocation.
 UserInfo getUser()
          Return the UserInfo object that is associated with this MapleStatement
 java.lang.String getXMLString()
          Returns the complete XML form of the response from the server
 java.lang.String[] getXMLStringArray()
          Returns the complete XML form of the response from the server
 void releaseLock()
          Release the session lock held by this MapleStatement object.
 void setHost(HostInfo newHostinfo)
          Sets new host connection information for this MapleStatement
 void setHost(java.lang.String sHost, int iPort)
          Change the host information for this statement.
 void setUser(java.lang.String user, java.lang.String pswd)
          Change the user information for this MapleStatement.
 void setUser(UserInfo newUserinfo)
          Change the user information for this MapleStatement
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapleStatement

public MapleStatement()
Create a default MapleStatement and set up a default connection (localhost) and an empty user. Use setHost and setUser to establish connection information prior to executing any requests from the server.

MapleStatement

public MapleStatement(HostInfo hostinfo,
                      UserInfo userinfo)
Creates a MapleStatement for a given HostInfo and UserInfo.
See Also:
HostInfo, UserInfo

MapleStatement

public MapleStatement(java.lang.String sHost,
                      int iPort,
                      java.lang.String sUser,
                      java.lang.String sPassword)
Create a MapleStatement for a specific host, port, user and password.
Parameters:
sHost - name of server (eg: abc.com)
iPort - port to connect to on server
sUser - user as registered on server
sPassword - password for user
Method Detail

setHost

public void setHost(java.lang.String sHost,
                    int iPort)
Change the host information for this statement.
Parameters:
sHost - Name of host machine eq abc.com
iPort - Port number to connect on
Returns:
void

setHost

public void setHost(HostInfo newHostinfo)
Sets new host connection information for this MapleStatement
Parameters:
newHostinfo - A HostInfo object
Returns:
void

getHost

public HostInfo getHost()
Returns the HostInfo object for this MapleStatement
Returns:
a HostInfo object
See Also:
setHost( HostInfo )

setUser

public void setUser(java.lang.String user,
                    java.lang.String pswd)
Change the user information for this MapleStatement.
Parameters:
sUser - username to use when connecting to server
sPassword - password for user
Returns:
void

setUser

public void setUser(UserInfo newUserinfo)
Change the user information for this MapleStatement
Parameters:
newUserinfo - a UserInfo object
Returns:
void

getUser

public UserInfo getUser()
Return the UserInfo object that is associated with this MapleStatement
Returns:
a UserInfo object
See Also:
setUser( UserInfo ), setUser( String, String )

getLock

public void getLock()
             throws MapleException,
                    MapleStatementException
Obtain a session lock from the MapleNet server.
Returns:
void
See Also:
releaseLock( )

releaseLock

public void releaseLock()
                 throws MapleException,
                        MapleStatementException
Release the session lock held by this MapleStatement object.
Returns:
void
See Also:
getLock( )

execute

public java.lang.String execute(java.lang.String sRequest)
                         throws MapleException,
                                MapleStatementException
Pass the command contained in the string to the Maple Server.
 Note: Valid Host and User information needs to be set before
       calling this method, either through the constructor
       MapleStatement or through the
       setHost and setUser methods.
 
Parameters:
sRequest - - a Maple command using Maple syntax.
Returns:
The string response from the server for this requested Maple command.
Optionally the results can also be retrieved with getResponse method.
Throws:
MapleException - if it cannot connect to server, if the user is invalid or if the host is unknown.
MapleStatementException - if it cannot the request cannot be processed by the server

execute

public java.lang.String[] execute(java.lang.String[] saRequest)
                           throws MapleException,
                                  MapleStatementException
Pass the sequence of commands contained in the string array to the Maple Server.
 Note: Valid Host and User information needs to be set before
       calling this method, either through the constructor
       MapleStatement or through the
       setHost and setUser methods.
 
Parameters:
saRequest - - a string array of Maple commands, using Maple syntax.
Returns:
The string array response from the server for the sequence of Maple commands.
Optionally the results can also be retrieved with getResponseArray method.
Throws:
MapleException - if it cannot connect to server, if the user is invalid or if the host is unknown.
MapleStatementException - if it cannot the request cannot be processed by the server

doMaple

public java.lang.Object[] doMaple(java.lang.String[] saRequest)
                           throws MapleException,
                                  MapleStatementException
Sends maple commands to the server and returns an object, text or plot, associated with each command.
Parameters:
saRequest - - an array of Maple commands
Returns:
an array of Objects, one for each command in saRequest. The objects will be either a String object if the maple commands returns a text answer or it will return an java.awt.Image object if the command produced a plotted image.
Throws:
MapleException -  
MapleStatementException -  

getResponse

public java.lang.String getResponse()
Returns the Server response to the last execute() invocation.
Returns:
A string representing the answer from the server. This will be the same response that the execute() method returned.

getResponseArray

public java.lang.String[] getResponseArray()
Returns the Server response to the last execute() invocation.
Returns:
A string array representing the answer from the server. This will be the same response that the execute() method returned.

getXMLString

public java.lang.String getXMLString()
Returns the complete XML form of the response from the server
Returns:
String The server's response in XML format

getXMLStringArray

public java.lang.String[] getXMLStringArray()
Returns the complete XML form of the response from the server
Returns:
String[] The server's response in XML format