final int engineCount = engineFactories.size();
if (SHOW_FACTORIES.equalsIgnoreCase(show)) {
System.err.println("Found "+engineCount+ " engine factories");
for (Iterator iter = engineFactories.iterator(); iter.hasNext();){
ScriptEngineFactory fac = (ScriptEngineFactory) iter.next();
showFactory(fac, false);
}
return;
}
if (language == null && extension == null && inFileName != null) {
int i = inFileName.lastIndexOf('.');
if (i > 0) {
extension = inFileName.substring(i+1);
}
}
if (extension == null && language == null) {
throw new IllegalArgumentException("unable to determine language");
}
Reader in;
if (inFileName != null) {
in = new FileReader(inFileName);
} else {
in = new InputStreamReader(System.in);
inFileName = DEFAULT_IN_FILE_NAME;
}
try {
ScriptEngine engine;
if (language != null) {
engine = mgr.getEngineByName(language);
if (engine == null){
throw new IllegalArgumentException("unable to find engine using Language: "+language);
}
} else {
engine = mgr.getEngineByExtension(extension);
if (engine == null){
throw new IllegalArgumentException("unable to find engine using Extension: "+extension);
}
}
if (SHOW_ENGINE.equalsIgnoreCase(show)){
ScriptEngineFactory fac = engine.getFactory();
showFactory(fac, true);
System.err.println("Engine="+engine.getClass().getName());
if (engine instanceof Compilable){
System.err.println("Engine supports Compilable interface.");
}