com.twitter.common.net
Class UrlTokenizerUtil

java.lang.Object
  extended by com.twitter.common.net.UrlTokenizerUtil

public class UrlTokenizerUtil
extends Object

Utility methods to help with url tokenization.


Constructor Summary
UrlTokenizerUtil()
           
 
Method Summary
static List<String> getReversedDomainParts(String host, int numParts)
          Given an url host, tokenizes the host parts by dot, reverses them, and pads (with "") or truncates up to numParts pieces.
static boolean isTLD(String url, boolean reversed)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlTokenizerUtil

public UrlTokenizerUtil()
Method Detail

getReversedDomainParts

public static List<String> getReversedDomainParts(String host,
                                                  int numParts)
Given an url host, tokenizes the host parts by dot, reverses them, and pads (with "") or truncates up to numParts pieces. Truncation happens post token reversal. This method properly accounts for two-part top-level domains as listed at http://www.surbl.org/two-level-tlds as of 05/12/2010. For example, www.twitter.co.uk will be returned as ["co.uk", "twitter", "www"].

Parameters:
host - A url host
numParts - The number of host parts to return.
Returns:
The reversed and tokenized list of host parts from host.

isTLD

public static boolean isTLD(String url,
                            boolean reversed)