org.rosuda.util
Class Platform

java.lang.Object
  extended by org.rosuda.util.Platform
Direct Known Subclasses:
Platform, Platform, PlatformMac, PlatformWin

public class Platform
extends java.lang.Object

Generic platform class. It provides interface to platform-dependent functionality.


Field Summary
static boolean isMac
           
static boolean isWin
           
static java.awt.Dimension screenRes
           
 
Constructor Summary
Platform()
          the constructor should never be called directly.
 
Method Summary
 java.lang.String forceResourceFile(java.lang.String rname)
          if getResourceFile returns null then this methods should create a temporary file for the resource and return the file name.
static Platform getPlatform()
           
 java.lang.String getResourceFile(java.lang.String rname)
          if possible this returns full path to the specified resource file. if the platform doesn't store bundles in files, the platform should return null
 java.io.InputStream getResourceInput(java.lang.String rname)
          every platform should provide at least this method for each resource.
 void handleAbout()
           
 void handleOpenFile(java.io.File fileName)
           
 void handlePrefs()
           
 void handleQuit()
           
static Platform initPlatform()
          initialize platforms with the default implementation (in org.rosuda.util)
static Platform initPlatform(java.lang.String classPrefix)
          initialize platforms using the specified class prefix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isMac

public static boolean isMac

isWin

public static boolean isWin

screenRes

public static java.awt.Dimension screenRes
Constructor Detail

Platform

public Platform()
the constructor should never be called directly. Platform classes are created by the initPlatform() methods.

Method Detail

getPlatform

public static Platform getPlatform()

initPlatform

public static Platform initPlatform()
initialize platforms with the default implementation (in org.rosuda.util)

Returns:
newly initailized platform object

initPlatform

public static Platform initPlatform(java.lang.String classPrefix)
initialize platforms using the specified class prefix. If the desired class is not found using the class prefix, fall-back to org.rosuda.util classes is attempted.

Parameters:
classPrefix - prefix (including the trailing dot) for the platform classes
Returns:
newly initailized platform object

getResourceInput

public java.io.InputStream getResourceInput(java.lang.String rname)
every platform should provide at least this method for each resource.


getResourceFile

public java.lang.String getResourceFile(java.lang.String rname)
if possible this returns full path to the specified resource file. if the platform doesn't store bundles in files, the platform should return null


forceResourceFile

public java.lang.String forceResourceFile(java.lang.String rname)
if getResourceFile returns null then this methods should create a temporary file for the resource and return the file name. It should return null only if it finds no means of creating such temporary file. The current implementation first check getResourceFile, if it fails but getResourceInput is successfull, then for JDK 1.2 and above it creates a temp file using createTempFile method and copies the contents from the InputStream. If this fails (creation of tmep file - this will fail for JDK 1.1 and below) then it tries to create a file "javaRes.tmp" in the current directory. Beware: the returned filename is valid only until the next call to this method. In fact on JDK 1.2 every call creates an unique file (flagged as delete-on-exit), but on JDK 1.1 and in other cases when this procedure fails the same file is used (and is not deleted upon exit!)


handleAbout

public void handleAbout()

handleOpenFile

public void handleOpenFile(java.io.File fileName)

handlePrefs

public void handlePrefs()

handleQuit

public void handleQuit()