com.maplesoft.client
Class Utility

java.lang.Object
  |
  +--com.maplesoft.client.Utility

public class Utility
extends java.lang.Object

Provides general helper methods for Client Applications. The class itself cannot be instantiated.


Method Summary
static byte[] convertInput2Bytes(com.webpearls.pearlserver.api.PSAPDataInputStream input)
          Converts the PSAPDataInputStream into a byte array
static MapleStatement createDefaultStatement(java.awt.Frame frame, boolean doPrompt)
          Creates a MapleStatement object from the default host and user info.
static java.awt.Image createImage(byte[] buffer)
          Creates an Image from a data buffer that is either a Gif or JPEG.
static java.awt.Image createImage(int width, int height)
          Create a white rectangular Image of size width x height
static java.awt.Image createImage(int width, int height, java.awt.Color fillColor)
          Create a white rectangular Image of size width x height
static void main(java.lang.String[] args)
           
static void promptForDefaultLogin()
          Displays a default Login Dialog that will prompt for Username and Password.
static void promptForDefaultLogin(java.awt.Frame owner)
          Displays a default Login Dialog that will prompt for Username and Password.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

convertInput2Bytes

public static byte[] convertInput2Bytes(com.webpearls.pearlserver.api.PSAPDataInputStream input)
                                 throws MapleException
Converts the PSAPDataInputStream into a byte array
Parameters:
PSAPDataInputStream - input
Returns:
byte array representing data from the server
Throws:
MapleException -  

createImage

public static java.awt.Image createImage(byte[] buffer)
Creates an Image from a data buffer that is either a Gif or JPEG.
Parameters:
buffer - a byte array that represents either a Gif or JPEG
Returns:
an Image

createImage

public static java.awt.Image createImage(int width,
                                         int height)
Create a white rectangular Image of size width x height
Parameters:
width - The width of the image
height - The height of the image
Returns:
a java.awt.Image object

createImage

public static java.awt.Image createImage(int width,
                                         int height,
                                         java.awt.Color fillColor)
Create a white rectangular Image of size width x height
Parameters:
width - The width of the image
height - The height of the image
fillColor - a Color object describing the color to use as fill
Returns:
a java.awt.Image object

promptForDefaultLogin

public static void promptForDefaultLogin()
Displays a default Login Dialog that will prompt for Username and Password. If Save is pressed then the login info will be saved using the UserInfo.setDefaultUser() method. Pressing Cancel abort the login dialog and the default UserInfo is unchanged.

promptForDefaultLogin

public static void promptForDefaultLogin(java.awt.Frame owner)
Displays a default Login Dialog that will prompt for Username and Password. If Save is pressed then the login info will be saved using the UserInfo.setDefaultUser() method. Pressing Cancel abort the login dialog and the default UserInfo is unchanged.
Parameters:
owner - The frame window that will be the owner of the modal login dialog window.

createDefaultStatement

public static MapleStatement createDefaultStatement(java.awt.Frame frame,
                                                    boolean doPrompt)
                                             throws MapleStatementException
Creates a MapleStatement object from the default host and user info. The default user is derived from the UserInfo.getDefaultUser. If the default user is not set a login window will appear prompting for the user login. If Save button in the login window is pressed then the username and password are saved using the UserInfo.setDefaultUser and then used to create the MapleStatement. The default Host is derived from the HostInfo.getDefaultHost() method and should therefore be set prior to using this method.
Parameters:
frame - Frame representing main program window that the modal login dialog window will be associated with. The frame can be null if there is not main window
doPrompt - A boolean when true will always display a login dialog and when false only displays a login dialog if the UserInfo.getDefaultUser() is null.
Returns:
a MapleStatement object that is tied to the default host and user information
Throws:
MapleStatementException - when no user info is defined or if the username is blank.

main

public static void main(java.lang.String[] args)