01: /*
02: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
03: *
04: * This file is part of Resin(R) Open Source
05: *
06: * Each copy or derived work must preserve the copyright notice and this
07: * notice unmodified.
08: *
09: * Resin Open Source is free software; you can redistribute it and/or modify
10: * it under the terms of the GNU General Public License version 2
11: * as published by the Free Software Foundation.
12: *
13: * Resin Open Source is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
16: * of NON-INFRINGEMENT. See the GNU General Public License for more
17: * details.
18: *
19: * You should have received a copy of the GNU General Public License
20: * along with Resin Open Source; if not, write to the
21: *
22: * Free Software Foundation, Inc.
23: * 59 Temple Place, Suite 330
24: * Boston, MA 02111-1307 USA
25: *
26: * @author Scott Ferguson
27: */
28:
29: package javax.faces.event;
30:
31: import java.util.*;
32:
33: public class PhaseId implements Comparable {
34: public static final PhaseId ANY_PHASE = new PhaseId("any", 0);
35: public static final PhaseId RESTORE_VIEW = new PhaseId(
36: "restore-view", 1);
37: public static final PhaseId APPLY_REQUEST_VALUES = new PhaseId(
38: "apply-request-values", 2);
39: public static final PhaseId PROCESS_VALIDATIONS = new PhaseId(
40: "process-validations", 3);
41: public static final PhaseId UPDATE_MODEL_VALUES = new PhaseId(
42: "update-model-values", 4);
43: public static final PhaseId INVOKE_APPLICATION = new PhaseId(
44: "invoke-application", 5);
45: public static final PhaseId RENDER_RESPONSE = new PhaseId(
46: "render-response", 6);
47:
48: public static final List VALUES;
49:
50: private final String _name;
51: private final int _value;
52:
53: PhaseId(String name, int value) {
54: _name = name;
55: _value = value;
56: }
57:
58: public int compareTo(Object o) {
59: if (!(o instanceof PhaseId))
60: return -1;
61:
62: PhaseId phaseId = (PhaseId) o;
63:
64: if (_value < phaseId._value)
65: return -1;
66: else if (phaseId._value < _value)
67: return 1;
68: else
69: return 0;
70: }
71:
72: public int getOrdinal() {
73: return _value;
74: }
75:
76: public String toString() {
77: return _name;
78: }
79:
80: static {
81: ArrayList<PhaseId> values = new ArrayList<PhaseId>();
82:
83: values.add(ANY_PHASE);
84: values.add(RESTORE_VIEW);
85: values.add(APPLY_REQUEST_VALUES);
86: values.add(PROCESS_VALIDATIONS);
87: values.add(UPDATE_MODEL_VALUES);
88: values.add(INVOKE_APPLICATION);
89: values.add(RENDER_RESPONSE);
90:
91: VALUES = Collections.unmodifiableList(values);
92: }
93: }
|