Top Description Inners Fields Constructors Methods
org.lwjgl

public Class LWJGLUtil

extends Object
Class Inheritance
Imports
java.io.File, java.lang.reflect.Field, .Method, .Modifier, java.nio.ByteBuffer, java.security.AccessController, .PrivilegedAction, .PrivilegedActionException, .PrivilegedExceptionAction, java.util.*

Internal library methods

Author
Brian Matzon
Version
$Revision$ $Id$

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
LWJGLUtil.TokenFilter

Simple interface for Field filtering.

Field Summary

Modifier and TypeField and Description
public static final boolean
public static final boolean
DEBUG

Debug flag.

private static final String
private static final String
public static final ByteBuffer
LWJGLIcon16x16

LWJGL Logo - 16 by 16 pixels

public static final ByteBuffer
LWJGLIcon32x32

LWJGL Logo - 32 by 32 pixels

private static final int
public static final int
public static final String
public static final int
public static final String
public static final int
public static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
execPrivileged(final String[] cmd_array)

public static Map<Integer, String>

Returns:

the token map
getClassTokens
(final LWJGLUtil.TokenFilter
the filter to use (optional)
filter
,
final Map<Integer, String>
the target map (optional)
target
,
final Class<T>...
an array of classes to get tokens from
tokenClasses
)

Returns a map of public static final integer fields in the specified classes, to their String representations.

public static Map<Integer, String>

Returns:

the token map
getClassTokens
(final LWJGLUtil.TokenFilter
the filter to use (optional)
filter
,
Map<Integer, String>
the target map (optional)
target
,
final Iterable<Class<T>>
the classes to get tokens from
tokenClasses
)

Returns a map of public static final integer fields in the specified classes, to their String representations.

public static String[]

Returns:

Paths to located libraries, if any
getLibraryPaths
(String
Local Library Name to search the classloader with ("openal").
libname
,
String
The native library name ("libopenal.so")
platform_lib_name
,
ClassLoader
The classloader to ask for library paths
classloader
)

Locates the paths required by a library.

public static String[]

Returns:

Paths to located libraries, if any
getLibraryPaths
(String
Local Library Name to search the classloader with ("openal").
libname
,
String[]
The list of possible library names ("libopenal.so")
platform_lib_names
,
ClassLoader
The classloader to ask for library paths
classloader
)

Locates the paths required by a library.

private static String

Returns:

Absolute path to library if found, otherwise null
getPathFromClassLoader
(final String
Name of library to search for
libname
,
final ClassLoader
Classloader to use
classloader
)

Tries to locate named library from the current ClassLoader This method exists because native libraries are loaded from native code, and as such is exempt from ClassLoader library loading rutines.

public static int

Returns:

the current platform type
getPlatform
()

public static String

Returns:

current platform name
getPlatformName
()

public static boolean
getPrivilegedBoolean(final String property_name)

Gets a boolean property as a privileged action.

public static Integer

Returns:

the property value
getPrivilegedInteger
(final String
the integer property name
property_name
)

Gets an integer property as a privileged action.

public static Integer

Returns:

the property value
getPrivilegedInteger
(final String
the integer property name
property_name
,
final int
the default value to use if the property is not defined
default_val
)

Gets an integer property as a privileged action.

private static String
getPrivilegedProperty(final String property_name)

public static boolean
isMacOSXEqualsOrBetterThan(int major_required, int minor_required)

Method to determine if the current system is running a version of Mac OS X better than the given version.

private static ByteBuffer
public static void
log(CharSequence
Message to print
msg
)

Prints the given message to System.err if DEBUG is true.

public static String

Returns:

a platform-dependent native library name.
mapLibraryName
(String
the name of the library.
name
)

Wraps System#mapLibraryName.

public static String

Returns:

the hex string representation
toHexString
(final int
the integer value
value
)

Returns a string representation of the integer argument as an unsigned integer in base 16.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CHECKSback to summary
public static final boolean CHECKS
DEBUGback to summary
public static final boolean DEBUG

Debug flag.

LWJGL_ICON_DATA_16x16back to summary
private static final String LWJGL_ICON_DATA_16x16
LWJGL_ICON_DATA_32x32back to summary
private static final String LWJGL_ICON_DATA_32x32
LWJGLIcon16x16back to summary
public static final ByteBuffer LWJGLIcon16x16

LWJGL Logo - 16 by 16 pixels

LWJGLIcon32x32back to summary
public static final ByteBuffer LWJGLIcon32x32

LWJGL Logo - 32 by 32 pixels

PLATFORMback to summary
private static final int PLATFORM
PLATFORM_LINUXback to summary
public static final int PLATFORM_LINUX
PLATFORM_LINUX_NAMEback to summary
public static final String PLATFORM_LINUX_NAME
PLATFORM_MACOSXback to summary
public static final int PLATFORM_MACOSX
PLATFORM_MACOSX_NAMEback to summary
public static final String PLATFORM_MACOSX_NAME
PLATFORM_WINDOWSback to summary
public static final int PLATFORM_WINDOWS
PLATFORM_WINDOWS_NAMEback to summary
public static final String PLATFORM_WINDOWS_NAME

Constructor Detail

LWJGLUtilback to summary
public LWJGLUtil()

Method Detail

execPrivilegedback to summary
pack-priv static void execPrivileged(final String[] cmd_array) throws Exception
getClassTokensback to summary
public static Map<Integer, String> getClassTokens(final LWJGLUtil.TokenFilter filter, final Map<Integer, String> target, final Class<T>... tokenClasses)

Returns a map of public static final integer fields in the specified classes, to their String representations. An optional filter can be specified to only include specific fields. The target map may be null, in which case a new map is allocated and returned.

This method is useful when debugging to quickly identify values returned from the AL/GL/CL APIs.

Parameters
filter:LWJGLUtil.TokenFilter

the filter to use (optional)

target:Map<Integer, String>

the target map (optional)

tokenClasses:Class<T>[]

an array of classes to get tokens from

Returns:Map<Integer, String>

the token map

getClassTokensback to summary
public static Map<Integer, String> getClassTokens(final LWJGLUtil.TokenFilter filter, Map<Integer, String> target, final Iterable<Class<T>> tokenClasses)

Returns a map of public static final integer fields in the specified classes, to their String representations. An optional filter can be specified to only include specific fields. The target map may be null, in which case a new map is allocated and returned.

This method is useful when debugging to quickly identify values returned from the AL/GL/CL APIs.

Parameters
filter:LWJGLUtil.TokenFilter

the filter to use (optional)

target:Map<Integer, String>

the target map (optional)

tokenClasses:Iterable<Class<T>>

the classes to get tokens from

Returns:Map<Integer, String>

the token map

getLibraryPathsback to summary
public static String[] getLibraryPaths(String libname, String platform_lib_name, ClassLoader classloader)

Locates the paths required by a library.

Parameters
libname:String

Local Library Name to search the classloader with ("openal").

platform_lib_name:String

The native library name ("libopenal.so")

classloader:ClassLoader

The classloader to ask for library paths

Returns:String[]

Paths to located libraries, if any

getLibraryPathsback to summary
public static String[] getLibraryPaths(String libname, String[] platform_lib_names, ClassLoader classloader)

Locates the paths required by a library.

Parameters
libname:String

Local Library Name to search the classloader with ("openal").

platform_lib_names:String[]

The list of possible library names ("libopenal.so")

classloader:ClassLoader

The classloader to ask for library paths

Returns:String[]

Paths to located libraries, if any

getPathFromClassLoaderback to summary
private static String getPathFromClassLoader(final String libname, final ClassLoader classloader)

Tries to locate named library from the current ClassLoader This method exists because native libraries are loaded from native code, and as such is exempt from ClassLoader library loading rutines. It therefore always fails. We therefore invoke the protected method of the ClassLoader to see if it can locate it.

Parameters
libname:String

Name of library to search for

classloader:ClassLoader

Classloader to use

Returns:String

Absolute path to library if found, otherwise null

getPlatformback to summary
public static int getPlatform()
Returns:int

the current platform type

See Also
PLATFORM_WINDOWS, PLATFORM_LINUX, PLATFORM_MACOSX
getPlatformNameback to summary
public static String getPlatformName()
Returns:String

current platform name

See Also
PLATFORM_WINDOWS_NAME, PLATFORM_LINUX_NAME, PLATFORM_MACOSX_NAME
getPrivilegedBooleanback to summary
public static boolean getPrivilegedBoolean(final String property_name)

Gets a boolean property as a privileged action.

getPrivilegedIntegerback to summary
public static Integer getPrivilegedInteger(final String property_name)

Gets an integer property as a privileged action.

Parameters
property_name:String

the integer property name

Returns:Integer

the property value

getPrivilegedIntegerback to summary
public static Integer getPrivilegedInteger(final String property_name, final int default_val)

Gets an integer property as a privileged action.

Parameters
property_name:String

the integer property name

default_val:int

the default value to use if the property is not defined

Returns:Integer

the property value

getPrivilegedPropertyback to summary
private static String getPrivilegedProperty(final String property_name)
isMacOSXEqualsOrBetterThanback to summary
public static boolean isMacOSXEqualsOrBetterThan(int major_required, int minor_required)

Method to determine if the current system is running a version of Mac OS X better than the given version. This is only useful for Mac OS X specific code and will not work for any other platform.

loadIconback to summary
private static ByteBuffer loadIcon(String data)
logback to summary
public static void log(CharSequence msg)

Prints the given message to System.err if DEBUG is true.

Parameters
msg:CharSequence

Message to print

mapLibraryNameback to summary
public static String mapLibraryName(String name)

Wraps System#mapLibraryName. On OS X with JDK 6, the .jnilib file extension will be replaced with .dylib.

Parameters
name:String

the name of the library.

Returns:String

a platform-dependent native library name.

toHexStringback to summary
public static String toHexString(final int value)

Returns a string representation of the integer argument as an unsigned integer in base 16. The string will be uppercase and will have a leading '0x'.

Parameters
value:int

the integer value

Returns:String

the hex string representation

org.lwjgl back to summary

public Interface LWJGLUtil.TokenFilter


Simple interface for Field filtering.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the Field is accepted
accept
(Field
the Field to test
field
,
int
the integer value of the field
value
)

Should return true if the specified Field passes the filter.

Method Detail

acceptback to summary
public boolean accept(Field field, int value)

Should return true if the specified Field passes the filter.

Parameters
field:Field

the Field to test

value:int

the integer value of the field

Returns:boolean

true if the Field is accepted