Package de.umass.util

Class StringUtilities


  • public final class StringUtilities
    extends java.lang.Object
    Utilitiy class with methods to calculate an md5 hash and to encode URLs.
    Author:
    Janni Kovacs
    • Constructor Summary

      Constructors 
      Constructor Description
      StringUtilities()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String cleanUp​(java.lang.String s)
      Strips all characters from a String, that might be invalid to be used in file names.
      static boolean convertToBoolean​(java.lang.String resultString)
      Converts a Last.fm boolean result string to a boolean.
      static java.lang.String decode​(java.lang.String s)  
      static java.lang.String encode​(java.lang.String s)  
      static boolean isMbid​(java.lang.String nameOrMbid)  
      static boolean isMD5​(java.lang.String s)
      Tests if the given string might already be a 32-char md5 string.
      static java.util.Map<java.lang.String,​java.lang.String> map​(java.lang.String... strings)
      Creates a Map out of an array with Strings.
      static java.lang.String md5​(java.lang.String s)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringUtilities

        public StringUtilities()
    • Method Detail

      • md5

        public static java.lang.String md5​(java.lang.String s)
      • encode

        public static java.lang.String encode​(java.lang.String s)
      • decode

        public static java.lang.String decode​(java.lang.String s)
      • isMbid

        public static boolean isMbid​(java.lang.String nameOrMbid)
      • map

        public static java.util.Map<java.lang.String,​java.lang.String> map​(java.lang.String... strings)
        Creates a Map out of an array with Strings.
        Parameters:
        strings - input strings, key-value alternating
        Returns:
        a parameter map
      • cleanUp

        public static java.lang.String cleanUp​(java.lang.String s)
        Strips all characters from a String, that might be invalid to be used in file names. By default : / \ < > | ? " * are all replaced by -. Note that this is no guarantee that the returned name will be definately valid.
        Parameters:
        s - the String to clean up
        Returns:
        the cleaned up String
      • isMD5

        public static boolean isMD5​(java.lang.String s)
        Tests if the given string might already be a 32-char md5 string.
        Parameters:
        s - String to test
        Returns:
        true if the given String might be a md5 string
      • convertToBoolean

        public static boolean convertToBoolean​(java.lang.String resultString)
        Converts a Last.fm boolean result string to a boolean.
        Parameters:
        resultString - A Last.fm boolean result string.
        Returns:
        true if the given String represents a true, false otherwise.