Keine Cache-Version

Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code LNG204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.
javax.script

Class AbstractScriptEngine

  • All Implemented Interfaces:
    ScriptEngine

    public abstract class AbstractScriptEngine
    extends Object
    implements ScriptEngine
    Provides a standard implementation for several of the variants of the eval method.

    eval(Reader)

    eval(String)

    eval(String, Bindings)

    eval(Reader, Bindings)

    are implemented using the abstract methods

    eval(Reader,ScriptContext) or eval(String, ScriptContext)

    with a SimpleScriptContext.

    A SimpleScriptContext is used as the default ScriptContext of the AbstractScriptEngine..

    Since:
    1.6
    • Field Detail

      • context

        protected ScriptContext context
        The default ScriptContext of this AbstractScriptEngine.
    • Constructor Detail

      • AbstractScriptEngine

        public AbstractScriptEngine()
        Creates a new instance of AbstractScriptEngine using a SimpleScriptContext as its default ScriptContext.
      • AbstractScriptEngine

        public AbstractScriptEngine(Bindings n)
        Creates a new instance using the specified Bindings as the ENGINE_SCOPE Bindings in the protected context field.
        Parameters:
        n - The specified Bindings.
        Throws:
        NullPointerException - if n is null.
    • Method Detail

      • setContext

        public void setContext(ScriptContext ctxt)
        Sets the value of the protected context field to the specified ScriptContext.
        Specified by:
        setContext in interface ScriptEngine
        Parameters:
        ctxt - The specified ScriptContext.
        Throws:
        NullPointerException - if ctxt is null.
      • getContext

        public ScriptContext getContext()
        Returns the value of the protected context field.
        Specified by:
        getContext in interface ScriptEngine
        Returns:
        The value of the protected context field.
      • getBindings

        public Bindings getBindings(int scope)
        Returns the Bindings with the specified scope value in the protected context field.
        Specified by:
        getBindings in interface ScriptEngine
        Parameters:
        scope - The specified scope
        Returns:
        The corresponding Bindings.
        Throws:
        IllegalArgumentException - if the value of scope is invalid for the type the protected context field.
      • setBindings

        public void setBindings(Bindings bindings,
                       int scope)
        Sets the Bindings with the corresponding scope value in the context field.
        Specified by:
        setBindings in interface ScriptEngine
        Parameters:
        bindings - The specified Bindings.
        scope - The specified scope.
        Throws:
        IllegalArgumentException - if the value of scope is invalid for the type the context field.
        NullPointerException - if the bindings is null and the scope is ScriptContext.ENGINE_SCOPE
      • put

        public void put(String key,
               Object value)
        Sets the specified value with the specified key in the ENGINE_SCOPE Bindings of the protected context field.
        Specified by:
        put in interface ScriptEngine
        Parameters:
        key - The specified key.
        value - The specified value.
        Throws:
        NullPointerException - if key is null.
        IllegalArgumentException - if key is empty.
      • get

        public Object get(String key)
        Gets the value for the specified key in the ENGINE_SCOPE of the protected context field.
        Specified by:
        get in interface ScriptEngine
        Parameters:
        key - The key whose value is to be returned
        Returns:
        The value for the specified key.
        Throws:
        NullPointerException - if key is null.
        IllegalArgumentException - if key is empty.
      • eval

        public Object eval(Reader reader,
                  Bindings bindings)
                    throws ScriptException
        eval(Reader, Bindings) calls the abstract eval(Reader, ScriptContext) method, passing it a ScriptContext whose Reader, Writers and Bindings for scopes other that ENGINE_SCOPE are identical to those members of the protected context field. The specified Bindings is used instead of the ENGINE_SCOPE Bindings of the context field.
        Specified by:
        eval in interface ScriptEngine
        Parameters:
        reader - A Reader containing the source of the script.
        bindings - A Bindings to use for the ENGINE_SCOPE while the script executes.
        Returns:
        The return value from eval(Reader, ScriptContext)
        Throws:
        ScriptException - if an error occurs in script.
        NullPointerException - if any of the parameters is null.
      • eval

        public Object eval(String script,
                  Bindings bindings)
                    throws ScriptException
        Same as eval(Reader, Bindings) except that the abstract eval(String, ScriptContext) is used.
        Specified by:
        eval in interface ScriptEngine
        Parameters:
        script - A String containing the source of the script.
        bindings - A Bindings to use as the ENGINE_SCOPE while the script executes.
        Returns:
        The return value from eval(String, ScriptContext)
        Throws:
        ScriptException - if an error occurs in script.
        NullPointerException - if any of the parameters is null.
      • eval

        public Object eval(Reader reader)
                    throws ScriptException
        eval(Reader) calls the abstract eval(Reader, ScriptContext) passing the value of the context field.
        Specified by:
        eval in interface ScriptEngine
        Parameters:
        reader - A Reader containing the source of the script.
        Returns:
        The return value from eval(Reader, ScriptContext)
        Throws:
        ScriptException - if an error occurs in script.
        NullPointerException - if any of the parameters is null.
      • eval

        public Object eval(String script)
                    throws ScriptException
        Same as eval(Reader) except that the abstract eval(String, ScriptContext) is used.
        Specified by:
        eval in interface ScriptEngine
        Parameters:
        script - A String containing the source of the script.
        Returns:
        The return value from eval(String, ScriptContext)
        Throws:
        ScriptException - if an error occurrs in script.
        NullPointerException - if any of the parameters is null.
      • getScriptContext

        protected ScriptContext getScriptContext(Bindings nn)
        Returns a SimpleScriptContext. The SimpleScriptContext:

        • Uses the specified Bindings for its ENGINE_SCOPE
        • Uses the Bindings returned by the abstract getGlobalScope method as its GLOBAL_SCOPE
        • Uses the Reader and Writer in the default ScriptContext of this ScriptEngine


        A SimpleScriptContext returned by this method is used to implement eval methods using the abstract eval(Reader,Bindings) and eval(String,Bindings) versions.
        Parameters:
        nn - Bindings to use for the ENGINE_SCOPE
        Returns:
        The SimpleScriptContext

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 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/script/abstractscriptengine.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 Diese 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.

Inhaltsverzeichnis Haut