org.apache.anteater.util
Class Utils

java.lang.Object
  |
  +--org.apache.anteater.util.Utils

public class Utils
extends Object

Various utility methods.

Since:
October 1, 2001
Version:
$Revision: 1.10 $ $Date: 2003/03/09 15:12:17 $
Author:
Ovidiu Predescu, Jeff Turner

Method Summary
static String compare(String expected, String actual)
          Resolve a reference to a resource.
static String compareWeak(String expected, String actual)
          String comparison with precise error reporting, ignoring whitespace.
static String interpolate(Map map, String rawValue)
          Replace ${variables} in a string with values from a Map.
static String normalizeSpaces(String s)
          Utility to normalize whitespace in a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

compare

public static String compare(String expected,
                             String actual)
Resolve a reference to a resource. public String resolve(Project proj, String ref) { } // These compare methods based on code from Latka // (http://http://jakarta.apache.org/commons/latka/) /** String comparison with precise error reporting. Compares an expected and actual String for equality.

Returns:
An error message if the strings don't match, null if they do.

compareWeak

public static String compareWeak(String expected,
                                 String actual)
String comparison with precise error reporting, ignoring whitespace. Equivalent to compare(java.lang.String, java.lang.String), but ignores whitespace [\t\n\r\f].

Returns:
An error message if the strings don't match, null if they do.

normalizeSpaces

public static String normalizeSpaces(String s)
Utility to normalize whitespace in a String. Ie, collapses whitespace (spaces, tabs, linefeeds etc) into a single ' ' character. Note: doesn't trim() the string; whitespace at the beginning and end is normalized too.

Parameters:
s - String to normalize
Returns:
A normalised version of s.

interpolate

public static String interpolate(Map map,
                                 String rawValue)
Replace ${variables} in a string with values from a Map.

Parameters:
map - a map of key-value pairs.
rawValue - String containing ${variable} references to replace
Returns:
rawValue string with variables interpolated
Throws:
RuntimeException - if any variables are undefined.


Ant Functional Tester -- see Project home page for details