Package com.kenai.jffi
Class Platform
- java.lang.Object
-
- com.kenai.jffi.Platform
-
- Direct Known Subclasses:
Platform.Darwin,Platform.Default,Platform.Windows
public abstract class Platform extends java.lang.ObjectConvenience class to interrogate the system about various platform-specific details.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPlatform.ArchHolderstatic classPlatform.CPUThe common names of cpu architectures.private static classPlatform.DarwinAPlatformsubclass representing the MacOS system.private static classPlatform.Defaultstatic classPlatform.OSThe common names of operating systems.private static classPlatform.SingletonHolderHolds a single, lazily loaded instance ofPlatformprivate static classPlatform.WindowsAPlatformsubclass representing the Windows system.
-
Field Summary
Fields Modifier and Type Field Description private intjavaVersionMajorprivate static java.util.LocaleLOCALEprivate Platform.OSos
-
Constructor Summary
Constructors Modifier Constructor Description privatePlatform(Platform.OS os)Constructs a newPlatforminstance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description longaddressMask()Gets the 32/64bit mask of a C address/pointer on the native platform.intaddressSize()Gets the size of a C address/pointer on the native platform.private static Platform.OSdetermineOS()Determines the operating system jffi is running onprivate static PlatformdeterminePlatform(Platform.OS os)Determines thePlatformthat best describes theOSPlatform.CPUgetCPU()Gets the current processor architecture the JVM is running on.intgetJavaMajorVersion()Gets the version of the Java Virtual Machine (JVM) jffi is running on.java.lang.StringgetLibraryNamePattern()Gets the regex string used to match platform-specific librariesjava.lang.StringgetName()Gets the name of thisPlatform.Platform.OSgetOS()Gets the current Operating System.static PlatformgetPlatform()Gets the currentPlatformbooleanisSupported()Checks if the current platform is supported by JFFI.abstract intlongSize()Gets the size of a C 'long' on the native platform.java.lang.StringmapLibraryName(java.lang.String libName)Maps from a generic library name (e.g.private static PlatformnewDarwinPlatform()private static PlatformnewDefaultPlatform(Platform.OS os)private static PlatformnewWindowsPlatform()private static booleanstartsWithIgnoreCase(java.lang.String s1, java.lang.String s2)
-
-
-
Field Detail
-
LOCALE
private static final java.util.Locale LOCALE
-
os
private final Platform.OS os
-
javaVersionMajor
private final int javaVersionMajor
-
-
Constructor Detail
-
Platform
private Platform(Platform.OS os)
Constructs a newPlatforminstance.- Parameters:
os- The current operating system.
-
-
Method Detail
-
determineOS
private static final Platform.OS determineOS()
Determines the operating system jffi is running on- Returns:
- An member of the
OSenum.
-
determinePlatform
private static final Platform determinePlatform(Platform.OS os)
Determines thePlatformthat best describes theOS- Parameters:
os- The operating system.- Returns:
- An instance of
Platform
-
newDarwinPlatform
private static Platform newDarwinPlatform()
-
newWindowsPlatform
private static Platform newWindowsPlatform()
-
newDefaultPlatform
private static Platform newDefaultPlatform(Platform.OS os)
-
getPlatform
public static final Platform getPlatform()
Gets the currentPlatform- Returns:
- The current platform.
-
getOS
public final Platform.OS getOS()
Gets the current Operating System.- Returns:
- A
OSvalue representing the current Operating System.
-
getCPU
public final Platform.CPU getCPU()
Gets the current processor architecture the JVM is running on.- Returns:
- A
CPUvalue representing the current processor architecture.
-
getJavaMajorVersion
public final int getJavaMajorVersion()
Gets the version of the Java Virtual Machine (JVM) jffi is running on.- Returns:
- A number representing the java version. e.g. 5 for java 1.5, 6 for java 1.6
-
longSize
public abstract int longSize()
Gets the size of a C 'long' on the native platform.- Returns:
- the size of a long in bits
-
addressSize
public final int addressSize()
Gets the size of a C address/pointer on the native platform.- Returns:
- the size of a pointer in bits
-
addressMask
public final long addressMask()
Gets the 32/64bit mask of a C address/pointer on the native platform.- Returns:
- the size of a pointer in bits
-
getName
public java.lang.String getName()
Gets the name of thisPlatform.- Returns:
- The name of this platform.
-
mapLibraryName
public java.lang.String mapLibraryName(java.lang.String libName)
Maps from a generic library name (e.g. "c") to the platform specific library name.- Parameters:
libName- The library name to map- Returns:
- The mapped library name.
-
getLibraryNamePattern
public java.lang.String getLibraryNamePattern()
Gets the regex string used to match platform-specific libraries- Returns:
-
isSupported
public boolean isSupported()
Checks if the current platform is supported by JFFI.- Returns:
trueif the platform is supported, else false.
-
startsWithIgnoreCase
private static boolean startsWithIgnoreCase(java.lang.String s1, java.lang.String s2)
-
-