Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)

com.lapetus_ltd.api.common
Class TLptsSysInfoUtil

java.lang.Object
  extended by com.lapetus_ltd.api.common.TLptsSysInfoUtil

public class TLptsSysInfoUtil
extends java.lang.Object

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

OS_LINUX

public static final java.lang.String OS_LINUX
Type of host system this application is running on

See Also:
Constant Field Values

OS_MAC

public static final java.lang.String OS_MAC
Type of host system this application is running on

See Also:
Constant Field Values

OS_SOLARIS

public static final java.lang.String OS_SOLARIS
Type of host system this application is running on

See Also:
Constant Field Values

OS_WINDOWS_2003

public static final java.lang.String OS_WINDOWS_2003
Type of host system this application is running on

See Also:
Constant Field Values

OS_WINDOWS_7

public static final java.lang.String OS_WINDOWS_7
Type of host system this application is running on

See Also:
Constant Field Values

OS_WINDOWS_VISTA

public static final java.lang.String OS_WINDOWS_VISTA
Type of host system this application is running on

See Also:
Constant Field Values

OS_WINDOWS_XP

public static final java.lang.String OS_WINDOWS_XP
Type of host system this application is running on

See Also:
Constant Field Values
Method Detail

getAllIpAddresses

public static java.lang.String getAllIpAddresses()
Gets a string with all the IP address of the current host.

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

 

Returns:
ips in a string delimited by comma.

getAllMacAddresses

public static java.lang.String getAllMacAddresses()
Gets a string with all the MAC address of the current host.

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
 

Returns:
mac addresses in a string delimited by comma.

getDefaultIpAddress

public static java.lang.String getDefaultIpAddress()
Get a string with the default IP address.

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

 

Returns:
default ip in a string

getEnvVariable

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...
 

Parameters:
variableName - The name of the path variable with out any special characters like $ or #.
Returns:
A string with the value of the requested variable, or NULL is the environment variable does not exist.

getJavaVersion

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
 

Returns:
The version of Java.

getMemoryInfo

public 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

 

Returns:
a new instance of application memory info

getOSArchitecture

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
 

Returns:
The architecture of the current host, or an empty string on error.

getOSName

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.
 

Returns:
A string containing the name of the OS.

getOSVersion

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
 

Returns:
The version of the host OS software.

getSoftwareVersionString

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)
 

Returns:
A string containing the version of this software.

getUserName

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.
 

Returns:
A string containing the name of the User.

isHostLinux

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.
 

Returns:
True if our application is running on a Linux System.

isHostMac

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.

Returns:
True if our application is running on an Apple Machintosh System.

isHostSolaris

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.
 

Returns:
True if our application is running on a Solaris System.

isHostWindows

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 :

Returns:
True if our application is running on a Windows System.

zI

public static void zI()
Obfuscated.



Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)