de.kapsi.util
Class OSAScript

java.lang.Object
  extended byde.kapsi.util.OSAScript
All Implemented Interfaces:
java.io.Serializable

public class OSAScript
extends java.lang.Object
implements java.io.Serializable

OSAScript is a simple scripting interface for Apple's Open Scripting Architecture (OSA).

See Also:
Serialized Form

Constructor Summary
OSAScript(java.io.File file)
          Loads a precompiled .scpt file
OSAScript(java.lang.String source)
          Creates a new OSAScript from the passed source code.
 
Method Summary
 void compile()
          Compiles the script
 AEDesc execute()
          Executes the script and returns the results as byte-array.
 AEDesc execute(java.lang.String subroutine)
          Executes a specific subroutine of the script and returns the results as byte-array.
 AEDesc execute(java.lang.String subroutine, java.lang.String[] args)
          Executes a specific subroutine of the script with optional parameters and returns the results as byte-array.
protected  void finalize()
           
 byte[] getBytes()
          Returns the binaries of this Script or null if script is not compiled.
 java.lang.String getSource()
          Returns the source of this script or null if script was loaded from a file.
 boolean isCompiled()
          Returns true if script is compiled
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OSAScript

public OSAScript(java.lang.String source)
          throws java.lang.UnsatisfiedLinkError,
                 OSAException
Creates a new OSAScript from the passed source code. E.g.

OSAScript os = new OSAScript("tell application \"Finder\"\nactivate\nend tell");
os.execute();


OSAScript

public OSAScript(java.io.File file)
          throws java.lang.UnsatisfiedLinkError,
                 java.io.IOException,
                 OSAException
Loads a precompiled .scpt file

Method Detail

getSource

public java.lang.String getSource()
Returns the source of this script or null if script was loaded from a file.


isCompiled

public boolean isCompiled()
Returns true if script is compiled


getBytes

public byte[] getBytes()
                throws OSAException
Returns the binaries of this Script or null if script is not compiled. The binaries have the same format as precompiled .scpt files!

Throws:
OSAException

compile

public void compile()
             throws OSAException
Compiles the script

Throws:
OSAException

execute

public AEDesc execute()
               throws OSAException
Executes the script and returns the results as byte-array. It is up to you to interpret the data (usually Strings). The script will be compiled automatically if necessary.

Throws:
OSAException

execute

public AEDesc execute(java.lang.String subroutine)
               throws OSAException
Executes a specific subroutine of the script and returns the results as byte-array. It is up to you to interpret the data (usually Strings). The script will be compiled automatically if necessary.

The name of the subroutine must be written in lower case!

Throws:
OSAException

execute

public AEDesc execute(java.lang.String subroutine,
                      java.lang.String[] args)
               throws OSAException
Executes a specific subroutine of the script with optional parameters and returns the results as byte-array. It is up to you to interpret the data (usually Strings). The script will be compiled automatically if necessary.

The name of the subroutine must be written in lower case!

Throws:
OSAException

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable