01: /*
02: * $Id: MyFunctionImpl.java,v 1.7 2007/09/18 11:27:13 agoubard Exp $
03: */
04: package com.mycompany.myproject.api;
05:
06: /**
07: * Implementation of the <code>MyFunction</code> function.
08: *
09: * @version $Revision: 1.7 $ $Date: 2007/09/18 11:27:13 $
10: * @author <a href="mailto:anthony.goubard@japplis.com">Anthony Goubard</a>
11: */
12: public class MyFunctionImpl extends MyFunction {
13:
14: /**
15: * Constructs a new <code>MyFunctionImpl</code> instance.
16: *
17: * @param api
18: * the API to which this function belongs, guaranteed to be not
19: * <code>null</code>.
20: */
21: public MyFunctionImpl(APIImpl api) {
22: super (api);
23: }
24:
25: public final Result call(Request request) throws Throwable {
26: String lastNameLower = request.getPersonLastName()
27: .toLowerCase();
28: if (lastNameLower.indexOf('a') == -1
29: && lastNameLower.indexOf('e') == -1
30: && lastNameLower.indexOf('i') == -1
31: && lastNameLower.indexOf('o') == -1
32: && lastNameLower.indexOf('u') == -1
33: && lastNameLower.indexOf('y') == -1) {
34: return new NoVowelResult();
35: }
36: String salutation = null;
37: if (request.getGender().equals(
38: com.mycompany.myproject.types.Gender.MALE)) {
39: salutation = "Mister";
40: } else {
41: salutation = "Miss";
42: }
43: SuccessfulResult result = new SuccessfulResult();
44: result.setMessage("Hello " + salutation + " "
45: + request.getPersonLastName());
46: return result;
47: }
48: }
|