ewe.sys
Class Vm

java.lang.Object
  extended byewe.sys.Vm
All Implemented Interfaces:
VmConstants

public class Vm
extends Object
implements VmConstants

Vm contains various system level methods.

This class contains methods to copy arrays, obtain a timestamp, sleep and get platform and version information.


Field Summary
static Vector dontGc
          A Vector where you can placed objects that you don't want gc'd.
static int IDABORT
           
static int IDCANCEL
           
static int IDIGNORE
           
static int IDNO
           
static int IDOK
           
static int IDRETRY
           
static int IDYES
           
static int MAX_TIMER_ENTRIES
          Obsolete - Used with setParameter(), it sets the maximum number of combined timer/callback/coroutine entries the system can handle.
static int MB_ABORTRETRYIGNORE
           
static int MB_APPLMODAL
           
static int MB_DEFBUTTON1
           
static int MB_DEFBUTTON2
           
static int MB_DEFBUTTON3
           
static int MB_ICONASTERISK
           
static int MB_ICONERROR
           
static int MB_ICONEXCLAMATION
           
static int MB_ICONHAND
           
static int MB_ICONINFORMATION
           
static int MB_ICONQUESTION
           
static int MB_ICONSTOP
           
static int MB_ICONWARNING
           
static int MB_OK
           
static int MB_OKCANCEL
           
static int MB_RETRYCANCEL
           
static int MB_SYSTEMMODAL
           
static int MB_TASKMODAL
           
static int MB_YESNO
           
static int MB_YESNOCANCEL
           
static int SET_ALWAYS_SHOW_SIP_BUTTON
          Used with setParameter() and a value of 1, it tells the VM to always show the SIP button.
static int SET_NO_WINDOWS
          Used with setParameter() and a value of 1, it switches on simulation of single windowing.
static int SIMULATE_SIP
          Used with setParameter() it switches on (1) or off (0) SIP simulation for Java and ewe on the PC.
static int SIP_CURRENT
           
static int SIP_FREEZE
           
static int SIP_IS_ON
           
static int SIP_LEAVE_BUTTON
          See documentation of SetSIP()
static int SIP_LOCK
          See documentation of SetSIP()
static int SIP_ON
          See documentation of SetSIP()
static int SIP_UNFREEZE
           
static int STANDARD_ERROR
          Use with getStandardStream().
static int STANDARD_INPUT
          Use with getStandardStream().
static int STANDARD_OUTPUT
          Use with getStandardStream().
static int TIMER_TICK
          Used with setParameter() it adjusts the minimum timer tick.
 
Fields inherited from interface ewe.sys.VmConstants
BUSY_CURSOR, COPY_MULTIPLE_CURSOR, COPY_SINGLE_CURSOR, CROSS_CURSOR, DEFAULT_CURSOR, DONT_DROP_CURSOR, DRAG_MULTIPLE_CURSOR, DRAG_SINGLE_CURSOR, HAND_CURSOR, IBEAM_CURSOR, INVISIBLE_CURSOR, LEFT_RIGHT_CURSOR, MEMORY_MAP_ON_DEMAND, MEMORY_MAP_STRICT, MOVE_CURSOR, NO_CURSOR, RESIZE_CURSOR, SND_ALIAS, SND_ALIAS_ID, SND_ASYNC, SND_FILENAME, SND_LOOP, SND_MEMORY, SND_NODEFAULT, SND_NOSTOP, SND_NOWAIT, SND_RESOURCE, SND_SYNC, UP_DOWN_CURSOR, VM_FILE_SEPARATOR, VM_FLAG_COUNTER_ROTATE_SCREEN, VM_FLAG_HAS_SOFT_KEYS, VM_FLAG_IS_APPLET, VM_FLAG_IS_MOBILE, VM_FLAG_IS_MONOCHROME, VM_FLAG_IS_ZAURUS_EVM, VM_FLAG_LOW_MEMORY, VM_FLAG_NO_CR, VM_FLAG_NO_KEYBOARD, VM_FLAG_NO_MOUSE_POINTER, VM_FLAG_NO_PEN, VM_FLAG_NO_WINDOWS, VM_FLAG_ROTATE_SCREEN, VM_FLAG_SIP_BUTTON_ALWAYS_SHOWN, VM_FLAG_SIP_BUTTON_ON_SCREEN, VM_FLAG_SLOW_MACHINE, VM_FLAG_USE_NATIVE_TEXT_INPUT, VM_FLAG_USING_CLASSES, VM_FLAGS, VM_PATH_SEPARATOR, VM_USE_SIP, WAIT_CURSOR
 
Method Summary
static boolean amInSystemQueue()
          This checks if the current thread is being run within the System Queue.
static void applicationError(String error)
          Force a halt of the application due to a critical error.
static void arraycopy(Object srcArray, int srcStart, Object dstArray, int dstStart, int length)
          This is exactly the same as copyArray() except that it is a void method and that it mirrors the standard System.arraycopy.
static int callInSystemQueue(CallBack who, Object data)
          This causes the callBack() method to be invoked on the CallBack object that will be in the OS's native message queue.
static int callInSystemQueue(Window w, CallBack who, Object data)
          This causes the callBack() method to be invoked on the CallBack object that will be in the OS's native message queue for a particular Window.
static void cancelTimer(int timerId)
          This cancels timer ticks for the specified timerID.
static int captureAppKeys(int options)
          Deprecated. use ewe.ui.Window.captureAppKeys() instead.
static int changeTimer(int timerId, TimerProc target, int newInterval)
          This cancels the current timer and then requests a new one with a new interval.
static boolean copyArray(Object srcArray, int srcStart, Object dstArray, int dstStart, int length)
          Copies the elements of one array to another array.
static int countObjects(boolean doGCFirst)
          This returns a count of allocated objects.
static int createCursor(Object cursor)
          Use this to create a new Mouse cursor.
static String createStringWithChars(char[] chars)
          Create a new String that uses the specified character array without creating a new character array for the String.
static int debug(Object in, Object out, int options)
           
static void debug(String message)
          Print a message on the console with no option.
static void debug(String message, int options)
          Print a message on the console.
static void debugObject(Object data, int options)
           
static PrintWriter err()
          Get a PrintWriter to standard error or to an application Console if standard error is not available (e.g.
static Process exec(String command)
          Execute a new process.
static Process exec(String[] command)
          Execute a new process.
static Process exec(String[] command, String[] env)
          Execute a new process.
static Process exec(String command, String[] env)
          Execute a new process.
static int exec(String command, String args, int launchCode, boolean wait)
          Deprecated. - use exec(String [] command, String [] environment) instead
static Process execEwe(String[] arguments, String[] env)
          Execute the Ewe VM with the supplied parameters.
static Process execEwe(String pathToEweFile, String args)
          Execute a ".ewe" file using the installed Ewe VM.
static boolean execute(String command, String args)
          Deprecated. - use exec(String [] command, String [] environment) instead
static boolean executeEwe(String pathToEweFile, String args)
          Deprecated. - use execEwe() instead.
static void exit(int retCode)
          Exit the application.
static void freezeSIP(boolean freezeOrUnfreeze, int sipOnOrOff, Window window)
          This temporarily holds the SIP in a particular mode (open or closed) until the current event thread has completed.
static void freezeSIP(Control forWho)
          This will freeze the SIP in it's current state until the end of the processing of the current Event.
static void gc()
          Do a garbage collection.
static PropertyList getAppletProperties()
          This returns properties for the current Applet if it is being run as an Applet.
static String getAStackTrace(Throwable th)
          This gets a String representation of the full stack trace for a Throwable, but not for any of its possible chained exceptions.
static int getAsyncKeyState(int keyCode)
          This is used to get the pressed state of a particular key at the time the method is called.
static Throwable getCause(Throwable target)
          This provides a fully portable method of getting the "cause" of a Throwable for exception chaining.
static int getClassMemory()
          This returns the amount of class memory used in bytes.
static String getClipboardText(String defaultText)
          Get the text in the system clipboard.
static String getFullStackTrace(Throwable th)
          This gets the fully expanded stack trace for the Throwable and all chained throwables.
static Locale getLocale()
          Get a default locale object.
static int getMessage(SystemMessage dest, boolean peek, boolean remove)
           
static int getNewId()
           
static int getParameter(int parameterID)
          This gets paramter values.
static String getPathToEweVM()
          Return the path to the registered Ewe VM executable file.
static String getPlatform()
          Returns the platform the Virtual Machine is running under as a string.
static String[] getProgramArguments()
          Get the program arguments.
static String getProperty(String propertyName, String defaultValue)
          This works similar to the true java.lang.System.getProperty().
static Object[] getReferencedObjects()
          Return an array that contains all reachable objects.
static int getSIP()
          Get the state of the SIP.
static String getStackTrace(Throwable th)
          Get a String representation of the stack trace for a Throwable object.
static String getStackTrace(Throwable t, int lines)
          Get a String representation of the stack trace for a Throwable object.
static Stream getStandardStream(int which)
          Return a Stream to the standard Input, Output or Error streams.
static char[] getStringChars(String str)
          Using the native VM this will expose the char array which represents the String.
static Object getSyncObject()
          This returns an object that you can synchronize with in an object "finalize()" method.
static MemoryStatus getSystemMemoryStatus()
          Get a MemoryStatus object representing the state of the system's physical memory.
static int getTimeStamp()
          Returns a time stamp in milliseconds.
static long getTimeStampLong()
          Returns a time stamp in milliseconds.
static int getUsedMemory(boolean doGCFirst)
          This returns the amount of object memory used in bytes.
static String getUserName()
          Returns the username of the user running the Virutal Machine.
static int getVersion()
          Returns the version of the Ewe Virtual Machine.
static int identityHashCode(Object obj)
          This returns the hashcode for the object as if the Object.hashCode() method was called regardless of any overriding hashCode() methods.
static BufferedReader in()
          Get a BufferedReader to standard input or to an application Console if standard input is not available (e.g.
static boolean isColor()
          Returns true if the system supports a color display and false otherwise.
static boolean isMobile()
          Returns true if this VM is running on what is considered a Mobile platform.
static void load(String libraryName)
           
static void loadDynamicLibrary(String name)
          Load a Dynamic Link Library which may have the native code for a ewe object.
static boolean loadLibrary(String name)
          Deprecated. use loadDynamicLibrary() instead.
static int loadResourceOrFile(String path, ByteArray dest)
          Deprecated.  
static Task makeBlockingTask(CallBack cb)
          Create a Task that can call a full system blocking method without blocking the VM.
static RandomAccessStream memoryMapFile(String path, String mode, int options)
          Memory map, if possible, a file on disk for later reading and possibly writing.
static int messageBox(String caption, String text, int type)
          This causes a "native" message box to be displayed - halting ewe programs until the user dismisses it.
static String mutateString(String str, char[] newChars, int start, int length, boolean useThisArray)
           
protected static boolean nativeLoadLibrary(String dllName)
           
static File newFileObject()
          Get a new ewe.io.File object which can be used to represent a file on the file system being used by the VM.
static RandomAccessStream openRandomAccessStream(String path, int mode)
          Deprecated. user the other openRandomAccessStream() instead.
static RandomAccessStream openRandomAccessStream(String path, String mode)
          This will attempt to provide a RandomAccessStream which can be used to read from a resource that is either stored in a ewe file, or resides on a sever (for Applet versions) or is a File.
static Stream openResource(Class aClass, String resourceName)
          This will attempt to open a class dependant resource for reading.
static PrintWriter out()
          Get a PrintWriter to standard output or to an application Console if standard output is not available (e.g.
static int playSound(String sound, int options)
          Deprecated. use SoundClip instead.
static void preloadVM(boolean doLoad)
          This tells the VM to pre-load the VM or to unload the VM.
static void printStackTrace(Throwable th, PrintWriter out)
           
static byte[] readResource(Class aClass, String resourceName)
          This opens a Stream to a resource using openResource and then reads in all the bytes.
static int readResource(String fileName, String resourceName, int options)
          Deprecated.  
static int releaseResource(String resourceName)
          Deprecated.  
static int requestTick(TimerProc target, int interval, boolean repeat)
          Request a timer tick to be sent to the TimerProc target.
static int requestTimer(TimerProc target, int interval)
          Request a timer tick to be sent to the TimerProc target.
static boolean runEweVM(String args)
          Deprecated. - use execEwe() instead.
static Handle runNativeDialog(Task nativeDialogTask)
          Run a task that will display a native dialog box of some kind while it runs.
static Throwable setCause(Throwable target, Throwable cause)
          This provides a fully portable method of setting the "cause" of a Throwable for exception chaining.
static void setClipboardText(String text)
          Sets the system clipboard text.
static int setCursor(Control c, int type)
           
static int setCursor(int type)
          Set the cursor.
static int setDeviceAutoOff(int seconds)
          Sets the device's "auto-off" time.
static void setFileObject(File fileObject)
          Set the File object to be used to represent the local file system.
static int setParameter(int ParameterId, int value)
          This sets VM parameters.
static boolean setProperty(String propertyName, String value)
          This only has an effect on the running program.
static void setSIP(int mode)
          This turns the SIP on PalmPC/PocketPC devices.
static void setSIP(int mode, Window forWindow)
          This turns the SIP on PalmPC/PocketPC devices.
static void showWait(boolean show)
           
static void showWait(Control c, boolean show)
           
static void sleep(int millis)
          Causes the VM to pause execution for the given number of milliseconds.
static String[] splitCommand(String args, String prepend)
           
static void startEwe(String[] programArguments)
          This is used to start the Ewe library running from a static main() method.
static void startEwe(String[] programArguments, String startClassName)
          This is used to start the Ewe library running from a static main() method.
static int toInt(Object obj)
          Deprecated. See identityHashCode()
static void useConsoleForIO()
          This tells the VM to use the application Console for out(), in() and err() instead of standard output, input and error (if they exist).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

STANDARD_INPUT

public static final int STANDARD_INPUT
Use with getStandardStream().

See Also:
Constant Field Values

STANDARD_OUTPUT

public static final int STANDARD_OUTPUT
Use with getStandardStream().

See Also:
Constant Field Values

STANDARD_ERROR

public static final int STANDARD_ERROR
Use with getStandardStream().

See Also:
Constant Field Values

SIP_ON

public static final int SIP_ON
See documentation of SetSIP()

See Also:
Constant Field Values

SIP_LEAVE_BUTTON

public static final int SIP_LEAVE_BUTTON
See documentation of SetSIP()

See Also:
Constant Field Values

SIP_LOCK

public static final int SIP_LOCK
See documentation of SetSIP()

See Also:
Constant Field Values

SIP_CURRENT

public static final int SIP_CURRENT
See Also:
Constant Field Values

SIP_FREEZE

public static final int SIP_FREEZE
See Also:
Constant Field Values

SIP_UNFREEZE

public static final int SIP_UNFREEZE
See Also:
Constant Field Values

SIP_IS_ON

public static final int SIP_IS_ON
See Also:
Constant Field Values

MB_OK

public static final int MB_OK
See Also:
Constant Field Values

MB_OKCANCEL

public static final int MB_OKCANCEL
See Also:
Constant Field Values

MB_ABORTRETRYIGNORE

public static final int MB_ABORTRETRYIGNORE
See Also:
Constant Field Values

MB_YESNOCANCEL

public static final int MB_YESNOCANCEL
See Also:
Constant Field Values

MB_YESNO

public static final int MB_YESNO
See Also:
Constant Field Values

MB_RETRYCANCEL

public static final int MB_RETRYCANCEL
See Also:
Constant Field Values

MB_ICONHAND

public static final int MB_ICONHAND
See Also:
Constant Field Values

MB_ICONQUESTION

public static final int MB_ICONQUESTION
See Also:
Constant Field Values

MB_ICONEXCLAMATION

public static final int MB_ICONEXCLAMATION
See Also:
Constant Field Values

MB_ICONASTERISK

public static final int MB_ICONASTERISK
See Also:
Constant Field Values

MB_ICONWARNING

public static final int MB_ICONWARNING
See Also:
Constant Field Values

MB_ICONERROR

public static final int MB_ICONERROR
See Also:
Constant Field Values

MB_ICONINFORMATION

public static final int MB_ICONINFORMATION
See Also:
Constant Field Values

MB_ICONSTOP

public static final int MB_ICONSTOP
See Also:
Constant Field Values

MB_DEFBUTTON1

public static final int MB_DEFBUTTON1
See Also:
Constant Field Values

MB_DEFBUTTON2

public static final int MB_DEFBUTTON2
See Also:
Constant Field Values

MB_DEFBUTTON3

public static final int MB_DEFBUTTON3
See Also:
Constant Field Values

MB_APPLMODAL

public static final int MB_APPLMODAL
See Also:
Constant Field Values

MB_SYSTEMMODAL

public static final int MB_SYSTEMMODAL
See Also:
Constant Field Values

MB_TASKMODAL

public static final int MB_TASKMODAL
See Also:
Constant Field Values

IDOK

public static final int IDOK
See Also:
Constant Field Values

IDCANCEL

public static final int IDCANCEL
See Also:
Constant Field Values

IDABORT

public static final int IDABORT
See Also:
Constant Field Values

IDRETRY

public static final int IDRETRY
See Also:
Constant Field Values

IDIGNORE

public static final int IDIGNORE
See Also:
Constant Field Values

IDYES

public static final int IDYES
See Also:
Constant Field Values

IDNO

public static final int IDNO
See Also:
Constant Field Values

TIMER_TICK

public static final int TIMER_TICK
Used with setParameter() it adjusts the minimum timer tick.

See Also:
Constant Field Values

SIMULATE_SIP

public static final int SIMULATE_SIP
Used with setParameter() it switches on (1) or off (0) SIP simulation for Java and ewe on the PC.

See Also:
Constant Field Values

SET_NO_WINDOWS

public static final int SET_NO_WINDOWS
Used with setParameter() and a value of 1, it switches on simulation of single windowing.

See Also:
Constant Field Values

SET_ALWAYS_SHOW_SIP_BUTTON

public static final int SET_ALWAYS_SHOW_SIP_BUTTON
Used with setParameter() and a value of 1, it tells the VM to always show the SIP button.

See Also:
Constant Field Values

MAX_TIMER_ENTRIES

public static final int MAX_TIMER_ENTRIES
Obsolete - Used with setParameter(), it sets the maximum number of combined timer/callback/coroutine entries the system can handle. Actually the VM now handles any number of these types of entries.

See Also:
Constant Field Values

dontGc

public static Vector dontGc
A Vector where you can placed objects that you don't want gc'd.

Method Detail

out

public static PrintWriter out()
Get a PrintWriter to standard output or to an application Console if standard output is not available (e.g. on WindowsCE).


in

public static BufferedReader in()
Get a BufferedReader to standard input or to an application Console if standard input is not available (e.g. on WindowsCE).


err

public static PrintWriter err()
Get a PrintWriter to standard error or to an application Console if standard error is not available (e.g. on WindowsCE).


useConsoleForIO

public static void useConsoleForIO()
This tells the VM to use the application Console for out(), in() and err() instead of standard output, input and error (if they exist).


copyArray

public static boolean copyArray(Object srcArray,
                                int srcStart,
                                Object dstArray,
                                int dstStart,
                                int length)
Copies the elements of one array to another array. This method returns true if the copy is successful. It will return false if the array types are not compatible or if either array is null. If the length parameter would cause the copy to read or write past the end of one of the arrays, an index out of range error will occur. If false is returned then no copying has been performed.

Parameters:
srcArray - the array to copy elements from
srcStart - the starting position in the source array
dstArray - the array to copy elements to
dstStart - the starting position in the destination array
length - the number of elements to copy

arraycopy

public static void arraycopy(Object srcArray,
                             int srcStart,
                             Object dstArray,
                             int dstStart,
                             int length)
This is exactly the same as copyArray() except that it is a void method and that it mirrors the standard System.arraycopy.


isColor

public static boolean isColor()
Returns true if the system supports a color display and false otherwise.


preloadVM

public static void preloadVM(boolean doLoad)
This tells the VM to pre-load the VM or to unload the VM.


getTimeStamp

public static int getTimeStamp()
Returns a time stamp in milliseconds. The time stamp is the time in milliseconds since some arbitrary starting time fixed when the VM starts executing. The maximum time stamp value is 0x3ffffffff and when it is reached, the timer will reset to 0 and will continue counting from there.


getTimeStampLong

public static long getTimeStampLong()
Returns a time stamp in milliseconds. The time stamp is the time in milliseconds since some arbitrary starting time fixed when the VM starts executing. The maximum time stamp value is (1 << 63) and when it is reached, the timer will reset to 0 and will continue counting from there.

Because of the arbitray nature of the initial value you should only use getTimeStampLong() for calculating differences between calls to getTimeStampLong()


getPlatform

public static String getPlatform()
Returns the platform the Virtual Machine is running under as a string. This will be one of:


getUserName

public static String getUserName()
Returns the username of the user running the Virutal Machine. Because of Java's security model, this method will return null when called in a Java applet. This method will also return null under most WinCE devices (that will be fixed in a future release).


getVersion

public static int getVersion()
Returns the version of the Ewe Virtual Machine. The major version is base 100. For example, version 1.0 has value 100. Version 2.0 has a version value of 200. A beta 0.8 VM will have version 80.


exec

public static int exec(String command,
                       String args,
                       int launchCode,
                       boolean wait)
Deprecated. - use exec(String [] command, String [] environment) instead

Executes a command.

As an example, the following call could be used to run the command "scandir /p mydir" under Java, Win32 or WinCE:

 int result = Vm.exec("scandir", "/p mydir", 0, true);
 
This example executes the Scribble program under PalmOS:
 Vm.exec("Scribble", null, 0, false);
 
The args parameter passed to this method is the arguments string to pass to the program being executed.

The launchCode parameter is only used under PalmOS. Under PalmOS, it is the launch code value to use when the Vm calls SysUIAppSwitch(). If 0 is passed, the default launch code (CmdNormalLaunch) is used to execute the program.

The wait parameter passed to this method determines whether to execute the command asynchronously. If false, then the method will return without waiting for the command to complete execution. If true, the method will wait for the program to finish executing and the return value of the method will be the value returned from the application under Java, Win32 and WinCE.

Parameters:
command - the command to execute
args - command arguments
launchCode - launch code for PalmOS applications
wait - whether to wait for the command to complete execution before returning

execute

public static boolean execute(String command,
                              String args)
Deprecated. - use exec(String [] command, String [] environment) instead

Execute a program.

Parameters:
command - The full path to the executable file. Don't put quotes within it.
args - Program arguments.
Returns:
True if the system reports that the program was executed. False otherwise.

splitCommand

public static String[] splitCommand(String args,
                                    String prepend)

exec

public static Process exec(String[] command,
                           String[] env)
                    throws IOException
Execute a new process.

Parameters:
command - The command and argument list. The first command must be the command to execute.
env - A new set of environment variables to use for the execution. Each must be in the form "name=value". this parameter can be null.
Returns:
a Process object which can be used for monitoring the status of the executing process.
Throws:
IOException - if an error occurs while attempting to execute the program.

exec

public static Process exec(String command,
                           String[] env)
                    throws IOException
Execute a new process.

Parameters:
command - The command and argument list as a single string. This will be split up using spaces as a separator and the resulting String array is then passed to exec(String [] command,String [] env). The first command must be the command to execute.
env - A new set of environment variables to use for the execution. Each must be in the form "name=value". this parameter can be null.
Returns:
a Process object which can be used for monitoring the status of the executing process.
Throws:
IOException - if an error occurs while attempting to execute the program.

exec

public static Process exec(String[] command)
                    throws IOException
Execute a new process.

Parameters:
command - The command and argument list. The first command must be the command to execute.
Returns:
a Process object which can be used for monitoring the status of the executing process.
Throws:
IOException - if an error occurs while attempting to execute the program.

exec

public static Process exec(String command)
                    throws IOException
Execute a new process.

Parameters:
command - The command and argument list as a single string. This will be split up using spaces as a separator and the resulting String array is then passed to exec(String [] command,String [] env). The first command must be the command to execute.
Returns:
a Process object which can be used for monitoring the status of the executing process.
Throws:
IOException - if an error occurs while attempting to execute the program.

execEwe

public static Process execEwe(String pathToEweFile,
                              String args)
                       throws IOException
Execute a ".ewe" file using the installed Ewe VM.

Parameters:
pathToEweFile -
args - Additional application arguments.
Returns:
A Process object for monitoring the progress of the application.
Throws:
IOException - If the Ewe VM could not be executed.

execEwe

public static Process execEwe(String[] arguments,
                              String[] env)
                       throws IOException
Execute the Ewe VM with the supplied parameters.

Parameters:
arguments - An argument list for the VM. The first command must be the command to execute.
env - A new set of environment variables to use for the execution. Each must be in the form "name=value". this parameter can be null.
Returns:
A Process object for monitoring the progress of the application.
Throws:
IOException - If the Ewe VM could not be executed.

getPathToEweVM

public static String getPathToEweVM()
Return the path to the registered Ewe VM executable file.

Returns:
The path to the Ewe VM executable file, or NULL if it is not found.

executeEwe

public static boolean executeEwe(String pathToEweFile,
                                 String args)
Deprecated. - use execEwe() instead.

Execute a Ewe file using a new Ewe VM.

Parameters:
pathToEweFile - The full path to the ".ewe" file.
args - Optional additional arguments for the application.
Returns:
true if the Ewe VM was executed.

runEweVM

public static boolean runEweVM(String args)
Deprecated. - use execEwe() instead.

This is used to run a new Ewe VM with the given argument list.

Parameters:
args - The full argument list for the VM.
Returns:
true if the Ewe VM was reported as being executed.

setDeviceAutoOff

public static int setDeviceAutoOff(int seconds)
Sets the device's "auto-off" time. This is the time in seconds where, if no user interaction occurs with the device, it turns off. To keep the device always on, pass 0. This method only works under PalmOS. The integer returned is the previous auto-off time in seconds.


sleep

public static void sleep(int millis)
Causes the VM to pause execution for the given number of milliseconds.

Parameters:
millis - time to sleep in milliseconds

setSIP

public static void setSIP(int mode,
                          Window forWindow)
This turns the SIP on PalmPC/PocketPC devices.

Parameters:
mode - a combination of the following bit flags.
SIP_ON = If this bit is set the SIP will be switched on and the SIP button will be made visible. If this bit is clear the SIP will be switched off (except in cases where SIP_LOCK is used).
SIP_LEAVE_BUTTON = If this bit is set when the SIP_ON bit is clear, the SIP will be switched off, but the SIP button will be left on. This only works for PocketPC.
SIP_LOCK = If this bit is set when SIP_ON is also set, the SIP will be switched on and will not be switched off unless this method is called with SIP_ON clear AND with SIP_LOCK on. This is used to keep the SIP visible even under circumstances where it is normally hidden (e.g. when switching from a text control to a non-text control). This can be used to avoid excessive SIP showing and hiding. SIP_FREEZE/UnFreeze = Valid only when executed in an Event thread. If this bit is set, then the SIP mode will be set either on or off depending on SIP_ON, and will not be able to be changed until the current Event thread exits. Do not use this with SIP_LOCK. In fact it is best to simply use freezeSIP().

setSIP

public static void setSIP(int mode)
This turns the SIP on PalmPC/PocketPC devices.

Parameters:
mode - a combination of the following bit flags.
SIP_ON = If this bit is set the SIP will be switched on and the SIP button will be made visible. If this bit is clear the SIP will be switched off (except in cases where SIP_LOCK is used).
SIP_LEAVE_BUTTON = If this bit is set when the SIP_ON bit is clear, the SIP will be switched off, but the SIP button will be left on. This only works for PocketPC.
SIP_LOCK = If this bit is set when SIP_ON is also set, the SIP will be switched on and will not be switched off unless this method is called with SIP_ON clear AND with SIP_LOCK on. This is used to keep the SIP visible even under circumstances where it is normally hidden (e.g. when switching from a text control to a non-text control). This can be used to avoid excessive SIP showing and hiding.
SIP_FREEZE = Valid only when executed in an Event thread. If this bit is set, then the SIP mode will be set either on or off depending on SIP_ON, and will not be able to be changed until the current Event thread exits. Do not use this with SIP_LOCK. In fact it is best to simply use freezeSIP().

freezeSIP

public static void freezeSIP(boolean freezeOrUnfreeze,
                             int sipOnOrOff,
                             Window window)
This temporarily holds the SIP in a particular mode (open or closed) until the current event thread has completed.

Parameters:
freezeOrUnfreeze - true to freeze the SIP either on (if sipOnOrOff is SIP_ON) or off (if sipOnOrOff is 0). Set to false to unfreeze the SIP. This is done automatically at the end of the current event thread.
sipOnOrOff - This is only valid if freezeOrUnfreeze is true, in which case it tells if the SIP should be open (SIP_ON) or closed (0).
window - The window of the control that is changing the SIP.

freezeSIP

public static void freezeSIP(Control forWho)
This will freeze the SIP in it's current state until the end of the processing of the current Event.


getSIP

public static int getSIP()
Get the state of the SIP.


playSound

public static int playSound(String sound,
                            int options)
Deprecated. use SoundClip instead.

Play a .wav file resource.

Parameters:
sound - The name of the .wav sound to play.
options - One of the SND_ variables.
Returns:

getAsyncKeyState

public static int getAsyncKeyState(int keyCode)
This is used to get the pressed state of a particular key at the time the method is called.

Parameters:
keyCode - One of the ewe.ui.IKeys constants.
Returns:
If the key is pressed the value will have bit 0x8000 set and if the key has been pressed since the last call the 0x0001 bit will be set.
See Also:
IKeys

captureAppKeys

public static int captureAppKeys(int options)
Deprecated. use ewe.ui.Window.captureAppKeys() instead.

This will capture the WindowCE special App keys (the non-cursor buttons generally found on the bottom). Calling this with options set to 1 will cause WinCE to not capture the App keys as ordinary keypresses, instead of special application launch buttons. These keypresses are then passed via a normal key event to your application with the APP0 to APP15 key codes. Calling this with options set to 0 will cause WinCE to no longer capture these keys and they will be re-associated with their application launch functionality.

Parameters:
options - A value of 1 causes WinCE to capture the keys. A value of 0 cause WinCE to release the keys.
Returns:
The same value as options.

messageBox

public static int messageBox(String caption,
                             String text,
                             int type)
This causes a "native" message box to be displayed - halting ewe programs until the user dismisses it. Useful for a variety of purposes including ensuring that a particular question or message is _definitely_ answered by the user - since it is not possible for a ewe application to programatically dismiss a native message box. This can therefore be used for security purposes in future versions. Use one of the vm.MB_ options for the type. It will return one of the vm.ID values


getParameter

public static int getParameter(int parameterID)
This gets paramter values. It only works currently for parameterID as VM_FLAGS.


isMobile

public static boolean isMobile()
Returns true if this VM is running on what is considered a Mobile platform. This is a convenienc method that uses the getParameter() method.


setParameter

public static int setParameter(int ParameterId,
                               int value)
This sets VM parameters.

Parameters:
ParameterId - Currently only the value VM_FLAGS is supported.
value - The new value to set.
Returns:

showWait

public static void showWait(Control c,
                            boolean show)

showWait

public static void showWait(boolean show)

setCursor

public static int setCursor(int type)
Set the cursor.


setCursor

public static int setCursor(Control c,
                            int type)

createCursor

public static int createCursor(Object cursor)
Use this to create a new Mouse cursor. The parameter you pass to it must have been created by ewe.fx.mImage.toCursor(Point hotSpot)
If it is successful an int value is returned which you can the use in ewe.ui.Control.setCursor(int cursor), otherwise it will return 0 which represents the default cursor.


getNewId

public static int getNewId()

requestTick

public static int requestTick(TimerProc target,
                              int interval,
                              boolean repeat)
Request a timer tick to be sent to the TimerProc target. It returns a unique timer id which will be sent to the target on each tick. If repeat is false only one tick will be sent.

Parameters:
target - The TimerProc object to receive the ticks.
interval - The time in milliseconds.
repeat - true if the timer should receive ticks at regular intervals until cancelTimer is called.
Returns:

requestTimer

public static int requestTimer(TimerProc target,
                               int interval)
Request a timer tick to be sent to the TimerProc target. It returns a unique timer id which will be sent to the target on each tick.


cancelTimer

public static void cancelTimer(int timerId)
This cancels timer ticks for the specified timerID.


changeTimer

public static int changeTimer(int timerId,
                              TimerProc target,
                              int newInterval)
This cancels the current timer and then requests a new one with a new interval. The returned value is the id of the new timer.


getMessage

public static int getMessage(SystemMessage dest,
                             boolean peek,
                             boolean remove)

callInSystemQueue

public static int callInSystemQueue(Window w,
                                    CallBack who,
                                    Object data)
This causes the callBack() method to be invoked on the CallBack object that will be in the OS's native message queue for a particular Window.

Parameters:
who - The CallBack object.
data - Optional data to send.
Returns:
not defined.

callInSystemQueue

public static int callInSystemQueue(CallBack who,
                                    Object data)
This causes the callBack() method to be invoked on the CallBack object that will be in the OS's native message queue.

Parameters:
who - The CallBack object.
data - Optional data to send.
Returns:
not defined.

amInSystemQueue

public static boolean amInSystemQueue()
This checks if the current thread is being run within the System Queue.

Returns:
true if the current thread is in the System Queue, false otherwise.

readResource

public static int readResource(String fileName,
                               String resourceName,
                               int options)
Deprecated.  

This reads a Win32 specific resource.

Parameters:
fileName -
resourceName -
options -
Returns:

releaseResource

public static int releaseResource(String resourceName)
Deprecated.  

This releases a resource read in by readResource.

Parameters:
resourceName -
Returns:

loadResourceOrFile

public static int loadResourceOrFile(String path,
                                     ByteArray dest)
Deprecated.  

This reads in a resource or a file with the specified path into the provided ByteArray. It returns: 0 = Could not load. 1 = Loaded from Resource. 2 = Loaded from File. < 0 = Error.

This method has been deprecated. Instead use openResource() or readResource().


gc

public static void gc()
Do a garbage collection.


loadLibrary

public static boolean loadLibrary(String name)
Deprecated. use loadDynamicLibrary() instead.

Load a Dynamic Link Library which may have the native code for a ewe object.

Parameters:
name - The name of the library - do NOT include ".dll" or ".so"
Returns:
true if the library was loaded, false if not.

loadDynamicLibrary

public static void loadDynamicLibrary(String name)
                               throws SecurityException,
                                      UnsatisfiedLinkError
Load a Dynamic Link Library which may have the native code for a ewe object.

Parameters:
name - The name of the library - do NOT include ".dll" or ".so"
Returns:
true if the library was loaded, false if not.
Throws:
SecurityException
UnsatisfiedLinkError

load

public static void load(String libraryName)
                 throws SecurityException,
                        UnsatisfiedLinkError
Throws:
SecurityException
UnsatisfiedLinkError

setFileObject

public static void setFileObject(File fileObject)
                          throws SecurityException
Set the File object to be used to represent the local file system.

Parameters:
fileObject - the File object to be used to represent the local file system.
Throws:
SecurityException - If the security system does not allow this. Currently this operation is not allowed to be done more than once.

newFileObject

public static File newFileObject()
Get a new ewe.io.File object which can be used to represent a file on the file system being used by the VM.

Returns:
A new ewe.io.File object.

nativeLoadLibrary

protected static boolean nativeLoadLibrary(String dllName)

getLocale

public static Locale getLocale()
Get a default locale object.


applicationError

public static void applicationError(String error)
Force a halt of the application due to a critical error.


getStringChars

public static char[] getStringChars(String str)
Using the native VM this will expose the char array which represents the String.

Use this with care! If you write into it using the native VM you will change the String which is SUPPOSED to be immutable. Under a JavaVM this will return a COPY of the string arrays.


createStringWithChars

public static String createStringWithChars(char[] chars)
Create a new String that uses the specified character array without creating a new character array for the String.

Use this with care. After creating the String you may be able to change it since you may have direct access to the String's characters. However under some systems (e.g. Java) this method may allocate a new copy of the array so do not assume that the provided character array will be used directly.


mutateString

public static String mutateString(String str,
                                  char[] newChars,
                                  int start,
                                  int length,
                                  boolean useThisArray)

debug

public static void debug(String message,
                         int options)
Print a message on the console. There are no options defined yet.


debugObject

public static void debugObject(Object data,
                               int options)

debug

public static int debug(Object in,
                        Object out,
                        int options)

debug

public static void debug(String message)
Print a message on the console with no option.


countObjects

public static int countObjects(boolean doGCFirst)
This returns a count of allocated objects. Set doGCFirst to true to do a garbage collection before counting. The absolute value returned by this will be of little use, but you can use it to ensure that your application is not constantly creating objects which never get gc'ed.


getReferencedObjects

public static Object[] getReferencedObjects()
Return an array that contains all reachable objects. A gc() is done before retrieving the objects. The returned array will not contain the array itself. Under Java this returns an empty array.

Returns:
an array of reachable objects.

getUsedMemory

public static int getUsedMemory(boolean doGCFirst)
This returns the amount of object memory used in bytes.

Parameters:
doGCFirst - Set this true if you want a gc() to be called first.
Returns:
The amount of used object memory. Under Java this will return -1.

getClassMemory

public static int getClassMemory()
This returns the amount of class memory used in bytes. Under Java this will return -1


memoryMapFile

public static RandomAccessStream memoryMapFile(String path,
                                               String mode,
                                               int options)
                                        throws UnsupportedOperationException,
                                               SystemResourceException,
                                               IOException,
                                               IllegalArgumentException
Memory map, if possible, a file on disk for later reading and possibly writing. The returned RandomAccessStream will always implement FastStream - so you can call seek(long position) followed by quickRead() (and quickWrite() if supported) to access the data from memory using the fastest access.

Parameters:
path - the path to the file.
mode - must be either "r" for read-only access and "rw" for read-write access.
options - any of the MEMORY_MAP_XXX values ORed together.
Returns:
a RandomAccessStream for reading from the memory mapped file.
Throws:
UnsupportedOperationException - if Memory Mapping is not supported or if the mode requested is not supported or if options requested could not be supported and MEMORY_MAP_STRICT was specified.
SystemResourceException - if there is not enough system resources to memory map.
FileNotFoundException - if the file was not found.
IOException - if there was an IO error mapping the file.
IllegalArgumentException - if the mode is not "r" or "rw".

openRandomAccessStream

public static RandomAccessStream openRandomAccessStream(String path,
                                                        String mode)
                                                 throws IOException,
                                                        IllegalArgumentException
This will attempt to provide a RandomAccessStream which can be used to read from a resource that is either stored in a ewe file, or resides on a sever (for Applet versions) or is a File. If the resource is in a ewe file or is on a server, then you will only be able to read from the stream.

Parameters:
path - The path to the resource or file.
mode - Either "r" or "rw".
Returns:
A RandomAccessStream which can be used to access the resource.
Throws:
IOException - if an error occured accessing the resource.
IllegalArgumentException - if the mode is not "r" or "rw".

openRandomAccessStream

public static RandomAccessStream openRandomAccessStream(String path,
                                                        int mode)
Deprecated. user the other openRandomAccessStream() instead.

This will attempt to provide a RandomAccessStream which can be used to read from a resource that is either stored in a ewe file, or resides on a sever (for Applet versions) or is a File. If the resource is in a ewe file or is on a server, then you will only be able to read from the stream.

Parameters:
path - The path to the resource or file.
mode - One of the RandomAccessStream constants: READ_ONLY or READ_WRITE
Returns:
A RandomAccessStream if successful.

openResource

public static Stream openResource(Class aClass,
                                  String resourceName)
This will attempt to open a class dependant resource for reading. If the provided class is null or was loaded by the system loader or was loaded by a ClassLoader which is not an instance of ewe.util.mClassLoader, then this will call openRandomAccessStream(). Otherwise the openResource() method in the mClassLoader is called.

Parameters:
aClass - The class requesting the resource. If it is null it will assume that it is a standard application resource.
resourceName - The name of the resource.
Returns:
A Stream that can be used to read the resource. The returned Stream may not be a RandomAccessStream, depending on the resource itself.

readResource

public static byte[] readResource(Class aClass,
                                  String resourceName)
This opens a Stream to a resource using openResource and then reads in all the bytes. It will return null if the resource could not be found or read.

Parameters:
aClass - The class requesting the resource. If it is null it will assume that it is a standard application resource.
resourceName - The name of the resource.
Returns:
the bytes of the resource.

setClipboardText

public static void setClipboardText(String text)
Sets the system clipboard text.

Parameters:
text - New text to place in clipboard.

getClipboardText

public static String getClipboardText(String defaultText)
Get the text in the system clipboard.

Parameters:
defaultText - Text to return if there is no text in the system clipboard.
Returns:
The text in the system clipboard, or defaultText if there is no text in the system clipboard.

getProgramArguments

public static String[] getProgramArguments()
Get the program arguments.

Returns:
The program arguments

toInt

public static int toInt(Object obj)
Deprecated. See identityHashCode()

This returns the hashcode for the object as if the Object.hashCode() method was called regardless of any overriding hashCode() methods.

Parameters:
obj - The object.
Returns:
The identity hashcode for the object.

identityHashCode

public static int identityHashCode(Object obj)
This returns the hashcode for the object as if the Object.hashCode() method was called regardless of any overriding hashCode() methods.

Parameters:
obj - The object.
Returns:
The identity hashcode for the object.

getAppletProperties

public static PropertyList getAppletProperties()
This returns properties for the current Applet if it is being run as an Applet. If it is being run as an application this will return null.

The available properties will be:
applet - The Applet object itself.
hostName - A string representing the host computer name.
hostPort - A string representing the host computer port.
codeBase - A string giving the codebase of the applet.
documentBase - A string giving the documentbase of the applet.


getAStackTrace

public static String getAStackTrace(Throwable th)
This gets a String representation of the full stack trace for a Throwable, but not for any of its possible chained exceptions.

Parameters:
th - The Throwable
Returns:
a String representation of the full stack trace for the Throwable.

getStackTrace

public static String getStackTrace(Throwable th)
Get a String representation of the stack trace for a Throwable object. This trace will display partial traces of all chained exception as well. To get the full trace for any particular Throwable you should call getAStackTrace().

Parameters:
th - The throwable object.
Returns:
A String representation of the stack trace.

printStackTrace

public static void printStackTrace(Throwable th,
                                   PrintWriter out)

getFullStackTrace

public static String getFullStackTrace(Throwable th)
This gets the fully expanded stack trace for the Throwable and all chained throwables.

Parameters:
th - The throwable.
Returns:
the fully expanded stack trace for the Throwable and all chained throwables.

setCause

public static Throwable setCause(Throwable target,
                                 Throwable cause)
                          throws IllegalArgumentException,
                                 IllegalStateException
This provides a fully portable method of setting the "cause" of a Throwable for exception chaining. Under Java this will only have an effect on Java 1.4 or higher. Under earlier versions of Java this call will not do anything.

Parameters:
target - The target Throwable.
cause - The cause for the target.
Returns:
The target Throwable.
Throws:
IllegalArgumentException - If the cause is the same as the target.
IllegalStateException - If the cause for the target has already been set.

getCause

public static Throwable getCause(Throwable target)
This provides a fully portable method of getting the "cause" of a Throwable for exception chaining. Under Java this will only have an effect on Java 1.4 or higher. Under earlier versions of Java this call will always return null.

Parameters:
target - The target Throwable.
Returns:
The cause for the Throwable.

getStackTrace

public static String getStackTrace(Throwable t,
                                   int lines)
Get a String representation of the stack trace for a Throwable object.

Parameters:
t - The throwable object.
lines - The number of lines to retrieve. If lines <= 0 then all lines will be retrieved
Returns:
A String representation of the stack trace.

getSyncObject

public static Object getSyncObject()
This returns an object that you can synchronize with in an object "finalize()" method. This is the only use for this object - it ensures that your application remains single threaded when running under Java. This is because the "finalize()" method can be called at any point, which may not be synchronized with the ewe application. Under a native Ewe VM "finalize()" will always be called in sync with your application so the object returned is not actually used (the synchronized() keyword is ignored in a Ewe VM).


getProperty

public static String getProperty(String propertyName,
                                 String defaultValue)
This works similar to the true java.lang.System.getProperty().


setProperty

public static boolean setProperty(String propertyName,
                                  String value)
This only has an effect on the running program. It will override system values for this VM instance but will not affect other VMs or any OS values.


exit

public static void exit(int retCode)
Exit the application.

Parameters:
retCode - The return code.

startEwe

public static void startEwe(String[] programArguments,
                            String startClassName)
This is used to start the Ewe library running from a static main() method. Always have it as the first line of code in your main method. You should pass the name of the class to begin running AND the program arguments as supplied to the main() method.


startEwe

public static void startEwe(String[] programArguments)
This is used to start the Ewe library running from a static main() method. Always have it as the first line of code in your main method. This calls startEwe(programArguments,startClassName) with a startClassName of null. This tells the system to use the stack trace to figure out which class called the method.


getStandardStream

public static Stream getStandardStream(int which)
Return a Stream to the standard Input, Output or Error streams.

Parameters:
which - one of STANDARD_INPUT, STANDARD_OUTPUT or STANDARD_ERROR
Returns:
an open Stream OR null if the stream is not available

getSystemMemoryStatus

public static MemoryStatus getSystemMemoryStatus()
Get a MemoryStatus object representing the state of the system's physical memory.

Returns:
A MemoryStatus object if available on the system, or null if not.

makeBlockingTask

public static Task makeBlockingTask(CallBack cb)
Create a Task that can call a full system blocking method without blocking the VM. Under a native Ewe VM this is not possible and this will still block the VM, but under a Java VM the Ewe VM will not be blocked.

The task should be implemented in a CallBack Object, where the callBack(Object data) method will hold the blocking code and the "data" parameter will be a Handle that the task can use to set the status of the task.


runNativeDialog

public static Handle runNativeDialog(Task nativeDialogTask)
Run a task that will display a native dialog box of some kind while it runs. The method returns immediately, returning the Handle of the nativeDialogTask.