Class TicketingSystemMIDlet

java.lang.Object
  extended by javax.microedition.midlet.MIDlet
      extended by TicketingSystemMIDlet
All Implemented Interfaces:
java.lang.Runnable, javax.microedition.lcdui.ItemCommandListener, javax.wireless.messaging.MessageListener

public class TicketingSystemMIDlet
extends javax.microedition.midlet.MIDlet
implements javax.wireless.messaging.MessageListener, javax.microedition.lcdui.ItemCommandListener, java.lang.Runnable

TicketingSystemMIDlet is responsible for the life cycle of the MIDlet. It is responsible for receiving incoming sms. It offers the menu selections to the user.

Since:
1.0
Author:
Magnus Egeberg

Field Summary
private  byte[] buf
           
 BusyAlert busy
           
private  java.lang.String BUSY_CONNECTING_TO_CHIP
           
private  java.lang.String BUSY_RECEIVING_DATA
           
private  java.lang.String BUSY_TICKET_RECEIVED
           
private  java.lang.String BUSY_TITLE
           
private  java.lang.String CONFIRMATION_ERROR_TITLE
           
private static java.lang.String DefaultSmsPort
           
 javax.microedition.lcdui.Display display
           
private  java.lang.String ENDING_KR
           
private  java.lang.String ERROR_DATA
           
private  java.lang.String ERROR_RECEIVED_SMS_TXT
           
private  java.lang.String ERROR_SMS
           
private  java.lang.String ERROR_SMS_NOT_A_TICKET
           
private  java.lang.String ERROR_SMS_TICKET
           
private  java.lang.String ERROR_TITLE
           
 javax.microedition.lcdui.Form errorForm
           
 boolean handle_error
           
 int info
           
private  javax.microedition.lcdui.Command mainExitCmd
           
 javax.microedition.lcdui.Form mainForm
           
private  javax.microedition.lcdui.Command mainSelectCmd
           
private  javax.microedition.lcdui.StringItem[] mainView
           
 com.nokia.nfc.shared.ui.DeviceManager manager
           
private  java.lang.String MENU_BUY_TICKET
           
private  java.lang.String MENU_CMD_EXIT
           
private  java.lang.String MENU_CMD_SELECT
           
private  java.lang.String MENU_CURRENT_CREDIT
           
private  java.lang.String MENU_LAST_PURCHASE
           
private  java.lang.String MENU_MAIN_TITLE
           
private  javax.wireless.messaging.MessageConnection msgConn
           
private  javax.microedition.lcdui.ImageItem nfcLogo
           
private  java.lang.String ORDER_CMD_BACK
           
private  java.lang.String ORDER_CMD_SELECT
           
private  java.lang.String ORDER_MAIN_TITLE
           
private  javax.microedition.lcdui.Command orderBackCmd
           
 javax.microedition.lcdui.Form orderForm
           
private  javax.microedition.lcdui.Command orderSelectCmd
           
private  javax.microedition.lcdui.StringItem[] orderView
           
 BusyAlert purchasing
           
private  SecureChipHandler secureChip
           
 java.lang.String smsPort
           
private static java.lang.String SmsPortAttribute
           
 javax.microedition.lcdui.StringItem tracelines
           
static int[][] vibeSequence
           
 
Constructor Summary
TicketingSystemMIDlet()
          Empty Constructor
 
Method Summary
 void commandAction(javax.microedition.lcdui.Command cmd, javax.microedition.lcdui.Item item)
          Executes actions based on user commands
private  javax.microedition.lcdui.Image createImage(java.lang.String file)
          Creates an image from a file
 void destroyApp(boolean arg0)
          Exits the application
private static java.lang.String getHexString(byte[] data)
          Converts a byte array to string representation
private  void mainSelect(javax.microedition.lcdui.Item item)
          Performs actions based on user selections in the main menu
 void notifyIncomingMessage(javax.wireless.messaging.MessageConnection conn)
          Receives the incoming sms and extracts the payload.
private  void orderSelect(javax.microedition.lcdui.Item item)
          Performs actions based on user selections in the order menu
protected  void pauseApp()
          Pauses the application
 void placeOrder()
          Creates the order form and adds listener to the buttons
 void purchase(java.lang.String s)
          Notifies the user that a purchase has been made
private  void receiveSms()
          Listens for incoming sms at portnumber from application properites.
 void run()
          Starts listening for sms
 void showMain()
          Presents the error form on the display
 void showTrace()
          Notifies the user of an error Presents the error form if user selects yes to do so.
protected  void startApp()
          Creates the menus.
 void trace(java.lang.String line)
          Collects strings for tracing.
 
Methods inherited from class javax.microedition.midlet.MIDlet
checkPermission, getAppProperty, notifyDestroyed, notifyPaused, platformRequest, resumeRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MENU_MAIN_TITLE

private final java.lang.String MENU_MAIN_TITLE
See Also:
Constant Field Values

MENU_CURRENT_CREDIT

private final java.lang.String MENU_CURRENT_CREDIT
See Also:
Constant Field Values

MENU_LAST_PURCHASE

private final java.lang.String MENU_LAST_PURCHASE
See Also:
Constant Field Values

MENU_BUY_TICKET

private final java.lang.String MENU_BUY_TICKET
See Also:
Constant Field Values

MENU_CMD_EXIT

private final java.lang.String MENU_CMD_EXIT
See Also:
Constant Field Values

MENU_CMD_SELECT

private final java.lang.String MENU_CMD_SELECT
See Also:
Constant Field Values

ORDER_MAIN_TITLE

private final java.lang.String ORDER_MAIN_TITLE
See Also:
Constant Field Values

ORDER_CMD_BACK

private final java.lang.String ORDER_CMD_BACK
See Also:
Constant Field Values

ORDER_CMD_SELECT

private final java.lang.String ORDER_CMD_SELECT
See Also:
Constant Field Values

ENDING_KR

private final java.lang.String ENDING_KR
See Also:
Constant Field Values

ERROR_TITLE

private final java.lang.String ERROR_TITLE
See Also:
Constant Field Values

ERROR_DATA

private final java.lang.String ERROR_DATA
See Also:
Constant Field Values

ERROR_SMS

private final java.lang.String ERROR_SMS
See Also:
Constant Field Values

ERROR_SMS_TICKET

private final java.lang.String ERROR_SMS_TICKET
See Also:
Constant Field Values

ERROR_SMS_NOT_A_TICKET

private final java.lang.String ERROR_SMS_NOT_A_TICKET
See Also:
Constant Field Values

ERROR_RECEIVED_SMS_TXT

private final java.lang.String ERROR_RECEIVED_SMS_TXT
See Also:
Constant Field Values

BUSY_TITLE

private final java.lang.String BUSY_TITLE
See Also:
Constant Field Values

BUSY_RECEIVING_DATA

private final java.lang.String BUSY_RECEIVING_DATA
See Also:
Constant Field Values

BUSY_TICKET_RECEIVED

private final java.lang.String BUSY_TICKET_RECEIVED
See Also:
Constant Field Values

BUSY_CONNECTING_TO_CHIP

private final java.lang.String BUSY_CONNECTING_TO_CHIP
See Also:
Constant Field Values

CONFIRMATION_ERROR_TITLE

private final java.lang.String CONFIRMATION_ERROR_TITLE
See Also:
Constant Field Values

manager

public com.nokia.nfc.shared.ui.DeviceManager manager

vibeSequence

public static int[][] vibeSequence

mainForm

public javax.microedition.lcdui.Form mainForm

nfcLogo

private javax.microedition.lcdui.ImageItem nfcLogo

mainSelectCmd

private javax.microedition.lcdui.Command mainSelectCmd

mainExitCmd

private javax.microedition.lcdui.Command mainExitCmd

mainView

private javax.microedition.lcdui.StringItem[] mainView

orderForm

public javax.microedition.lcdui.Form orderForm

orderSelectCmd

private javax.microedition.lcdui.Command orderSelectCmd

orderBackCmd

private javax.microedition.lcdui.Command orderBackCmd

orderView

private javax.microedition.lcdui.StringItem[] orderView

errorForm

public javax.microedition.lcdui.Form errorForm

info

public int info

busy

public BusyAlert busy

purchasing

public BusyAlert purchasing

smsPort

public java.lang.String smsPort

SmsPortAttribute

private static java.lang.String SmsPortAttribute

DefaultSmsPort

private static java.lang.String DefaultSmsPort

msgConn

private javax.wireless.messaging.MessageConnection msgConn

buf

private byte[] buf

display

public javax.microedition.lcdui.Display display

handle_error

public boolean handle_error

secureChip

private SecureChipHandler secureChip

tracelines

public javax.microedition.lcdui.StringItem tracelines
Constructor Detail

TicketingSystemMIDlet

public TicketingSystemMIDlet()
Empty Constructor

Method Detail

startApp

protected void startApp()
                 throws javax.microedition.midlet.MIDletStateChangeException
Creates the menus. Opens a SecureChipHandler Starts a thread

Specified by:
startApp in class javax.microedition.midlet.MIDlet
Throws:
javax.microedition.midlet.MIDletStateChangeException

pauseApp

protected void pauseApp()
Pauses the application

Specified by:
pauseApp in class javax.microedition.midlet.MIDlet

destroyApp

public void destroyApp(boolean arg0)
Exits the application

Specified by:
destroyApp in class javax.microedition.midlet.MIDlet
Parameters:
arg0 - Boolean variable demanded by J2ME

run

public void run()
Starts listening for sms

Specified by:
run in interface java.lang.Runnable

receiveSms

private void receiveSms()
Listens for incoming sms at portnumber from application properites. Default portnumber 7552 used if SmsPortAttribute undefined in JAD file.


notifyIncomingMessage

public void notifyIncomingMessage(javax.wireless.messaging.MessageConnection conn)
Receives the incoming sms and extracts the payload.

Specified by:
notifyIncomingMessage in interface javax.wireless.messaging.MessageListener
Parameters:
conn - The connection receiving the sms

getHexString

private static java.lang.String getHexString(byte[] data)
Converts a byte array to string representation

Parameters:
data - The byte array to
Returns:
the string representation of the byte array

showMain

public void showMain()
Presents the error form on the display


trace

public void trace(java.lang.String line)
Collects strings for tracing.

Parameters:
line - The string to be used for tracing

showTrace

public void showTrace()
Notifies the user of an error Presents the error form if user selects yes to do so.


createImage

private javax.microedition.lcdui.Image createImage(java.lang.String file)
Creates an image from a file

Parameters:
file - The address of the file
Returns:
The file as an Image
See Also:
Image

commandAction

public void commandAction(javax.microedition.lcdui.Command cmd,
                          javax.microedition.lcdui.Item item)
Executes actions based on user commands

Specified by:
commandAction in interface javax.microedition.lcdui.ItemCommandListener
Parameters:
cmd - The command issued by the user
item - The item selected by the user

mainSelect

private void mainSelect(javax.microedition.lcdui.Item item)
Performs actions based on user selections in the main menu

Parameters:
item - the item selected by the user

orderSelect

private void orderSelect(javax.microedition.lcdui.Item item)
Performs actions based on user selections in the order menu

Parameters:
item - The item selected by the user

purchase

public void purchase(java.lang.String s)
Notifies the user that a purchase has been made

Parameters:
s - The notification to the user

placeOrder

public void placeOrder()
Creates the order form and adds listener to the buttons