edu.wisc.ssec.mcidasv.util
Class SystemState

java.lang.Object
  extended by edu.wisc.ssec.mcidasv.util.SystemState

public class SystemState
extends Object

Utility methods for querying the state of the user's machine.


Field Summary
private static org.slf4j.Logger logger
          Handy logging object.
 
Constructor Summary
private SystemState()
           
 
Method Summary
static String escapeWhitespaceChars(CharSequence sequence)
           
static Map<Integer,Rectangle> getDisplayBounds()
          Returns a mapping of display number to a Rectangle that represents the "bounds" of the display.
static String getIdvVersionString()
          Gets a human-friendly representation of the information embedded within IDV's build.properties.
static String getMcvVersionString()
          Gets a human-friendly representation of the information embedded within McIDAS-V's build.properties.
private  InputStream getResourceAsStream(String name)
           
static String getStateAsString(McIDASV mcv)
          Builds a (filtered) subset of the McIDAS-V system properties and returns the results as a String.
static String getStateAsString(McIDASV mcv, boolean firehose)
          Builds the McIDAS-V system properties and returns the results as a String.
static Rectangle getVirtualDisplayBounds()
           
static String getVisadVersionString()
          Gets a human-friendly representation of the version information embedded within VisAD's "DATE" file.
private static
<T> T
hackyMethodCall(String methodName, T defaultValue)
          Attempt to invoke OperatingSystemMXBean.methodName via reflection.
static Map<String,String> queryIdvBuildProperties()
          Returns a Map of the (currently) most useful contents of ucar/unidata/idv/resources/build.properties.
static Map<String,Object> queryJava3d()
          Polls Java 3D for information about its environment.
static Map<Object,Object> queryJythonProps()
          Returns the contents of Jython's registry (basically just Jython-specific properties) as well as some of the information from Python's "sys" module.
static Map<String,String> queryMachine()
          Polls Java for information about the user's machine.
static Map<String,String> queryMcvBuildProperties()
          Returns a Map of the (currently) most useful contents of edu/wisc/ssec/mcidasv/resources/build.properties.
static Map<String,Object> queryMcvState(McIDASV mcv)
          Queries McIDAS-V for information about its state.
static Map<String,String> queryOpSysProps()
          Attempts to call methods belonging to com.sun.management.OperatingSystemMXBean.
static Map<String,String> queryVisadBuildProperties()
          Returns a Map containing any relevant version information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.slf4j.Logger logger
Handy logging object.

Constructor Detail

SystemState

private SystemState()
Method Detail

escapeWhitespaceChars

public static String escapeWhitespaceChars(CharSequence sequence)

hackyMethodCall

private static <T> T hackyMethodCall(String methodName,
                                     T defaultValue)
Attempt to invoke OperatingSystemMXBean.methodName via reflection.

Type Parameters:
T - Either Long or Double.
Parameters:
methodName - The method to invoke. Must belong to com.sun.management.OperatingSystemMXBean.
defaultValue - Default value to return, must be in "boxed" form.
Returns:
Either the result of the methodName call or defaultValue.

queryJythonProps

public static Map<Object,Object> queryJythonProps()
Returns the contents of Jython's registry (basically just Jython-specific properties) as well as some of the information from Python's "sys" module.

Returns:
Jython's configuration settings.

queryOpSysProps

public static Map<String,String> queryOpSysProps()
Attempts to call methods belonging to com.sun.management.OperatingSystemMXBean. If successful, we'll have the following information:

Returns:
Map of properties that contains interesting information about the hardware McIDAS-V is using.

queryMachine

public static Map<String,String> queryMachine()
Polls Java for information about the user's machine. We're specifically after memory statistics, number of processors, and display information.

Returns:
Map of properties that describes the user's machine.

getDisplayBounds

public static Map<Integer,Rectangle> getDisplayBounds()
Returns a mapping of display number to a Rectangle that represents the "bounds" of the display.

Returns:
Rectangles representing the "bounds" of the current display devices.

getVirtualDisplayBounds

public static Rectangle getVirtualDisplayBounds()

queryJava3d

public static Map<String,Object> queryJava3d()
Polls Java 3D for information about its environment. Specifically, we call VirtualUniverse.getProperties() and Canvas3D.queryProperties().

Returns:
As much information as Java 3D can provide.

getIdvVersionString

public static String getIdvVersionString()
Gets a human-friendly representation of the information embedded within IDV's build.properties.

Returns:
String that looks like "IDV version major.minor<b>revision</b> built <b>date</b>". For example: IDV version 2.9u4 built 2011-04-13 14:01 UTC.

getMcvVersionString

public static String getMcvVersionString()
Gets a human-friendly representation of the information embedded within McIDAS-V's build.properties.

Returns:
String that looks like "McIDAS-V version major.minor<b>release</b> built <b>date</b>". For example: McIDAS-V version 1.02beta1 built 2011-04-14 17:36.

getVisadVersionString

public static String getVisadVersionString()
Gets a human-friendly representation of the version information embedded within VisAD's "DATE" file.

Returns:
String that looks "VisAD version <b>revision</b> built <b>date</b>". For example: VisAD version 5952 built Thu Mar 22 13:01:31 CDT 2012.

getResourceAsStream

private InputStream getResourceAsStream(String name)

queryVisadBuildProperties

public static Map<String,String> queryVisadBuildProperties()
Returns a Map containing any relevant version information.

Currently this information consists of the date visad.jar was built, as well as the (then-current) Subversion revision number.

Returns:
Map of the contents of VisAD's DATE file.

queryIdvBuildProperties

public static Map<String,String> queryIdvBuildProperties()
Returns a Map of the (currently) most useful contents of ucar/unidata/idv/resources/build.properties.

Consider the output of getIdvVersionString(); it's built with the the following:

Returns:
A Map of at least the useful parts of build.properties.

queryMcvBuildProperties

public static Map<String,String> queryMcvBuildProperties()
Returns a Map of the (currently) most useful contents of edu/wisc/ssec/mcidasv/resources/build.properties.

Consider the output of getMcvVersionString(); it's built with the the following:

Returns:
A Map of at least the useful parts of build.properties.

queryMcvState

public static Map<String,Object> queryMcvState(McIDASV mcv)
Queries McIDAS-V for information about its state. There's not a good way to characterize what we're interested in, so let's leave it at "whatever seems useful".

Parameters:
mcv - The McIDASV "god" object.
Returns:
Information about the state of McIDAS-V.

getStateAsString

public static String getStateAsString(McIDASV mcv)
Builds a (filtered) subset of the McIDAS-V system properties and returns the results as a String.

Parameters:
mcv - The McIDASV "god" object.
Returns:
The McIDAS-V system properties in the following format: KEY=VALUE\n. This is so we kinda-sorta conform to the standard Properties file format.
See Also:
getStateAsString(edu.wisc.ssec.mcidasv.McIDASV, boolean)

getStateAsString

public static String getStateAsString(McIDASV mcv,
                                      boolean firehose)
Builds the McIDAS-V system properties and returns the results as a String.

Parameters:
mcv - The McIDASV "god" object.
firehose - If true, enables "unfiltered" output.
Returns:
The McIDAS-V system properties in the following format: KEY=VALUE\n. This is so we kinda-sorta conform to the standard Properties file format.