01: /*
02: * XML 2 Java Binding (X2JB) - the excellent Java tool.
03: * Copyright 2007, by Richard Opalka.
04: *
05: * This is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU Lesser General Public License as
07: * published by the Free Software Foundation; either version 2.1 of
08: * the License, or (at your option) any later version.
09: *
10: * This software is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this software; if not see the FSF site:
17: * http://www.fsf.org/ and search for the LGPL License document there.
18: */
19: package webapp;
20:
21: /**
22: * Web app sample
23: * @author <a href="mailto:richard_opalka@yahoo.com">Richard Opalka</a>
24: * @version 1.0
25: */
26: public final class Dispatcher {
27:
28: /** Dispatcher type in web.xml is <code>FORWARD</code> */
29: public static final Dispatcher FORWARD = new Dispatcher("FORWARD");
30: /** Dispatcher type in web.xml is <code>INCLUDE</code> */
31: public static final Dispatcher INCLUDE = new Dispatcher("INCLUDE");
32: /** Dispatcher type in web.xml is <code>REQUEST</code> */
33: public static final Dispatcher REQUEST = new Dispatcher("REQUEST");
34: /** Dispatcher type in web.xml is <code>ERROR</code> */
35: public static final Dispatcher ERROR = new Dispatcher("ERROR");
36:
37: private final String type;
38:
39: /**
40: * Forbidden constructor
41: * @param type dispatcher type
42: */
43: private Dispatcher(String type) {
44: super ();
45: this .type = type;
46: }
47:
48: /**
49: * Factory method which converts passed <code>String</code> to <code>DispatcherType</code>
50: * @param s to be converted
51: * @return <code>DispatcherType</code> instance or null if no match was found
52: */
53: public static Dispatcher valueOf(String s) {
54: if (s != null) {
55: if (FORWARD.toString().equals(s))
56: return FORWARD;
57: if (INCLUDE.toString().equals(s))
58: return INCLUDE;
59: if (REQUEST.toString().equals(s))
60: return REQUEST;
61: if (ERROR.toString().equals(s))
62: return ERROR;
63: }
64:
65: return null;
66: }
67:
68: public final String toString() {
69: return this.type;
70: }
71:
72: }
|