uk.co.petertribble.jumble
Class JumbleUtils

java.lang.Object
  extended by uk.co.petertribble.jumble.JumbleUtils

public class JumbleUtils
extends java.lang.Object

Convenience routines.


Constructor Summary
JumbleUtils()
           
 
Method Summary
static java.lang.String byteToString(byte[] b)
          Reads a String out of a byte array.
static java.lang.String ListSystemProperties()
          Retrieves all the system properties into a String
static void printKeys(java.util.Hashtable h)
          Prints all the keys in a Hashtable to the standard output
static java.lang.String safeFileName(java.lang.String s)
          Sanitizes a file name, replacing undesirable characters with the "_" character.
static java.util.Hashtable<java.lang.String,java.lang.String> stringToPropHash(java.lang.String s, java.lang.String delim)
          Converts a String to a property hash.
static java.util.Map<java.lang.String,java.lang.String> stringToPropMap(java.lang.String s, java.lang.String delim)
          Converts a String to a property Map.
static java.lang.String[] stringToStringArray(java.lang.String s, java.lang.String delim)
          Converts a String to an Array of Strings separated by the given separator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JumbleUtils

public JumbleUtils()
Method Detail

ListSystemProperties

public static java.lang.String ListSystemProperties()
Retrieves all the system properties into a String

Returns:
A String containing all the system properties, one property per line, with the name and value of each property separated by " = "

printKeys

public static void printKeys(java.util.Hashtable h)
Prints all the keys in a Hashtable to the standard output

Parameters:
h - A Hashtable whose keys are to be output

safeFileName

public static java.lang.String safeFileName(java.lang.String s)
Sanitizes a file name, replacing undesirable characters with the "_" character.

Parameters:
s - The filename to be sanitized
Returns:
The sanitized filename

byteToString

public static java.lang.String byteToString(byte[] b)
Reads a String out of a byte array.

Parameters:
b - An array of bytes to be converted to a String
Returns:
The converted String

stringToStringArray

public static java.lang.String[] stringToStringArray(java.lang.String s,
                                                     java.lang.String delim)
Converts a String to an Array of Strings separated by the given separator. Normally used to break a String into its constituent lines. This method is obsolete now that the String.split method is available.

Parameters:
s - The String to be broken up.
delim - The delimiter around which the String will be broken up
Returns:
An array of Strings

stringToPropHash

public static java.util.Hashtable<java.lang.String,java.lang.String> stringToPropHash(java.lang.String s,
                                                                                      java.lang.String delim)
Converts a String to a property hash. The String is first broken up using the specified delimiter. Then the resulting Strings are broken up into a key and value, with the key being anything to the left of the first '=' character and the value anything that is left over. If no '=' character is present, that String is skipped.

Parameters:
s - The String to be broken up.
delim - The delimiter around which the String will be broken up
Returns:
A Hashtable containing the keys and values specified by the input String

stringToPropMap

public static java.util.Map<java.lang.String,java.lang.String> stringToPropMap(java.lang.String s,
                                                                               java.lang.String delim)
Converts a String to a property Map. The String is first broken up using the specified delimiter. Then the resulting Strings are broken up into a key and value, with the key being anything to the left of the first '=' character and the value anything that is left over. If no '=' character is present, that String is skipped.

Parameters:
s - The String to be broken up.
delim - The delimiter around which the String will be broken up
Returns:
A Map containing the keys and values specified by the input String