Java Reference
In-Depth Information
public
public
Object
getParameter
(
String key
) {
switch
switch
(
key
) {
case
case
ScriptEngine
.
ENGINE
:
return
return
getEngineName
();
case
case
ScriptEngine
.
ENGINE_VERSION
:
return
return
getEngineVersion
();
case
case
ScriptEngine
.
LANGUAGE
:
return
return
getLanguageName
();
case
case
ScriptEngine
.
LANGUAGE_VERSION
:
return
return
getLanguageVersion
();
default
default
:
throw
throw new
new
IllegalArgumentException
(
"Unknown parameter "
+
key
);
}
}
@Override
public
public
String
getMethodCallSyntax
(
String obj
,
String m
,
String
...
args
) {
// TODO Auto-generated method stub
return
return null
null
;
}
@Override
public
public
String
getOutputStatement
(
String toDisplay
) {
return
return
toDisplay
;
}
@Override
public
public
String
getProgram
(
String
...
statements
) {
return
return
statements
.
toString
();
}
@Override
public
public
ScriptEngine
getScriptEngine
() {
return
return new
new
CalcScriptEngine
(
this
this
);
}
}
Finally, a configuration file is required. This file must be named exactly
javax.script.ScriptEngineFactory
and must be located precisely in the
META-INF/services
directory of the same classpath element as your JAR files. This file must contain exactly one
line with just the full name of your factory class. For example:
otherlang.calcscriptengine.CalcScriptEngineFactory