reservation.system.functions
Class Functions

java.lang.Object
  extended byreservation.system.functions.Functions
All Implemented Interfaces:
Action
Direct Known Subclasses:
Cancel, Create, Flights, Identify, Lists, Reload, Reserve, Store, Store_alternatif

public abstract class Functions
extends java.lang.Object
implements Action

This class uniform the way to call each sub-class (Create, Reserve, Cancel, Lists, Identify) that processes the commands. It delegates to the sub-class the implementation of the function execute () and check (). Also it masks the machinery and helps the developer who want to reuse the program.

Author:
Texier Mathieu and Frederic Bidon

Field Summary
protected  java.lang.String[] arg
          The list of argnument receive from the command
 
Fields inherited from interface reservation.Action
fs, NUMBER_ARGUMENT_MAX
 
Constructor Summary
Functions()
           
 
Method Summary
(package private) abstract  void _check(java.lang.String[] arg)
          Check if the arguments are correct and can be executed
static void ArgumentIsValid(java.lang.String[] arg, int min, int max)
          Verify the number of arguments of the command Verify invariants : - regex ^[A-Z][a-z]* - seat < dimension of the flight and > 0
(package private) static void CheckBookingListNotEmpty()
          Verify that one reservation has been made.
(package private) static void CheckFlightListNotEmpty()
          Verify that at least one flight is created.
static boolean checkInteger(java.lang.String arg, int min, int max)
          Verify invariants : - regex ^0*[1-9]+0* * - arg belongs to [min max]
abstract  java.lang.String execute()
          Proceed the execution of the request
 java.lang.String execute(java.lang.String[] arg)
          Process the array of argument
static java.lang.String usage()
          Display the usage for the command (details the different arguments, his type...).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arg

protected java.lang.String[] arg
The list of argnument receive from the command

Constructor Detail

Functions

public Functions()
Method Detail

execute

public abstract java.lang.String execute()
                                  throws java.lang.Exception
Proceed the execution of the request

Returns:
The apropriate description
Throws:
java.lang.Exception - if the excution is not complete

usage

public static java.lang.String usage()
Display the usage for the command (details the different arguments, his type...).

Returns:
the Usage

execute

public java.lang.String execute(java.lang.String[] arg)
                         throws java.lang.Exception
Process the array of argument

Specified by:
execute in interface Action
Parameters:
arg - the list of command to be proceed
Returns:
the result of the request.
Throws:
java.lang.Exception - If the command is not executed

checkInteger

public static boolean checkInteger(java.lang.String arg,
                                   int min,
                                   int max)
Verify invariants :
 - regex ^0*[1-9]+0*
 * - arg belongs to [min max]
 

Parameters:
min - the minimun number allowed in arg
max - the maximum number allowed in arg
arg - the input String that will be checked
Returns:
false if the invariants is violated

ArgumentIsValid

public static void ArgumentIsValid(java.lang.String[] arg,
                                   int min,
                                   int max)
                            throws java.lang.Exception
Verify the number of arguments of the command Verify invariants :
 - regex ^[A-Z][a-z]*
 - seat < dimension of the flight and > 0
 

Parameters:
arg - the input array that will be checked
min - the minimum argument allowed in arg
max - the maximum argument allowed in arg
Throws:
java.lang.Exception - if the invariants is violated

CheckFlightListNotEmpty

static void CheckFlightListNotEmpty()
                             throws java.lang.Exception
Verify that at least one flight is created.

Throws:
java.lang.Exception - if the FlightList contains no flight.

CheckBookingListNotEmpty

static void CheckBookingListNotEmpty()
                              throws java.lang.Exception
Verify that one reservation has been made.

Throws:
java.lang.Exception - if the BookingList contains no BookingNumber.

_check

abstract void _check(java.lang.String[] arg)
              throws java.lang.Exception
Check if the arguments are correct and can be executed

Throws:
java.lang.Exception - if the argument is violated