cs138.common
Class Utils

java.lang.Object
  extended by cs138.common.Utils

public class Utils
extends java.lang.Object

Class containing various utility methods

Author:
rm

Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String getHostName()
          Looks up the fully qualified domain name for this host.
static java.util.Random getRandom()
          To help deal with Random seed issues, we define a single instance of the Random class to exist in the project and provide an access method for it.
static java.lang.String getRandomNode()
          Based on the cs138.service.nodes property, this method will read in a list of nodes and randomly pick one to use.
static java.lang.String prettyType(java.lang.String type)
          Translates the full java name for a given node implementation and returns a more user friendly version of the name based on the core interface that is being used by it.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

getHostName

public static java.lang.String getHostName()
Looks up the fully qualified domain name for this host. Note the underlying method is only best effort, so it may return less.

Returns:
The string form of this host's fqdn.

prettyType

public static java.lang.String prettyType(java.lang.String type)
Translates the full java name for a given node implementation and returns a more user friendly version of the name based on the core interface that is being used by it.

Parameters:
type - A string containing the complete java name for the given implementation type
Returns:
A friendly version of the name for use in a GUI or logging.

getRandom

public static java.util.Random getRandom()
To help deal with Random seed issues, we define a single instance of the Random class to exist in the project and provide an access method for it. This random class is seeded on the currentTimeMillis

Returns:
The system wide Random variable.

getRandomNode

public static java.lang.String getRandomNode()
Based on the cs138.service.nodes property, this method will read in a list of nodes and randomly pick one to use.

Returns:
A random node to use or null there was an error locating the specified nodes file.