dk.netarkivet.harvester.datamodel
Class TLDInfo

java.lang.Object
  extended by dk.netarkivet.harvester.datamodel.TLDInfo
All Implemented Interfaces:
java.lang.Comparable<TLDInfo>

public class TLDInfo
extends java.lang.Object
implements java.lang.Comparable<TLDInfo>

A container for miscellaneous information about a TLD. Currently contains the TLD name and a count of subdomains.


Field Summary
(package private) static java.lang.String IP_ADDRESS_NAME
          The special name for IP adresses, since they have no TLD.
 
Constructor Summary
TLDInfo(java.lang.String name)
          Create TLD info holder.
 
Method Summary
(package private)  void addSubdomain(java.lang.String name)
          Add a 2nd-level domain to the information for this domain.
 int compareTo(TLDInfo o)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object o)
           
 int getCount()
          Number of subdomains we have registered under this TLD.
(package private) static java.lang.String getMultiLevelTLD(java.lang.String domain, int maxLevel)
          Get the TLD for a given domain including multilevel TLD.
 java.lang.String getName()
          The name of this TLD (e.g.
(package private) static java.lang.String getTLD(java.lang.String domain)
          Get the TLD for a given domain.
(package private) static int getTLDLevel(java.lang.String domain)
          Return TLD level of the domain.
 int hashCode()
           
 boolean isIP()
          True if this TLDinfo accumulates IP address information.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IP_ADDRESS_NAME

static final java.lang.String IP_ADDRESS_NAME
The special name for IP adresses, since they have no TLD.

See Also:
Constant Field Values
Constructor Detail

TLDInfo

public TLDInfo(java.lang.String name)
Create TLD info holder.

Parameters:
name - The TLD domain name.
Method Detail

getName

public java.lang.String getName()
The name of this TLD (e.g. dk, com or museum). IP addresses are registered under a special "IP address" name.

Returns:
TLD name without .

getCount

public int getCount()
Number of subdomains we have registered under this TLD. All IP addresses are lumped together as one TLD.

Returns:
Number of 2nd-level domains we have registered under this TLD.

addSubdomain

void addSubdomain(java.lang.String name)
Add a 2nd-level domain to the information for this domain. This tests that the given domain does in fact belong to this TLD, but not whether it has been added before.

Parameters:
name - A name of a domain

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode for this object which is equal to the hashCode for the name of the tld.
See Also:
Object.hashCode()

compareTo

public int compareTo(TLDInfo o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable<TLDInfo>
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
See Also:
Comparable.compareTo(Object o)

getTLD

static java.lang.String getTLD(java.lang.String domain)
Get the TLD for a given domain.

Parameters:
domain - A domain, as specified by the global domain regexp.
Returns:
The TLD of the domain, or a special placeholder for IP addresses.

getMultiLevelTLD

static java.lang.String getMultiLevelTLD(java.lang.String domain,
                                         int maxLevel)
Get the TLD for a given domain including multilevel TLD. for example .gouv.fr is level 2 TLD

Parameters:
domain - A domain, as specified by the global domain regexp.
maxLevel - maximum level for TLD (can't be 0).
Returns:
The TLD of the domain, or a special placeholder for IP addresses.

getTLDLevel

static int getTLDLevel(java.lang.String domain)
Return TLD level of the domain.

Parameters:
domain - A domain
Returns:
TLD level of the domain 1 for IP addresses

isIP

public boolean isIP()
True if this TLDinfo accumulates IP address information.

Returns:
True if the domains counted in the TLDinfo are IP domains.