class TextUtils {

    public static String htmlLinks( String text )
    {
        if ( text == null || text.trim().isEmpty() )
        {
            return null;
        }

        Matcher matcher = LINK_PATTERN.matcher( text );

        StringBuffer buffer = new StringBuffer();

        while ( matcher.find() )
        {
            String url = matcher.group( 1 );
            String suffix = matcher.group( 3 );

            String ref = url.startsWith( "www." ) ? "http://" + url : url;

            url = "<a href=\"" + ref + "\">" + url + "</a>" + suffix;

            matcher.appendReplacement( buffer, url );
        }

        return matcher.appendTail( buffer ).toString();
    }

}