fulmine.util
Class Utils

java.lang.Object
  extended by fulmine.util.Utils

public abstract class Utils
extends Object

Utility methods and constants.

Author:
Ramon Servadei

Field Summary
static String BACKSPACE
          The backspace character (escaped) '\\'
static String CLOSE_BRACE
          Close brace ')'
static String CLOSE_CURLY
          Close curly brace '}'
static String CLOSE_SQUARE
          Close square brace ']'
static String COLON
          Colon ':'
static String COMMA
          Comma ','
static String COMMA_SPACE
          Comma followed by space ', '
static String DOT
          Full stop or dot '.'
static String EMPTY_STRING
          The empty string
static String EQUALS
          Equals '='
static String OPEN_BRACE
          Open brace '('
static String OPEN_CURLY
          Open curly brace '{'
static String OPEN_SQUARE
          Open square brace '['
static String SPACE
          Single space ' '
static String SPACING_4_CHARS
          Standard 4 char spacing
static String UNDERSCORE
          The underscore character '_'
 
Constructor Summary
Utils()
           
 
Method Summary
static void logException(org.apache.commons.logging.Log log, Object context, Exception e)
          Log an exception to WARN or System.err if the log level is not enabled.
static void nullCheck(Object reference, String message)
          Check if the reference is null.
static String safeToString(Object target)
          Invoke the toString() method on the target.
static String string(Object source, String message)
          Produces a string representation of a source object class with a message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLON

public static final String COLON
Colon ':'

See Also:
Constant Field Values

EMPTY_STRING

public static final String EMPTY_STRING
The empty string

See Also:
Constant Field Values

SPACING_4_CHARS

public static final String SPACING_4_CHARS
Standard 4 char spacing

See Also:
Constant Field Values

CLOSE_SQUARE

public static final String CLOSE_SQUARE
Close square brace ']'

See Also:
Constant Field Values

OPEN_SQUARE

public static final String OPEN_SQUARE
Open square brace '['

See Also:
Constant Field Values

CLOSE_CURLY

public static final String CLOSE_CURLY
Close curly brace '}'

See Also:
Constant Field Values

OPEN_CURLY

public static final String OPEN_CURLY
Open curly brace '{'

See Also:
Constant Field Values

CLOSE_BRACE

public static final String CLOSE_BRACE
Close brace ')'

See Also:
Constant Field Values

OPEN_BRACE

public static final String OPEN_BRACE
Open brace '('

See Also:
Constant Field Values

SPACE

public static final String SPACE
Single space ' '

See Also:
Constant Field Values

COMMA

public static final String COMMA
Comma ','

See Also:
Constant Field Values

DOT

public static final String DOT
Full stop or dot '.'

See Also:
Constant Field Values

EQUALS

public static final String EQUALS
Equals '='

See Also:
Constant Field Values

COMMA_SPACE

public static final String COMMA_SPACE
Comma followed by space ', '

See Also:
Constant Field Values

UNDERSCORE

public static final String UNDERSCORE
The underscore character '_'

See Also:
Constant Field Values

BACKSPACE

public static final String BACKSPACE
The backspace character (escaped) '\\'

See Also:
Constant Field Values
Constructor Detail

Utils

public Utils()
Method Detail

logException

public static void logException(org.apache.commons.logging.Log log,
                                Object context,
                                Exception e)
Log an exception to WARN or System.err if the log level is not enabled.

Parameters:
log - the logger to use, if null then the Utils logger is used
context - the context message for the exception
e - the exception

safeToString

public static String safeToString(Object target)
Invoke the toString() method on the target. If an exception occurs, a standard error string is returned.

Parameters:
target - the target to invoke the toString() method on
Returns:
the output of the toString() method or a standard error string

string

public static String string(Object source,
                            String message)
Produces a string representation of a source object class with a message.

Parameters:
source - the source object class for the string message
message - a message to add
Returns:
a string in the format [source class](message)

nullCheck

public static void nullCheck(Object reference,
                             String message)
Check if the reference is null. If it is, throws an IllegalArgumentException with the message

Parameters:
reference - the reference to check for null
message - the exception message to use
Throws:
IllegalArgumentException - if the reference is null


Copyright © 2007-2009. All Rights Reserved.