org.pandora.util
Class Utils

java.lang.Object
  extended by org.pandora.util.Utils

public class Utils
extends java.lang.Object

Helper utility class.


Field Summary
static java.util.Map<java.lang.String,java.lang.String> profanityMap
           
 
Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String capitalize(java.lang.String text)
          Capitalize the first character of the string.
static java.lang.String compress(java.lang.String text, int size)
          Compress the text to be a proper identifier within the size limit.
static java.util.List<java.lang.String> getWords(java.lang.String text)
          Tokenize the sentence into its words.
static boolean isProfanity(java.lang.String text)
          Check if the text contains any profanity.
static java.lang.String mapProfanity(java.lang.String word)
          If the word is profanity, map it to something less offensive.
static java.util.Calendar parseDate(java.lang.String value)
          Parse the date of the form, "yyyy-MM-dd HH:mm:ss.S".
static java.util.Calendar parseDate(java.lang.String value, java.lang.String format)
          Parse the date of the format.
static java.sql.Timestamp parseTimestamp(java.lang.String value)
          Parse the date of the form, "yyyy-MM-dd HH:mm:ss.N".
static java.lang.String printDate(java.util.Calendar date)
          Print the date in the form, "yyyy-MM-dd HH:mm:ss.S".
static java.lang.String printTimestamp(java.sql.Timestamp timestamp)
          Print the date in the form, "yyyy-MM-dd HH:mm:ss.N".
static void sleep(int millis)
           
static java.lang.String translateProfanity(java.lang.String text)
          If the word is profanity, map it to something less offensive.
static java.lang.String truncate(java.lang.String text, int size)
          Truncate the string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

profanityMap

public static java.util.Map<java.lang.String,java.lang.String> profanityMap
Constructor Detail

Utils

public Utils()
Method Detail

isProfanity

public static boolean isProfanity(java.lang.String text)
Check if the text contains any profanity.


mapProfanity

public static java.lang.String mapProfanity(java.lang.String word)
If the word is profanity, map it to something less offensive.


translateProfanity

public static java.lang.String translateProfanity(java.lang.String text)
If the word is profanity, map it to something less offensive.


getWords

public static java.util.List<java.lang.String> getWords(java.lang.String text)
Tokenize the sentence into its words.


parseDate

public static java.util.Calendar parseDate(java.lang.String value)
                                    throws java.text.ParseException
Parse the date of the form, "yyyy-MM-dd HH:mm:ss.S".

Throws:
java.text.ParseException

parseTimestamp

public static java.sql.Timestamp parseTimestamp(java.lang.String value)
                                         throws java.text.ParseException
Parse the date of the form, "yyyy-MM-dd HH:mm:ss.N".

Throws:
java.text.ParseException

parseDate

public static java.util.Calendar parseDate(java.lang.String value,
                                           java.lang.String format)
                                    throws java.text.ParseException
Parse the date of the format.

Throws:
java.text.ParseException

printDate

public static java.lang.String printDate(java.util.Calendar date)
Print the date in the form, "yyyy-MM-dd HH:mm:ss.S".


printTimestamp

public static java.lang.String printTimestamp(java.sql.Timestamp timestamp)
Print the date in the form, "yyyy-MM-dd HH:mm:ss.N".


sleep

public static void sleep(int millis)

compress

public static java.lang.String compress(java.lang.String text,
                                        int size)
Compress the text to be a proper identifier within the size limit. Replace space with '-' and remove any non alpha numerics.


truncate

public static java.lang.String truncate(java.lang.String text,
                                        int size)
Truncate the string.


capitalize

public static java.lang.String capitalize(java.lang.String text)
Capitalize the first character of the string.