com.mucommander.ui.macosx
Class AppleScript

java.lang.Object
  extended by com.mucommander.ui.macosx.AppleScript

public class AppleScript
extends java.lang.Object

This class allows to run AppleScript code under Mac OS X, relying on the osacript command available that comes with any install of Mac OS X. This command is used instead of the Cocoa-Java library which has been deprecated by Apple.
Calls to execute(String, StringBuffer) on any OS other than Mac OS X will always fail.

Important notes about character encoding:

Author:
Maxence Bernard

Field Summary
static java.lang.String MACROMAN
          The MacRoman encoding
static java.lang.String UTF8
          The UTF-8 encoding
 
Constructor Summary
AppleScript()
           
 
Method Summary
static boolean execute(java.lang.String appleScript, java.lang.StringBuffer outputBuffer)
          Executes the given AppleScript and returns true if it completed its execution normally, i.e.
static java.lang.String getScriptEncoding()
          Returns the encoding that AppleScript uses on the current runtime environment: UTF8 for AppleScript 2.0+ (Mac OS X 10.5 and up) MACROMAN for AppleScript 1.10- (Mac OS X 10.4 or lower) If MACROMAN is used, the scripts passed to execute(String, StringBuffer) should not contain characters that are not part of the MacRoman charset or they will not be properly interpreted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF8

public static final java.lang.String UTF8
The UTF-8 encoding

See Also:
Constant Field Values

MACROMAN

public static final java.lang.String MACROMAN
The MacRoman encoding

See Also:
Constant Field Values
Constructor Detail

AppleScript

public AppleScript()
Method Detail

execute

public static boolean execute(java.lang.String appleScript,
                              java.lang.StringBuffer outputBuffer)
Executes the given AppleScript and returns true if it completed its execution normally, i.e. without any error. The script's output is accumulated in the given StringBuffer. If the script completed its execution normally, the buffer will contain the script's standard output. If the script failed because of an error in it, the buffer will contain details about the error.

If the caller is not interested in the script's output, a null value can be passed which will speed the execution up a little.

Parameters:
appleScript - the AppleScript to execute
outputBuffer - the StringBuffer that will hold the script's output, null for no output
Returns:
true if the script was succesfully executed, false if the

getScriptEncoding

public static java.lang.String getScriptEncoding()
Returns the encoding that AppleScript uses on the current runtime environment: If MACROMAN is used, the scripts passed to execute(String, StringBuffer) should not contain characters that are not part of the MacRoman charset or they will not be properly interpreted.

Returns:
the encoding that AppleScript uses on the current runtime environment


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard