|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lapetus_ltd.api.common.TLptsSysInfoUtil
public class TLptsSysInfoUtil
Class Description : System information factory.
This class has functions which provide system information like user name, host OS, and versions, host IP and MAC addresses.
$LastChangedRevision: 1179 $
$LastChangedDate:: 2010-11-12 10:13:56#$
Field Summary | |
---|---|
static java.lang.String |
OS_LINUX
Type of host system this application is running on |
static java.lang.String |
OS_MAC
Type of host system this application is running on |
static java.lang.String |
OS_SOLARIS
Type of host system this application is running on |
static java.lang.String |
OS_WINDOWS_2003
Type of host system this application is running on |
static java.lang.String |
OS_WINDOWS_7
Type of host system this application is running on |
static java.lang.String |
OS_WINDOWS_VISTA
Type of host system this application is running on |
static java.lang.String |
OS_WINDOWS_XP
Type of host system this application is running on |
Method Summary | |
---|---|
static java.lang.String |
getAllIpAddresses()
Gets a string with all the IP address of the current host. |
static java.lang.String |
getAllMacAddresses()
Gets a string with all the MAC address of the current host. |
static java.lang.String |
getDefaultIpAddress()
Get a string with the default IP address. |
static java.lang.String |
getEnvVariable(java.lang.String variableName)
This will retrieve the system variable requested. |
static java.lang.String |
getJavaVersion()
Gets the version of the Java Run-Time (JRE) installed on this host. |
static TLptsMemoryInfo |
getMemoryInfo()
Get Application Memory Info Thread Safe : Yes Spawns its own Thread : No May Return NULL : No Notes : Example : public void actionPerformed(ActionEvent e) { TLptsMemoryInfo mi = TLptsSysInfoUtil.getMemoryInfo(); String maxMemory = mi.getMemoryString(mi.getMaxMemoryInMb(), "#####.0000"); String totalMemory = mi.getMemoryString(mi.getTotalMemoryInMb(), "#####.0000"); String freeMemory = mi.getMemoryString(mi.getFreeMemoryInMb(), "#####.0000"); Timestamp dateTime = new Timestamp(mi.getTime()); //Or String time = mi.getTimeString(); } Result:63,5625 4,9375 4,3906 2010-07-08 10:58:55.493 10:58:55.493 |
static java.lang.String |
getOSArchitecture()
Gets the architecture of the running host. |
static java.lang.String |
getOSName()
This function provides the name of the host OS. |
static java.lang.String |
getOSVersion()
Gets the OS software version of the running host. |
static java.lang.String |
getSoftwareVersionString()
Gets the version string of the software from the SVN repository. |
static java.lang.String |
getUserName()
This function provides the name of the currently logged-in user. |
static boolean |
isHostLinux()
Use this to find out which OS system is hosting our running application. |
static boolean |
isHostMac()
Use this to find out which OS system is hosting our running application. |
static boolean |
isHostSolaris()
Use this to find out which OS system is hosting our running application. |
static boolean |
isHostWindows()
Use this to find out which OS system is hosting our running application. |
static void |
zI()
Obfuscated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String OS_LINUX
public static final java.lang.String OS_MAC
public static final java.lang.String OS_SOLARIS
public static final java.lang.String OS_WINDOWS_2003
public static final java.lang.String OS_WINDOWS_7
public static final java.lang.String OS_WINDOWS_VISTA
public static final java.lang.String OS_WINDOWS_XP
Method Detail |
---|
public static java.lang.String getAllIpAddresses()
Notes : The string is comma delimited with all IPs except the localhost 127.0.0.1 and 0.0.0.0.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never, only empty string.
Example :
String ips = TLptsSysInfoUtil.getAllIpAddresses(); System.out.println(ips); Result (in our case): 192.168.1.2, 192.168.1.3
public static java.lang.String getAllMacAddresses()
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never, only empty string.
Notes :
Example :
String mac = TLptsSysInfoUtil.getAllMacAddresses(); System.out.println(mac); Result (in our case): 00-24-81-08-3B-A3, 02-00-54-55-4E-01
public static java.lang.String getDefaultIpAddress()
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never, only empty string.
Notes :
Example :
String ip = TLptsSysInfoUtil.getDefaultIpAddress(); System.out.println(ip); Result (in our case): 192.168.1.2
public static java.lang.String getEnvVariable(java.lang.String variableName)
This will retrieve the system variable requested.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : No
Notes :
Example :
String envPath = TLptsSysInfoUtil.getEnvVariable("PATH"); System.out.println(envPath); Result: C:\Windows\System32;C:\Windows;C:\Java\apache-maven-2.2.1\bin;c:\program files\jetbrains\intellij idea 9.0\jre\jre\bin...
variableName
- The name of the path variable with out any special characters like $ or #.
public static java.lang.String getJavaVersion()
Gets the version of the Java Run-Time (JRE) installed on this host.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : N0
Notes :
Example :
String ver = TLptsSysInfoUtil.getJavaVersion(); System.out.println(ver); Result : 1.5.0_09
public static TLptsMemoryInfo getMemoryInfo()
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : No
Notes :
Example :
public void actionPerformed(ActionEvent e) { TLptsMemoryInfo mi = TLptsSysInfoUtil.getMemoryInfo(); String maxMemory = mi.getMemoryString(mi.getMaxMemoryInMb(), "#####.0000"); String totalMemory = mi.getMemoryString(mi.getTotalMemoryInMb(), "#####.0000"); String freeMemory = mi.getMemoryString(mi.getFreeMemoryInMb(), "#####.0000"); Timestamp dateTime = new Timestamp(mi.getTime()); //Or String time = mi.getTimeString(); } Result:63,5625 4,9375 4,3906 2010-07-08 10:58:55.493 10:58:55.493
public static java.lang.String getOSArchitecture()
Gets the architecture of the running host.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : No
Notes :
Example :
String arc = TLptsSysInfoUtil.getOSArchitecture(); System.out.println(arc); Result : x86
public static java.lang.String getOSName()
This function provides the name of the host OS.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : No
Notes :
Example :
String name = TLptsSysInfoUtil.getOSName(); System.out.println(name); Result : Windows XP.
public static java.lang.String getOSVersion()
Gets the OS software version of the running host.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : No
Notes : Use this with the OS Name.
Example :
String ver = TLptsSysInfoUtil.getOSVersion(); System.out.println(ver); Result : 6.0
public static java.lang.String getSoftwareVersionString()
Gets the version string of the software from the SVN repository.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : No
Notes : Used internally within JUT
Example :
String ver = TLptsSysInfoUtil.getSoftwareVersionString (); System.out.println(ver); Result : v1.0.655 (2010-01-10 10:10:10)
public static java.lang.String getUserName()
This function provides the name of the currently logged-in user.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : No
Notes :
Example :
String name = TLptsSysInfoUtil.getUserName (); System.out.println(name); Result : itisme.
public static boolean isHostLinux()
Use this to find out which OS system is hosting our running application.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : No
Notes :
Example :
boolean isThisLinux = TLptsSysInfoUtil.isHostLinux(); Result : Now that is more like it. We will get the correct answer here.
public static boolean isHostMac()
Use this to find out which OS system is hosting our running application.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : No
Notes :
Example :
boolean isThisLinux = TLptsSysInfoUtil.isHostMac();
Result : Either way, true or false, the result will always be incorrect as the variable name is a copy-paste mistake.
public static boolean isHostSolaris()
Use this to find out which OS system is hosting our running application.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : No
Notes :
Example :
boolean isThisSolaris = TLptsSysInfoUtil.isHostSolaris(); Result : If we are running on a Solaris, then the return value is true.
public static boolean isHostWindows()
Use this to find out which OS system is hosting our running application.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : No
Notes :
Example :
public static void zI()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |