edu.cuny.cat.server
Class ShoutValidator

java.lang.Object
  extended by edu.cuny.cat.server.ShoutValidator
All Implemented Interfaces:
edu.cuny.config.param.Parameterizable

public class ShoutValidator
extends java.lang.Object
implements edu.cuny.config.param.Parameterizable

A class used by the game server to check the validity of a shout.

Parameters

base.maxprice
double (1000 by default)
(the upper bound of the price of a shout)
base.minprice
double (0 by default)
(the lower bound of the price of a shout)

Default Base

shout

Version:
$Revision: 1.6 $
Author:
Jinzhong Niu

Field Summary
protected  double maxPrice
          the maximal price a shout may offer
protected  double minPrice
          the minimal price a shout may offer
static java.lang.String P_DEF_BASE
           
static java.lang.String P_MAXPRICE
           
static java.lang.String P_MINPRICE
           
 
Constructor Summary
ShoutValidator()
           
 
Method Summary
 void check(boolean isSeller, double price, double privateValue)
          checks whether a shout from a trader is valid or not.
 void check(Shout shout)
          checks whether a shout from a trader is valid or not.
 void setup(edu.cuny.config.param.ParameterDatabase parameters, edu.cuny.config.param.Parameter base)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

P_MAXPRICE

public static final java.lang.String P_MAXPRICE
See Also:
Constant Field Values

P_MINPRICE

public static final java.lang.String P_MINPRICE
See Also:
Constant Field Values

P_DEF_BASE

public static final java.lang.String P_DEF_BASE
See Also:
Constant Field Values

maxPrice

protected double maxPrice
the maximal price a shout may offer


minPrice

protected double minPrice
the minimal price a shout may offer

Constructor Detail

ShoutValidator

public ShoutValidator()
Method Detail

setup

public void setup(edu.cuny.config.param.ParameterDatabase parameters,
                  edu.cuny.config.param.Parameter base)
Specified by:
setup in interface edu.cuny.config.param.Parameterizable

check

public void check(Shout shout)
           throws IllegalShoutException
checks whether a shout from a trader is valid or not. To be valid, the price must be not money-losing and falls in the valid price range, i.e. between maxPrice and minPrice. IllegalShoutException will be thrown if the shout is found illegal.

Parameters:
shout - the shout to check its validity
Throws:
IllegalShoutException - thrown when the shout is invalid
See Also:
check(boolean, double, double)

check

public void check(boolean isSeller,
                  double price,
                  double privateValue)
           throws IllegalShoutException
checks whether a shout from a trader is valid or not. To be valid, the price must be not money-losing and falls in the valid price range, i.e. between maxPrice and minPrice. IllegalShoutException will be thrown if the shout is found illegal.

Parameters:
isSeller - true if the trader is a seller; false otherwise.
price - the price of the shout
privateValue - the private value of the trader
Throws:
IllegalShoutException - thrown when the shout is invalid
See Also:
check(Shout)