Java Javascript Mozilla Library stringValue(String name, Scriptable scope)

Here you can find the source of stringValue(String name, Scriptable scope)

Description

Returns the value of a JavaScript variable, or null.

License

Open Source License

Parameter

Parameter Description
name the JavaScript variable.
scope the JavaScript scope to read from

Return

the value of name or null.

Declaration

static String stringValue(String name, Scriptable scope) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.mozilla.javascript.Scriptable;

public class Main {
    /**//from w  ww  . j  a  v  a  2 s .c  o  m
     * Returns the value of a JavaScript variable, or null.
     * @param name the JavaScript variable.
     * @param scope the JavaScript scope to read from
     * @return the value of <i>name</i> or null.
     */
    static String stringValue(String name, Scriptable scope) {
        if (scope == null) {
            return null;
        }
        Object o = scope.get(name, scope);
        return o instanceof String ? (String) o : null;
    }
}

Related

  1. removeLinkFromXhtml(Object xhtml, String link)
  2. runWithAllOptimizationLevels(final ContextAction action)
  3. runWithOptimizationLevel(final ContextAction action, final int optimizationLevel)
  4. scriptableObjectToString(Object scriptObject)
  5. stringToNumber(CharSequence string)
  6. toInt(Object obj, int defaultValue)
  7. toJavaBoolean(final Scriptable options, final String key)
  8. toJavaInt(final Object fromScript)
  9. toList(AstNode... nodes)