01: /*
02: * Copyright 2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package javax.faces.event;
17:
18: import java.util.ArrayList;
19: import java.util.Collections;
20:
21: /**
22: * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
23: *
24: * @author Thomas Spiegl (latest modification by $Author: mbr $)
25: * @version $Revision: 513686 $ $Date: 2007-03-02 11:12:36 +0100 (Fr, 02 Mrz 2007) $
26: */
27: public class PhaseId implements Comparable {
28:
29: // FIELDS
30: public static final javax.faces.event.PhaseId ANY_PHASE;
31: public static final javax.faces.event.PhaseId APPLY_REQUEST_VALUES;
32: public static final javax.faces.event.PhaseId INVOKE_APPLICATION;
33: public static final javax.faces.event.PhaseId PROCESS_VALIDATIONS;
34: public static final javax.faces.event.PhaseId RENDER_RESPONSE;
35: public static final javax.faces.event.PhaseId RESTORE_VIEW;
36: public static final javax.faces.event.PhaseId UPDATE_MODEL_VALUES;
37: public static final java.util.List VALUES;
38:
39: static {
40: int i = 0;
41: ArrayList<PhaseId> list = new ArrayList<PhaseId>(6);
42:
43: ANY_PHASE = new PhaseId("ANY_PHASE", i++);
44: list.add(ANY_PHASE);
45: RESTORE_VIEW = new PhaseId("RESTORE_VIEW", i++);
46: list.add(RESTORE_VIEW);
47: APPLY_REQUEST_VALUES = new PhaseId("APPLY_REQUEST_VALUES", i++);
48: list.add(APPLY_REQUEST_VALUES);
49: PROCESS_VALIDATIONS = new PhaseId("PROCESS_VALIDATIONS", i++);
50: list.add(PROCESS_VALIDATIONS);
51: UPDATE_MODEL_VALUES = new PhaseId("UPDATE_MODEL_VALUES", i++);
52: list.add(UPDATE_MODEL_VALUES);
53: INVOKE_APPLICATION = new PhaseId("INVOKE_APPLICATION", i++);
54: list.add(INVOKE_APPLICATION);
55: RENDER_RESPONSE = new PhaseId("RENDER_RESPONSE", i++);
56: list.add(RENDER_RESPONSE);
57: VALUES = Collections.unmodifiableList(list);
58: }
59:
60: private final String _name;
61: private final int _ordinal;
62:
63: // CONSTRUCTORS
64: private PhaseId(String name, int ordinal) {
65: this ._name = name;
66: this ._ordinal = ordinal;
67: }
68:
69: // METHODS
70: public int compareTo(Object other) {
71: return _ordinal - ((PhaseId) other)._ordinal;
72: }
73:
74: public int getOrdinal() {
75: return _ordinal;
76: }
77:
78: public String toString() {
79: return _name + "(" + _ordinal + ")";
80: }
81:
82: }
|