View Javadoc

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