PulpCore

pulpcore
Class CoreSystem

java.lang.Object
  extended by pulpcore.CoreSystem

public class CoreSystem
extends Object

The CoreSystem class contains useful platform-specific methods. The class cannot be instantiated.


Method Summary
static boolean[] arraycopy(boolean[] src)
          Returns a copy of the specified array, or null if the array is null.
static byte[] arraycopy(byte[] src)
          Returns a copy of the specified array, or null if the array is null.
static char[] arraycopy(char[] src)
          Returns a copy of the specified array, or null if the array is null.
static double[] arraycopy(double[] src)
          Returns a copy of the specified array, or null if the array is null.
static float[] arraycopy(float[] src)
          Returns a copy of the specified array, or null if the array is null.
static int[] arraycopy(int[] src)
          Returns a copy of the specified array, or null if the array is null.
static long[] arraycopy(long[] src)
          Returns a copy of the specified array, or null if the array is null.
static Object[] arraycopy(Object[] src)
          Returns a copy of the specified array, or null if the array is null.
static short[] arraycopy(short[] src)
          Returns a copy of the specified array, or null if the array is null.
static void clearLog()
           
static void clearTalkBackFields()
           
static String getAppProperty(String name)
          Gets a named property for this application instance.
static URL getBaseURL()
           
static String getBrowserName()
          Returns the name of the web browser, or null if the browser name could not be determined.
static String getBrowserVersion()
          Returns the version of the web browser, or null if the browser version could not be determined.
static String getClipboardText()
          Returns the text currently in the clipboard.
static int getDefaultBackgroundColor()
          Gets the default background color.
static int getDefaultForegroundColor()
          Gets the default foreground color.
static String getJavaProperty(String name)
          Gets a Java system property.
static String getLocaleCountry()
           
static String getLocaleLanguage()
           
static String getLogText()
           
static int getMaxSimultaneousSounds()
          Gets the maximum number of sounds that can be played simultaneously.
static int getNumSoundsPlaying()
          Gets the number of sounds currently playing in the sound engine.
static pulpcore.platform.Platform getPlatform()
          Used internally by PulpCore - most apps will not need to access the Platform instance.
static double getSoundVolume()
          Gets the master sound volume mute setting for this application.
static String getTalkBackField(String name)
          Gets a named TalkBack field.
static pulpcore.platform.AppContext getThisAppContext()
          Used internally by PulpCore - most apps will not need to access the AppContext instance.
static long getTimeMicros()
          Returns the current value of the system timer in microseconds.
static long getTimeMillis()
          Returns the current value of the system timer in milliseconds.
static byte[] getUserData(String key)
          Attempts to get persistant user data from the local machine.
static void init(pulpcore.platform.Platform platform)
           
static boolean isBrowserHosted()
          Returns true if this platform is hosted in a browser (Applets).
static boolean isConsoleOutputEnabled()
           
static boolean isJava13orNewer()
          Returns true if Java 1.3 or newer is in use.
static boolean isJava14orNewer()
          Returns true if Java 1.4 or newer is in use.
static boolean isJava15orNewer()
          Returns true if Java 1.5 or newer is in use.
static boolean isJava16orNewer()
          Returns true if Java 1.6 or newer is in use.
static boolean isJava16u10orNewer()
          Returns true if Java 1.6 update 10 or newer is in use.
static boolean isJava17orNewer()
          Returns true if Java 1.7 or newer is in use.
static boolean isMacOSX()
          Returns true if the current operating system is any version of Mac OS X.
static boolean isMacOSXLeopardOrNewer()
          Returns true if the current operating system is Mac OS X Leopard (10.5) or newer.
static boolean isMute()
          Gets the audio mute setting for this application.
static boolean isNativeClipboard()
          Checks if the platform has access to the native operating system clipboard.
static boolean isSoundEngineAvailable()
          Returns true if the user's system can play sound.
static boolean isValidHost(String[] validHosts)
          Determines if this app is running from one of the specified hosts.
static boolean isWindows()
          Returns true if the current operating system is any version of Windows.
static boolean isWindowsXPorNewer()
          Returns true if the current operating system is Windows XP (5.1) or newer.
static void print(boolean b)
          Prints the string representation of a boolean to the log.
static void print(double n)
          Prints the string representation of a double to the log.
static void print(float n)
          Prints the string representation of a float to the log.
static void print(int n)
          Prints the string representation of an integer to the log.
static void print(Object object)
          Prints a the string representation of an object to the log.
static void print(String statement)
          Prints a line of text to the log.
static void print(String statement, Throwable t)
          Prints a line of text and a Throwable's stack trace to the log.
static void printMemory(String statement)
          Prints the amount of current memory usage and the change in memory usage since the last call to this method.
static void putUserData(String key, byte[] data)
          Attempts to store persistant user data to the local machine.
static void removeUserData(String key)
          Attempts to remove persistant user data from the local machine.
static void setClipboardText(String text)
          Sets the text in the clipboard.
static void setConsoleOutputEnabled(boolean consoleOut)
           
static void setMute(boolean mute)
          Sets the audio mute setting for this application.
static void setSoundVolume(double volume)
          Sets the master sound volume mute setting for this application.
static void setTalkBackField(String name, String value)
          Sets a new TalkBack field.
static void setTalkBackField(String name, Throwable t)
           
static void showDocument(String url)
           
static void showDocument(String url, String target)
           
static Upload uploadTalkBackFields(String talkbackPath)
          Uploads talkback data to an external URL using the POST (multipart form) method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public static void init(pulpcore.platform.Platform platform)

getJavaProperty

public static String getJavaProperty(String name)
Gets a Java system property. Returns null if the property does not exist or there is a security excepion.


getPlatform

public static pulpcore.platform.Platform getPlatform()
Used internally by PulpCore - most apps will not need to access the Platform instance.


getThisAppContext

public static pulpcore.platform.AppContext getThisAppContext()
Used internally by PulpCore - most apps will not need to access the AppContext instance.


isJava13orNewer

public static final boolean isJava13orNewer()
Returns true if Java 1.3 or newer is in use.


isJava14orNewer

public static final boolean isJava14orNewer()
Returns true if Java 1.4 or newer is in use.


isJava15orNewer

public static final boolean isJava15orNewer()
Returns true if Java 1.5 or newer is in use.


isJava16orNewer

public static final boolean isJava16orNewer()
Returns true if Java 1.6 or newer is in use.


isJava16u10orNewer

public static final boolean isJava16u10orNewer()
Returns true if Java 1.6 update 10 or newer is in use.


isJava17orNewer

public static final boolean isJava17orNewer()
Returns true if Java 1.7 or newer is in use.


isMacOSX

public static final boolean isMacOSX()
Returns true if the current operating system is any version of Mac OS X.


isMacOSXLeopardOrNewer

public static final boolean isMacOSXLeopardOrNewer()
Returns true if the current operating system is Mac OS X Leopard (10.5) or newer.


isWindows

public static final boolean isWindows()
Returns true if the current operating system is any version of Windows.


isWindowsXPorNewer

public static final boolean isWindowsXPorNewer()
Returns true if the current operating system is Windows XP (5.1) or newer.


arraycopy

public static boolean[] arraycopy(boolean[] src)
Returns a copy of the specified array, or null if the array is null.


arraycopy

public static byte[] arraycopy(byte[] src)
Returns a copy of the specified array, or null if the array is null.


arraycopy

public static short[] arraycopy(short[] src)
Returns a copy of the specified array, or null if the array is null.


arraycopy

public static char[] arraycopy(char[] src)
Returns a copy of the specified array, or null if the array is null.


arraycopy

public static int[] arraycopy(int[] src)
Returns a copy of the specified array, or null if the array is null.


arraycopy

public static long[] arraycopy(long[] src)
Returns a copy of the specified array, or null if the array is null.


arraycopy

public static float[] arraycopy(float[] src)
Returns a copy of the specified array, or null if the array is null.


arraycopy

public static double[] arraycopy(double[] src)
Returns a copy of the specified array, or null if the array is null.


arraycopy

public static Object[] arraycopy(Object[] src)
Returns a copy of the specified array, or null if the array is null.


getDefaultBackgroundColor

public static int getDefaultBackgroundColor()
Gets the default background color.


getDefaultForegroundColor

public static int getDefaultForegroundColor()
Gets the default foreground color.


getAppProperty

public static String getAppProperty(String name)
Gets a named property for this application instance. Returns null if the named parameter does not exist.

For Applets, the named properties are the applet parameters.


getTalkBackField

public static String getTalkBackField(String name)
Gets a named TalkBack field.


setTalkBackField

public static void setTalkBackField(String name,
                                    String value)
Sets a new TalkBack field. If the named field already exists, it is replaced.


setTalkBackField

public static void setTalkBackField(String name,
                                    Throwable t)

clearTalkBackFields

public static void clearTalkBackFields()

uploadTalkBackFields

public static Upload uploadTalkBackFields(String talkbackPath)
Uploads talkback data to an external URL using the POST (multipart form) method.

The upload starts immediately. Use Upload.isCompleted() to check if the upload is finished.

Parameters:
talkbackPath - the path on the applet's server.
Returns:
null if talkbackPath is an invalid URL.

isValidHost

public static boolean isValidHost(String[] validHosts)
Determines if this app is running from one of the specified hosts.


setConsoleOutputEnabled

public static void setConsoleOutputEnabled(boolean consoleOut)

isConsoleOutputEnabled

public static boolean isConsoleOutputEnabled()

getLogText

public static String getLogText()

clearLog

public static void clearLog()

print

public static void print(Object object)
Prints a the string representation of an object to the log.


print

public static void print(boolean b)
Prints the string representation of a boolean to the log.


print

public static void print(int n)
Prints the string representation of an integer to the log.


print

public static void print(float n)
Prints the string representation of a float to the log.


print

public static void print(double n)
Prints the string representation of a double to the log.


print

public static void print(String statement)
Prints a line of text to the log.


print

public static void print(String statement,
                         Throwable t)
Prints a line of text and a Throwable's stack trace to the log.


printMemory

public static void printMemory(String statement)
Prints the amount of current memory usage and the change in memory usage since the last call to this method. System.gc() is called before querying the amount of free memory.


putUserData

public static void putUserData(String key,
                               byte[] data)
Attempts to store persistant user data to the local machine.

For applets, each key is stored in a Base64-encoded cookie. The user's web browser must have LiveConnect, JavaScript, and cookies enabled. Web browsers may have the following limitations for cookies (according to RFC 2109 section 6.3):

Additionally, Internet Explorer allows only 4,096 bytes per domain.

Cookies may "expire" (become unaccessable) after an amount of time or may be deleted at any time by the browser.

Base64 encoding increases the data size by 33%. In summary, for Applets, try to use as few keys as possible, and keep the data length to a minimum.

Example: CoreSystem.putUserData("MyGame", data);

See Also:
getUserData(String), removeUserData(String)

getUserData

public static byte[] getUserData(String key)
Attempts to get persistant user data from the local machine.

See Also:
putUserData(String, byte[]), removeUserData(String)

removeUserData

public static void removeUserData(String key)
Attempts to remove persistant user data from the local machine.

See Also:
putUserData(String, byte[]), getUserData(String)

getBaseURL

public static URL getBaseURL()

getLocaleLanguage

public static String getLocaleLanguage()

getLocaleCountry

public static String getLocaleCountry()

showDocument

public static void showDocument(String url)

showDocument

public static void showDocument(String url,
                                String target)

getTimeMillis

public static long getTimeMillis()
Returns the current value of the system timer in milliseconds.


getTimeMicros

public static long getTimeMicros()
Returns the current value of the system timer in microseconds.


isNativeClipboard

public static boolean isNativeClipboard()
Checks if the platform has access to the native operating system clipboard. If not, an internal clipboard is used.


getClipboardText

public static String getClipboardText()
Returns the text currently in the clipboard. Returns an empty string if there is no text in the clipboard. If the native clipboard is not accessible (typical in Applet environments), an application clipboard is used.


setClipboardText

public static void setClipboardText(String text)
Sets the text in the clipboard. If the native clipboard is not accessible (typical in Applet environments), an application clipboard is used.


isBrowserHosted

public static boolean isBrowserHosted()
Returns true if this platform is hosted in a browser (Applets).


getBrowserName

public static String getBrowserName()
Returns the name of the web browser, or null if the browser name could not be determined.


getBrowserVersion

public static String getBrowserVersion()
Returns the version of the web browser, or null if the browser version could not be determined.


isMute

public static boolean isMute()
Gets the audio mute setting for this application.

Returns:
true if the application is muted (silent), false otherwise

setMute

public static void setMute(boolean mute)
Sets the audio mute setting for this application. This setting takes effect immediately for all calls to Sound.play().

Due to buffering, if any sounds are playing when this setting is changed, there may be a slight delay before the new setting takes affect on those playing sounds.

Parameters:
mute - true to mute the application, false otherwise

getSoundVolume

public static double getSoundVolume()
Gets the master sound volume mute setting for this application.

Returns:
the master sound volume, from 0 (silent) to 1 (full).

setSoundVolume

public static void setSoundVolume(double volume)
Sets the master sound volume mute setting for this application. This setting takes effect immediately for all calls to Sound.play().

Due to buffering, if any sounds are playing when this setting is changed, there may be a slight delay before the new setting takes affect on those playing sounds.

Parameters:
volume - the master sound volume, from 0 (silent) to 1 (full).

isSoundEngineAvailable

public static boolean isSoundEngineAvailable()
Returns true if the user's system can play sound.

As of PulpCore 0.11.4, the sound engine is loaded asynchronously. While the engine is loading, this method returns true, but may later return false if the initialization fails.


getNumSoundsPlaying

public static int getNumSoundsPlaying()
Gets the number of sounds currently playing in the sound engine.


getMaxSimultaneousSounds

public static int getMaxSimultaneousSounds()
Gets the maximum number of sounds that can be played simultaneously.


PulpCore

Copyright © 2007-2009 Interactive Pulp, LLC.