public class TargetFactory extends Object
TargetFactory serves as a central mechanism to instantiate OS specific class
flavors, provide OS specific file extension types, default install directories and similar
functionality. In addition it provides services that are related to OS versions and flavors. For
a tutorial on using some of the features in this class see the TargetFactory Tutorial.| Modifier and Type | Field and Description |
|---|---|
static int |
GENERIC
Used to report a non specific operating system.
|
static int |
NT
Used to identify the Windows-NT class of operating systems in terms of an OS flavor.
|
static int |
OTHER
Nonspecific processor architecture, other than X86.
|
static int |
STANDARD
This is the basic flavor for every operating system.
|
static int |
UNIX
Identifies generic UNIX operating systems
|
static int |
WINDOWS
Identifies Microsoft Windows.
|
static int |
X
Used to identify the OS X flavor of the Mac OS
|
static int |
X86
Identifies Intel X86 based processor types.
|
| Constructor and Description |
|---|
TargetFactory(TargetPlatformFactory factory)
Constructs a TargetFactory.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getArchitecture()
Returns an index number that identified the processor architecture of the target system.
|
static String |
getCurrentOSPrefix()
Gets a prefix alias for the current platform.
|
String |
getDefaultInstallPath(String appName)
Returns the system dependent default install path.
|
String |
getNativeLibraryExtension()
Returns the file extension customarily used on the target OS for dynamically loadable
libraries.
|
int |
getOS()
Returns the index number for the target operating system that was detected.
|
int |
getOSFlavor()
Returns the index number for the operating system flavor that was detected on the target
system.
|
<T> T |
makeObject(Class<T> clazz)
This method returns an OS specific instance of the requested class.
|
Object |
makeObject(String name)
This method returns an OS and OS flavor specific instance of the requested class.
|
boolean |
versionIsHigher(String version)
Returns true if the version in the parameter string is higher than the version of the target
os.
|
public static final int WINDOWS
public static final int UNIX
public static final int GENERIC
public static final int STANDARD
public static final int NT
public static final int X
public static final int X86
public static final int OTHER
public TargetFactory(TargetPlatformFactory factory)
factory - the factory to delegate topublic <T> T makeObject(Class<T> clazz) throws Exception
DefaultTargetPlatformFactory, falling back to makeObject(String)
if the call fails.clazz - theException - for any errorpublic Object makeObject(String name) throws Exception
| Operating System | Prefix |
|---|---|
| Microsoft Windows | Win_ |
| Mac OS | Mac_ |
| UNIX | UNIX_ |
| OS Flavor | Prefix |
|---|---|
| NT | NT_ |
| Mac OS X | X_ |
MyClass, the specific version for Windows NT must be in the
same package as MyClass and the name must be Win_NT_MyClass. A
version that should be instantiated for any non-NT flavor would be called
Win_MyClass. This would also be the version instantiated on Windows NT if the
version Win_NT_MyClass does not exist. name - the fully qualified name of the class to load without the extension.Exception - if all attempts to instantiate class failpublic boolean versionIsHigher(String version) throws Exception
version - the version number to compare tofalse if the version of the target system is higher, otherwise
trueExceptionpublic int getOS()
public int getOSFlavor()
public int getArchitecture()
public String getNativeLibraryExtension()
String containing the customary library extension for the target OS.
Note that the string might be empty if there no such specific extension for the target OS.public String getDefaultInstallPath(String appName)
INSTALL_PATH_FRAGMENT,
possibly a drive letter and the application name. The user the option to define resources
that define default paths which differ from the path fragments defined here. The following
resource names will be recognized by this method: TargetPanel.dir.windows
TargetPanel.dir.macosx
TargetPanel.dir.unix
TargetPanel.dir plus the all lower case version of
System.getProperty ("os.name"), with all spaces replaced by an underscore
('_').
TargetPanel.dir
appName - the name of the application to install. If no specific resource has been set,
then this name will be appended to the OS specific default path fragment.public static String getCurrentOSPrefix()
Copyright © 2001–2025. All rights reserved.