Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
Rhino JavaScript Java Library Source Code
Rhino JavaScript Java Library is an open-source implementation of JavaScript
written entirely in Java.
Rhino JavaScript Java Library Source Code files are provided in binary package (rhino-1.7.14.zip).
You can also browse the source code below:
✍: FYIcenter.com
⏎ org/mozilla/javascript/ast/VariableDeclaration.java
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.javascript.ast;
import java.util.ArrayList;
import java.util.List;
import org.mozilla.javascript.Token;
/**
* A list of one or more var, const or let declarations.
* Node type is {@link Token#VAR}, {@link Token#CONST} or
* {@link Token#LET}.<p>
*
* If the node is for {@code var} or {@code const}, the node position
* is the beginning of the {@code var} or {@code const} keyword.
* For {@code let} declarations, the node position coincides with the
* first {@link VariableInitializer} child.<p>
*
* A standalone variable declaration in a statement context returns {@code true}
* from its {@link #isStatement()} method.
*/
public class VariableDeclaration extends AstNode {
private List<VariableInitializer> variables = new ArrayList<VariableInitializer>();
private boolean isStatement;
{
type = Token.VAR;
}
public VariableDeclaration() {
}
public VariableDeclaration(int pos) {
super(pos);
}
public VariableDeclaration(int pos, int len) {
super(pos, len);
}
/**
* Returns variable list. Never {@code null}.
*/
public List<VariableInitializer> getVariables() {
return variables;
}
/**
* Sets variable list
* @throws IllegalArgumentException if variables list is {@code null}
*/
public void setVariables(List<VariableInitializer> variables) {
assertNotNull(variables);
this.variables.clear();
for (VariableInitializer vi : variables) {
addVariable(vi);
}
}
/**
* Adds a variable initializer node to the child list.
* Sets initializer node's parent to this node.
* @throws IllegalArgumentException if v is {@code null}
*/
public void addVariable(VariableInitializer v) {
assertNotNull(v);
variables.add(v);
v.setParent(this);
}
/**
* Sets the node type and returns this node.
* @throws IllegalArgumentException if {@code declType} is invalid
*/
@Override
public org.mozilla.javascript.Node setType(int type) {
if (type != Token.VAR
&& type != Token.CONST
&& type != Token.LET)
throw new IllegalArgumentException("invalid decl type: " + type);
return super.setType(type);
}
/**
* Returns true if this is a {@code var} (not
* {@code const} or {@code let}) declaration.
* @return true if {@code declType} is {@link Token#VAR}
*/
public boolean isVar() {
return type == Token.VAR;
}
/**
* Returns true if this is a {@link Token#CONST} declaration.
*/
public boolean isConst() {
return type == Token.CONST;
}
/**
* Returns true if this is a {@link Token#LET} declaration.
*/
public boolean isLet() {
return type == Token.LET;
}
/**
* Returns true if this node represents a statement.
*/
public boolean isStatement() {
return isStatement;
}
/**
* Set or unset the statement flag.
*/
public void setIsStatement(boolean isStatement) {
this.isStatement = isStatement;
}
private String declTypeName() {
return Token.typeToName(type).toLowerCase();
}
@Override
public String toSource(int depth) {
StringBuilder sb = new StringBuilder();
sb.append(makeIndent(depth));
sb.append(declTypeName());
sb.append(" ");
printList(variables, sb);
if (isStatement()) {
sb.append(";");
}
if(this.getInlineComment() != null) {
sb.append(this.getInlineComment().toSource(depth)).append("\n");
} else if (isStatement()) {
sb.append("\n");
}
return sb.toString();
}
/**
* Visits this node, then each {@link VariableInitializer} child.
*/
@Override
public void visit(NodeVisitor v) {
if (v.visit(this)) {
for (AstNode var : variables) {
var.visit(v);
}
}
}
}
⏎ org/mozilla/javascript/ast/VariableDeclaration.java
Or download all of them as a single archive file:
File name: rhino-1.7.14-sources.jar File size: 1029165 bytes Release date: 2022-01-06 Download
⇒ Example code to Test rhino-runtime-1.7.14.jar
⇐ Download Rhino JavaScript Binary Package
2022-05-03, ≈172🔥, 1💬
Popular Posts:
Where to get the Java source code for Connector/J 8.0 User API module? Java source code files for Co...
How to download and install JDK (Java Development Kit) 1.4? If you want to write Java applications, ...
What Is commons-net-ftp-2.0.jar? commons-net-ftp-2.0.jar is the JAR file for Apache Commons Net FTP ...
commons-io-1.4.jar is the JAR file for Commons IO 1.4, which is a library of utilities to assist wit...
How to download and install ojdbc11.jar for Oracle 21c? ojdbc11.jar for Oracle 21c is a Java JDBC Dr...