Java Javascript Mozilla Library getStringValue(AstNode element)

Here you can find the source of getStringValue(AstNode element)

Description

get String Value

License

Open Source License

Declaration

static public String getStringValue(AstNode element) 

Method Source Code


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

import org.mozilla.javascript.ast.AstNode;
import org.mozilla.javascript.ast.KeywordLiteral;
import org.mozilla.javascript.ast.Name;
import org.mozilla.javascript.ast.StringLiteral;

public class Main {
    static public String getStringValue(AstNode element) {
        if (element instanceof StringLiteral)
            return ((StringLiteral) element).getValue();
        if (element instanceof KeywordLiteral)
            return ((KeywordLiteral) element).toSource();
        if (element instanceof Name)
            return ((Name) element).getIdentifier();
        return "";
    }/* w  ww  .j  av  a  2  s  .  co m*/
}

Related

  1. getPropertyName(AstNode propKeyNode)
  2. getPrototypeClazz(List nodes)
  3. getScriptableArgument(Object[] args, int pos, boolean allowNull)
  4. getStaticProperty(Scriptable mixin, String name)
  5. getStringArgument(Object[] args, int pos, boolean allowNull)
  6. getXhtmlLinks(Object xhtml)
  7. grabContextFactoryGlobalSetter()
  8. isContained(AstNode mayAncestor, AstNode filial)
  9. isDefined(final Object object)