org.semanticdesktop.aperture.util
Class StringUtil

java.lang.Object
  extended by org.semanticdesktop.aperture.util.StringUtil

public class StringUtil
extends Object

Provides utility methods for String handling.


Constructor Summary
StringUtil()
           
 
Method Summary
static String replace(String olds, String news, String text)
          Substitute String "old" by String "new" in String "text" everywhere.
static String sha1Hash(byte[] bytes)
          Computes the SHA1 hash for the given byte array.
static String sha1Hash(String string)
          Computes the SHA1 hash for the given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtil

public StringUtil()
Method Detail

replace

public static String replace(String olds,
                             String news,
                             String text)
Substitute String "old" by String "new" in String "text" everywhere.

Parameters:
olds - The String to be substituted.
news - The String containing the new content.
text - The String in which the substitution is done.
Returns:
The result String containing the substitutions; if no substitutions were made, the specified 'text' instance is returned.

sha1Hash

public static String sha1Hash(String string)
Computes the SHA1 hash for the given string.

The code has been 'borrowed' from the mimedir-parser available from http://ilrt.org/discovery/2003/02/cal/mimedir-parser/

Parameters:
string - The string for which we'd like to get the SHA1 hash.
Returns:
The generated SHA1 hash

sha1Hash

public static String sha1Hash(byte[] bytes)
Computes the SHA1 hash for the given byte array.

Parameters:
bytes - the byte array
Returns:
SHA1 hash for the given byte array


Copyright © 2010 Aperture Development Team. All Rights Reserved.