de.beamertool.util
Class Utils

java.lang.Object
  extended by de.beamertool.util.Utils

public class Utils
extends Object

Author:
ocm-zeeman

Constructor Summary
Utils()
           
 
Method Summary
static String camelToHuman(String name)
          Converts a camel-notated string to a more human readable format.
static String colorToHTML(Color aColor)
          Converts a give color to it's html hex-notated counterpart.
static String getDateAsISO8601(Date date)
          Formats a string ISO8601 compliant.
static Collection<gnu.io.CommPortIdentifier> getPorts()
          Lists all availible com ports.
static BufferedImage getWindowIcon()
          Returns the beamer-tool icon.
static URL loadFramClassPath(String fileName)
          Tries to load a given file from the current classpath.
static void logStackTrace(Logger logger, Throwable t)
          Write the complete stacktrace to the logger.
static void openURLinBrowser(URL url)
          Opens the given URL in an external browser.
static void prepareLogger(Logger aLogger)
          Prepares the given logger according to the system proptery "beamer-tool.debug".
static void prepareSystem()
          Sets additional system properties
static String randomString(int length)
          Returns a random string with the given length.
static void setIconToFrame(Window aWindow)
          Sets the beamer-tool icon to the given window.
static String stringFirstUppercase(String value)
          Converts the first character of a string to uppercase and the rest to lowercase.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

camelToHuman

public static String camelToHuman(String name)
Converts a camel-notated string to a more human readable format.
The first character will be uppercased and every following uppercase is treated as word seperator.
For example "theNiceCamel" becomes "The Nice Camel"

Parameters:
name - the camel-noted string to convert
Returns:
the converted string

colorToHTML

public static String colorToHTML(Color aColor)
Converts a give color to it's html hex-notated counterpart.
For example Color.RED becomes "#ff0000"

Parameters:
aColor - the color to convert
Returns:
the html hex-notated counterpart of aColor

getDateAsISO8601

public static String getDateAsISO8601(Date date)
Formats a string ISO8601 compliant.

Parameters:
date - the date to format
Returns:
a string with a ISO8601 compliant date

getPorts

public static Collection<gnu.io.CommPortIdentifier> getPorts()
Lists all availible com ports.
The resulting list might be incomplete due to lacks in RXTX!

Returns:
a list of all availible com ports

getWindowIcon

public static BufferedImage getWindowIcon()
                                   throws IOException
Returns the beamer-tool icon.
Loads the image from the classpath

Returns:
the loaded icon or null
Throws:
IOException - if an IO-Error occurs

loadFramClassPath

public static URL loadFramClassPath(String fileName)
Tries to load a given file from the current classpath.

Parameters:
fileName - - the filename for the search
Returns:
- returns the url for the given filename or null if the file isn't found

logStackTrace

public static void logStackTrace(Logger logger,
                                 Throwable t)
Write the complete stacktrace to the logger.
It looks as warn and includes alle causes.

Parameters:
logger - the logger to log to
t - source of the stacktrace

openURLinBrowser

public static void openURLinBrowser(URL url)
                             throws IOException,
                                    URISyntaxException
Opens the given URL in an external browser.

Parameters:
url -
Throws:
URISyntaxException
IOException

prepareLogger

public static void prepareLogger(Logger aLogger)
Prepares the given logger according to the system proptery "beamer-tool.debug".
If the system property "beamer-tool_admin" is set, the loglevel is set to DEBUG. Oterwise WARN is used.

Parameters:
aLogger - the logger to set up

prepareSystem

public static void prepareSystem()
Sets additional system properties


randomString

public static String randomString(int length)
Returns a random string with the given length.

Parameters:
length - the length of the random string
Returns:
returns a random generated string with the given length

setIconToFrame

public static void setIconToFrame(Window aWindow)
Sets the beamer-tool icon to the given window.

Parameters:
aWindow - the window to set the icon to

stringFirstUppercase

public static String stringFirstUppercase(String value)
Converts the first character of a string to uppercase and the rest to lowercase.
For example "hello There" becomes "Hello there"

Parameters:
value - the string to convert
Returns:
the modified string