org.fest.assertions
Class Formatting

java.lang.Object
  extended by org.fest.assertions.Formatting

public final class Formatting
extends Object

Utility methods for formatting values.

Author:
Yvonne Wang, Alex Ruiz

Method Summary
static String format(Description description, String message)
          Returns the given message formatted as follows: [description] message.
static String format(String message)
          Formats the given message: if it is null or empty, an empty String is returned, otherwise uses the following format: [message]{whitespace}
static String format(String format, Object... args)
          Returns a formatted string using the specified format String and arguments.
static String inBrackets(Object o)
          Returns the String representation of the given object in between brackets ("<" and ">").
static String valueOf(Description description)
          Returns the value of the given Description.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

format

public static String format(Description description,
                            String message)
Returns the given message formatted as follows:
 [description] message.
 

Parameters:
description - the description of the actual value in the failed assertion. It can be null.
message - the message to format.
Returns:
the formatted message.
Since:
1.2

valueOf

public static String valueOf(Description description)
Returns the value of the given Description.

Parameters:
description - the given Description.
Returns:
the value of the given Description, or null if the given Description is null.

format

public static String format(String message)
Formats the given message:
  • if it is null or empty, an empty String is returned, otherwise uses the following format:
     [message]{whitespace}
     

    Parameters:
    message - the message to format.
    Returns:
    the formatted message.

  • inBrackets

    public static String inBrackets(Object o)
    Returns the String representation of the given object in between brackets ("<" and ">"). This method has special support for arrays, Class, Collections, Maps, Files and Dimensions. For any other types, this method simply calls its toString implementation.

    Parameters:
    o - the given object.
    Returns:
    the String representation of the given object in between brackets.

    format

    public static String format(String format,
                                Object... args)
    Returns a formatted string using the specified format String and arguments. This method is similar to String.format(String, Object...). The only difference is that this method uses FEST-Assert's own toString representation of the arguments.

    Parameters:
    format - a format String.
    args - Arguments referenced by the format specifiers in the format String. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero.
    Returns:
    A formatted String.
    Throws:
    IllegalFormatException - If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format String, or other illegal conditions.
    NullPointerException - if the given format is null.
    Since:
    1.3.1


    Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.