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  import java.util.List;
24  
25  /**
26   * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
27   * 
28   * @author Thomas Spiegl (latest modification by $Author: bommel $)
29   * @version $Revision: 1187701 $ $Date: 2011-10-22 07:21:54 -0500 (Sat, 22 Oct 2011) $
30   */
31  public class PhaseId implements Comparable
32  {
33      // FIELDS
34      public static final PhaseId ANY_PHASE;
35      public static final PhaseId APPLY_REQUEST_VALUES;
36      public static final PhaseId INVOKE_APPLICATION;
37      public static final PhaseId PROCESS_VALIDATIONS;
38      public static final PhaseId RENDER_RESPONSE;
39      public static final PhaseId RESTORE_VIEW;
40      public static final PhaseId UPDATE_MODEL_VALUES;
41      public static final List<PhaseId> VALUES;
42  
43      static
44      {
45          int i = 0;
46          ArrayList<PhaseId> list = new ArrayList<PhaseId>(6);
47  
48          ANY_PHASE = new PhaseId("ANY_PHASE", i++);
49          list.add(ANY_PHASE);
50          RESTORE_VIEW = new PhaseId("RESTORE_VIEW", i++);
51          list.add(RESTORE_VIEW);
52          APPLY_REQUEST_VALUES = new PhaseId("APPLY_REQUEST_VALUES", i++);
53          list.add(APPLY_REQUEST_VALUES);
54          PROCESS_VALIDATIONS = new PhaseId("PROCESS_VALIDATIONS", i++);
55          list.add(PROCESS_VALIDATIONS);
56          UPDATE_MODEL_VALUES = new PhaseId("UPDATE_MODEL_VALUES", i++);
57          list.add(UPDATE_MODEL_VALUES);
58          INVOKE_APPLICATION = new PhaseId("INVOKE_APPLICATION", i++);
59          list.add(INVOKE_APPLICATION);
60          RENDER_RESPONSE = new PhaseId("RENDER_RESPONSE", i++);
61          list.add(RENDER_RESPONSE);
62          VALUES = Collections.unmodifiableList(list);
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      @Override
87      public String toString()
88      {
89          return _name + "(" + _ordinal + ")";
90      }
91  
92  }