Websphere MQ Everyplace

examples.midp.exampleapp.textapp
Class Client

java.lang.Object
  |
  +--examples.midp.exampleapp.textapp.Client
All Implemented Interfaces:
AppController
Direct Known Subclasses:
GatewayServer, RegistrationServer

public class Client
extends java.lang.Object
implements AppController

The class acts as the J2SE controller for the text app client and should not be used on MIDP devices.

Once the model has been initialized and registered with the reg server, the client will prompt the user for input. If the user enters one of the keywords used to perform a function such as 'help' or 'status' then the relevant command will be performed, otherwise, the text will be sent as a message to the gateway server.


Field Summary
static java.lang.String initialPromptMessage
          The first thing to be displayed to the user after initialization
static short[] version
           
 
Constructor Summary
Client()
           
 
Method Summary
 void displayHelp()
          Displays the help screen to the user.
 void displayStatus(java.lang.String msg)
          Displays a status message to the user
protected  java.lang.String getInput()
          Obtains input from the user.
protected  AppModel getModel()
          Returns the controller's model.
protected  AppModel getNewModel()
          returns a new model.
 java.lang.String getQMname()
          Returns a name for the queue manager
protected  void initialize()
          This initializes the controller, which generally involves just initializing the model.
static void main(java.lang.String[] args)
          This function is invoked when this class is run from the commandline.
 void processInput(java.lang.String input)
          This class handles user input.
protected  java.lang.String promptFor(java.lang.String prompt, java.lang.String stringDefault)
          Used to prompt the user for something.
 void run()
          Called to start the controller running.
 void stop()
          Stops the controller and all constituent parts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static short[] version

initialPromptMessage

public static final java.lang.String initialPromptMessage
The first thing to be displayed to the user after initialization

See Also:
Constant Field Values
Constructor Detail

Client

public Client()
Method Detail

main

public static void main(java.lang.String[] args)
This function is invoked when this class is run from the commandline. A new controller is created and started to manage the model.


initialize

protected void initialize()
                   throws java.lang.Exception
This initializes the controller, which generally involves just initializing the model.

Returns:
void
java.lang.Exception

getModel

protected AppModel getModel()
Returns the controller's model. If no model exists, a new one is created and returned

Returns:
AppModel - the model

stop

public void stop()
          throws java.lang.Exception
Stops the controller and all constituent parts.

Returns:
void
java.lang.Exception

run

public void run()
         throws java.lang.Exception
Called to start the controller running. This will typically be called after the controller has been initialized

Returns:
void
java.lang.Exception

displayHelp

public void displayHelp()
Displays the help screen to the user.

Returns:
void

processInput

public void processInput(java.lang.String input)
This class handles user input. If the user enters anything that doesnt match a command, it is sent to the gateway as a message.

Parameters:
input - What the user input
Returns:
void

getInput

protected java.lang.String getInput()
Obtains input from the user.

Returns:
String - user input

getNewModel

protected AppModel getNewModel()
returns a new model. This is used so that classes that extend this class can simply override this function rather than getModel().

Returns:
AppModel

getQMname

public java.lang.String getQMname()
Description copied from interface: AppController
Returns a name for the queue manager

Specified by:
getQMname in interface AppController
Returns:
String - the name of the queue manager
See Also:
AppController.getQMname()

displayStatus

public void displayStatus(java.lang.String msg)
Description copied from interface: AppController
Displays a status message to the user

Specified by:
displayStatus in interface AppController
Parameters:
msg - The message to be displayed
Returns:
void
See Also:
AppController.displayStatus(String)

promptFor

protected java.lang.String promptFor(java.lang.String prompt,
                                     java.lang.String stringDefault)
Used to prompt the user for something.

Parameters:
prompt - What to prompt the user for
stringDefault - The default to display
Returns:
String - the reply

Websphere MQ Everyplace