All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.faces.event.PhaseId Maven / Gradle / Ivy

There is a newer version: 3.1.0.SP02
Show newest version
/*
 * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

package javax.faces.event;


import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.faces.FacesException;


/**
 * 

Typesafe enumeration of * the legal values that may be returned by the * getPhaseId() method of the {@link FacesEvent} interface. */ public class PhaseId implements Comparable { // ----------------------------------------------------------- Constructors /** *

Private constructor to disable the creation of new instances.

*/ private PhaseId(String newPhaseName) { phaseName = newPhaseName; } // ----------------------------------------------------- Instance Variables /** *

The ordinal value assigned to this instance.

*/ private final int ordinal = nextOrdinal++; /** *

The (optional) name for this phase.

*/ private String phaseName = null; // --------------------------------------------------------- Public Methods /** *

Compare this {@link PhaseId} instance to the specified one. * Returns a negative integer, zero, or a positive integer if this * object is less than, equal to, or greater than the specified object.

* * @param other The other object to be compared to */ @Override public int compareTo(Object other) { return this.ordinal - ((PhaseId) other).ordinal; } /** *

Return the ordinal value of this {@link PhaseId} instance.

* * @return the ordinal */ public int getOrdinal() { return (this.ordinal); } /** *

Return a String representation of this {@link PhaseId} instance.

*/ @Override public String toString() { if (null == phaseName) { return (String.valueOf(this.ordinal)); } return (String.valueOf(this.phaseName) + ' ' + this.ordinal); } /** *

Return the name of this phase.

* * @since 2.2 * * @return the name */ public String getName() { return this.phaseName; } /** *

Return a PhaseId * representation of the arcument phase.

* * @param phase the String for which the corresponding * PhaseId should be returned. * * @throws NullPointerException if argument phase is * null. * * @throws FacesException if the PhaseId * corresponding to the argument phase cannot be found. * * @since 2.2 * * @return the phase id corresponding to the argument {@code phase} */ public static PhaseId phaseIdValueOf(String phase) { if (null == phase) { throw new NullPointerException(); } PhaseId result = null; if (ANY_PHASE_NAME.equals(phase)) { result = PhaseId.ANY_PHASE; } else if (APPLY_REQUEST_VALUES_NAME.equalsIgnoreCase(phase)) { result = PhaseId.APPLY_REQUEST_VALUES; } else if (INVOKE_APPLICATION_NAME.equalsIgnoreCase(phase)) { result = PhaseId.INVOKE_APPLICATION; } else if (PROCESS_VALIDATIONS_NAME.equalsIgnoreCase(phase)) { result = PhaseId.PROCESS_VALIDATIONS; } else if (RENDER_RESPONSE_NAME.equalsIgnoreCase(phase)) { result = PhaseId.RENDER_RESPONSE; } else if (RESTORE_VIEW_NAME.equalsIgnoreCase(phase)) { result = PhaseId.RESTORE_VIEW; } else if (UPDATE_MODEL_VALUES_NAME.equalsIgnoreCase(phase)) { result = PhaseId.UPDATE_MODEL_VALUES; } else { throw new FacesException("Not a valid phase [" + phase + "]"); } return result; } // ------------------------------------------------------- Static Variables /** *

Static counter returning the ordinal value to be assigned to the * next instance that is created.

*/ private static int nextOrdinal = 0; // ------------------------------------------------------ Create Instances // Any new Phase values must go at the end of the list, or we will break // backwards compatibility on serialized instances private static final String ANY_PHASE_NAME = "ANY"; /** *

Identifier that indicates an interest in events, no matter * which request processing phase is being performed.

*/ public static final PhaseId ANY_PHASE = new PhaseId(ANY_PHASE_NAME); private static final String RESTORE_VIEW_NAME = "RESTORE_VIEW"; /** *

Identifier that indicates an interest in events queued for * the Restore View phase of the request * processing lifecycle.

*/ public static final PhaseId RESTORE_VIEW = new PhaseId(RESTORE_VIEW_NAME); private static final String APPLY_REQUEST_VALUES_NAME = "APPLY_REQUEST_VALUES"; /** *

Identifier that indicates an interest in events queued for * the Apply Request Values phase of the request * processing lifecycle.

*/ public static final PhaseId APPLY_REQUEST_VALUES = new PhaseId(APPLY_REQUEST_VALUES_NAME); private static final String PROCESS_VALIDATIONS_NAME = "PROCESS_VALIDATIONS"; /** *

Identifier that indicates an interest in events queued for * the Process Validations phase of the request * processing lifecycle.

*/ public static final PhaseId PROCESS_VALIDATIONS = new PhaseId(PROCESS_VALIDATIONS_NAME); private static final String UPDATE_MODEL_VALUES_NAME = "UPDATE_MODEL_VALUES"; /** *

Identifier that indicates an interest in events queued for * the Update Model Values phase of the request * processing lifecycle.

*/ public static final PhaseId UPDATE_MODEL_VALUES = new PhaseId(UPDATE_MODEL_VALUES_NAME); private static final String INVOKE_APPLICATION_NAME = "INVOKE_APPLICATION"; /** *

Identifier that indicates an interest in events queued for * the Invoke Application phase of the request * processing lifecycle.

*/ public static final PhaseId INVOKE_APPLICATION = new PhaseId(INVOKE_APPLICATION_NAME); private static final String RENDER_RESPONSE_NAME = "RENDER_RESPONSE"; /** *

Identifier for the Render Response phase of the * request processing lifecycle.

*/ public static final PhaseId RENDER_RESPONSE = new PhaseId(RENDER_RESPONSE_NAME); /** *

Array of all defined values, ascending order of ordinal value. * Be sure you include any new instances created above, in the * same order.

*/ private static final PhaseId[] values = {ANY_PHASE, RESTORE_VIEW, APPLY_REQUEST_VALUES, PROCESS_VALIDATIONS, UPDATE_MODEL_VALUES, INVOKE_APPLICATION, RENDER_RESPONSE}; /** *

List of valid {@link PhaseId} instances, in ascending order * of their ordinal value.

*/ public static final List VALUES = Collections.unmodifiableList(Arrays.asList(values)); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy