Java Reference
In-Depth Information
Chapter 3
Passing Parameters
to Scripts
In this chapter, you will learn:
Classes used in passing parameters from Java programs to scripts
How to create and use
Bindings object to hold the parameters
How to define the scope of parameters
How to pass parameters to scripts using different objects and
scopes
The advantages and disadvantages of different ways of passing
parameters
How to write script's output to a file
Bindings, Scope, and Context
To understand the details of the parameter passing mechanism, three terms must be
understood clearly: bindings, scope, and context. These terms are confusing at first. This
chapter explains the parameter passing mechanism using the following steps:
First, it defines these terms
Second, it defines the relationship between these terms
Third, it explains how to use them in Java programs
Bindings
A Bindings is a set of key-value pairs where all keys must be nonempty, non-null Strings.
In Java code, a Bindings is an instance of the Bindings interface. The SimpleBindings
class is an implementation of the Bindings interface. A script engine may provide its own
implementation of the Bindings interface.
 
Search WWH ::




Custom Search