javax.el

Class StaticFieldELResolver


  • public class StaticFieldELResolver
    extends ELResolver

    An ELResolver for resolving static fields, enum constants and static methods. Also handles constructor calls as a special case.

    The resolver handles base objects of the type ELClass, which is usually generated by an EL implementation.

    Since:
    EL 3.0
    See Also:
    ELClass
    • Constructor Detail

      • StaticFieldELResolver

        public StaticFieldELResolver()
    • Method Detail

      • getValue

        public Object getValue(ELContext context,
                               Object base,
                               Object property)

        Returns the value of a static field.

        If the base object is an instance of ELClass and the property is String, the propertyResolved property of the ELContext object must be set to true by this resolver, before returning. If this property is not true after this method is called, the caller should ignore the return value.

        If the property is a public static field of class specified in ELClass, return the value of the static field. An Enum constant is a public static field of an Enum object, and is a special case of this.
        Specified by:
        getValue in class ELResolver
        Parameters:
        context - The context of this evaluation.
        base - An ELClass.
        property - A static field name.
        Returns:
        If the propertyResolved property of ELContext was set to true, then the static field value.
        Throws:
        NullPointerException - if context is null.
        PropertyNotFoundException - if the specified class does not exist, or if the field is not a public static filed of the class, or if the field is inaccessible.
      • setValue

        public void setValue(ELContext context,
                             Object base,
                             Object property,
                             Object value)

        Attempts to write to a static field.

        If the base object is an instance of ELClassand the property is String, a PropertyNotWritableException will always be thrown, because writing to a static field is not allowed.

        Specified by:
        setValue in class ELResolver
        Parameters:
        context - The context of this evaluation.
        base - An ELClass
        property - The name of the field
        value - The value to set the field of the class to.
        Throws:
        NullPointerException - if context is null
        PropertyNotWritableException
      • invoke

        public Object invoke(ELContext context,
                             Object base,
                             Object method,
                             Class<?>[] paramTypes,
                             Object[] params)

        Invokes a public static method or the constructor for a class.

        If the base object is an instance of ELClass and the method is a String, the propertyResolved property of the ELContext object must be set to true by the resolver, before returning. If this property is not true after this method is called, the caller should ignore the return value.

        Invoke the public static method specified by method.

        The process involved in the method selection is the same as that used in BeanELResolver.

        As a special case, if the name of the method is "<init>", the constructor for the class will be invoked.

        Overrides:
        invoke in class ELResolver
        Parameters:
        base - An ELClass
        method - When coerced to a String, the simple name of the method.
        paramTypes - An array of Class objects identifying the method's formal parameter types, in declared order. Use an empty array if the method has no parameters. Can be null, in which case the method's formal parameter types are assumed to be unknown.
        params - The parameters to pass to the method, or null if no parameters.
        context - The context of this evaluation.
        Returns:
        The result of the method invocation (null if the method has a void return type).
        Throws:
        MethodNotFoundException - if no suitable method can be found.
        ELException - if an exception was thrown while performing (base, method) resolution. The thrown exception must be included as the cause property of this exception, if available. If the exception thrown is an InvocationTargetException, extract its cause and pass it to the ELException constructor.
      • getType

        public Class<?> getType(ELContext context,
                                Object base,
                                Object property)

        Returns the type of a static field.

        If the base object is an instance of ELClassand the property is a String, the propertyResolved property of the ELContext object must be set to true by the resolver, before returning. If this property is not true after this method is called, the caller can safely assume no value has been set.

        If the property string is a public static field of class specified in ELClass, return the type of the static field.

        Specified by:
        getType in class ELResolver
        Parameters:
        context - The context of this evaluation.
        base - An ELClass.
        property - The name of the field.
        Returns:
        If the propertyResolved property of ELContext was set to true, then the type of the type of the field.
        Throws:
        NullPointerException - if context is null.
        PropertyNotFoundException - if field is not a public static filed of the class, or if the field is inaccessible.
      • isReadOnly

        public boolean isReadOnly(ELContext context,
                                  Object base,
                                  Object property)

        Inquires whether the static field is writable.

        If the base object is an instance of ELClassand the property is a String, the propertyResolved property of the ELContext object must be set to true by the resolver, before returning. If this property is not true after this method is called, the caller can safely assume no value has been set.

        Always returns a true because writing to a static field is not allowed.

        Specified by:
        isReadOnly in class ELResolver
        Parameters:
        context - The context of this evaluation.
        base - An ELClass.
        property - The name of the bean.
        Returns:
        true
        Throws:
        NullPointerException - if context is null.
      • getCommonPropertyType

        public Class<?> getCommonPropertyType(ELContext context,
                                              Object base)
        Returns the type of the property. Always returns String.class, since a field name is a String.
        Specified by:
        getCommonPropertyType in class ELResolver
        Parameters:
        context - The context of this evaluation.
        base - An ELClass.
        Returns:
        String.class.

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/el/staticfieldelresolver.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.