src/macosx/classes/apple/applescript/AppleScriptEngine.java

Print this page




 138         put(ARGV, "");
 139 
 140         init();
 141     }
 142 
 143     /**
 144      * The initializer populates the local context with some useful predefined variables:
 145      * <ul><li><code>javax_script_language_version</code> - the version of AppleScript that the AppleScriptEngine supports.</li>
 146      * <li><code>javax_script_language</code> - "AppleScript" -- the language supported by the AppleScriptEngine.</li>
 147      * <li><code>javax_script_engine</code> - "AppleScriptEngine" -- the name of the ScriptEngine.</li>
 148      * <li><code>javax_script_engine_version</code> - the version of the AppleScriptEngine</li>
 149      * <li><code>javax_script_argv</code> - "" -- AppleScript does not take arguments from the command line</li>
 150      * <li><code>javax_script_filename</code> - "" -- the currently executing filename</li>
 151      * <li><code>javax_script_name</code> - "AppleScriptEngine" -- the short name of the AppleScriptEngine</li>
 152      * <li><code>THREADING</code> - null -- the AppleScriptEngine does not support concurrency, you will have to implement thread-safeness yourself.</li></ul>
 153      */
 154     private void init() {
 155         TRACE("init()");
 156         // set up our context
 157 /* TODO -- name of current executable?  bad java documentation at:
 158  * http://java.sun.com/javase/6/docs/api/javax/script/ScriptEngine.html#FILENAME */
 159         put(ScriptEngine.FILENAME, "");
 160         put(ScriptEngine.ENGINE, getEngine());
 161         put(ScriptEngine.ENGINE_VERSION, getEngineVersion());
 162         put(ScriptEngine.NAME, getName());
 163         put(ScriptEngine.LANGUAGE, getLanguage());
 164         put(ScriptEngine.LANGUAGE_VERSION, getLanguageVersion());
 165 
 166         // TODO -- for now, err on the side of caution and say that we are NOT thread-safe
 167         put("THREADING", null);
 168     }
 169 
 170     /**
 171      * Uses the AppleScriptEngine to get the local AppleScript version
 172      * @return the version of AppleScript running on the system
 173      */
 174     protected String getLanguageVersion() {
 175         TRACE("AppleScriptEngine.getLanguageVersion()");
 176         try {
 177             final Object result = eval("get the version of AppleScript");
 178             if (result instanceof String) return (String)result;




 138         put(ARGV, "");
 139 
 140         init();
 141     }
 142 
 143     /**
 144      * The initializer populates the local context with some useful predefined variables:
 145      * <ul><li><code>javax_script_language_version</code> - the version of AppleScript that the AppleScriptEngine supports.</li>
 146      * <li><code>javax_script_language</code> - "AppleScript" -- the language supported by the AppleScriptEngine.</li>
 147      * <li><code>javax_script_engine</code> - "AppleScriptEngine" -- the name of the ScriptEngine.</li>
 148      * <li><code>javax_script_engine_version</code> - the version of the AppleScriptEngine</li>
 149      * <li><code>javax_script_argv</code> - "" -- AppleScript does not take arguments from the command line</li>
 150      * <li><code>javax_script_filename</code> - "" -- the currently executing filename</li>
 151      * <li><code>javax_script_name</code> - "AppleScriptEngine" -- the short name of the AppleScriptEngine</li>
 152      * <li><code>THREADING</code> - null -- the AppleScriptEngine does not support concurrency, you will have to implement thread-safeness yourself.</li></ul>
 153      */
 154     private void init() {
 155         TRACE("init()");
 156         // set up our context
 157 /* TODO -- name of current executable?  bad java documentation at:
 158  * http://docs.oracle.com/javase/6/docs/api/javax/script/ScriptEngine.html#FILENAME */
 159         put(ScriptEngine.FILENAME, "");
 160         put(ScriptEngine.ENGINE, getEngine());
 161         put(ScriptEngine.ENGINE_VERSION, getEngineVersion());
 162         put(ScriptEngine.NAME, getName());
 163         put(ScriptEngine.LANGUAGE, getLanguage());
 164         put(ScriptEngine.LANGUAGE_VERSION, getLanguageVersion());
 165 
 166         // TODO -- for now, err on the side of caution and say that we are NOT thread-safe
 167         put("THREADING", null);
 168     }
 169 
 170     /**
 171      * Uses the AppleScriptEngine to get the local AppleScript version
 172      * @return the version of AppleScript running on the system
 173      */
 174     protected String getLanguageVersion() {
 175         TRACE("AppleScriptEngine.getLanguageVersion()");
 176         try {
 177             final Object result = eval("get the version of AppleScript");
 178             if (result instanceof String) return (String)result;