org.apache.james.util.inetnetwork
Class InetNetworkBuilder

java.lang.Object
  extended by org.apache.james.util.inetnetwork.InetNetworkBuilder

public class InetNetworkBuilder
extends java.lang.Object

Builds a InetNetwork (Inet4Network or Inet6Network) in function on the provided string pattern that represents a subnet. Inet4Network is constructed based on the IPv4 subnet expressed in one of several formats: IPv4 Format Example Explicit address 127.0.0.1 Address with a wildcard 127.0.0.* Domain name myHost.com Domain name + prefix-length myHost.com/24 Domain name + mask myHost.com/255.255.255.0 IP address + prefix-length 127.0.0.0/8 IP + mask 127.0.0.0/255.0.0.0 For more information on IP V4, see RFC 1518 and RFC 1519. Inet6Network is constructed based on the IPv4 subnet expressed in one of several formats: IPv6 Format Example Explicit address 0000:0000:0000:0000:0000:0000:0000:0001 IP address + subnet mask (/) 0000:0000:0000:0000:0000:0000:0000:0001/64 IP address + subnet mask (%) 0000:0000:0000:0000:0000:0000:0000:0001%64 The following V6 formats will be supported later: Domain name myHost.com Domain name + mask (/) myHost.com/48 Domain name + mask (%) myHost.com%48 Explicit shorted address ::1 For more information on IP V6, see RFC 2460. (see also http://en.wikipedia.org/wiki/IPv6_address)


Constructor Summary
InetNetworkBuilder(DNSService dnsServer)
          Constructs a InetNetwork.
 
Method Summary
 InetNetwork getFromString(java.lang.String netspec)
          Creates a InetNetwork for the given String.
static boolean isV6(java.lang.String netspec)
          Returns true if the string parameters is a IPv6 pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InetNetworkBuilder

public InetNetworkBuilder(DNSService dnsServer)
Constructs a InetNetwork.

Parameters:
dnsServer - the DNSService to use
Method Detail

getFromString

public InetNetwork getFromString(java.lang.String netspec)
                          throws java.net.UnknownHostException
Creates a InetNetwork for the given String. Depending on the provided pattern and the platform configuration (IPv4 and/or IPv6), the returned type will be Inet4Network or Inet6Network.

Parameters:
netspec - the String which is will converted to InetNetwork
Returns:
network the InetNetwork
Throws:
java.net.UnknownHostException

isV6

public static boolean isV6(java.lang.String netspec)
Returns true if the string parameters is a IPv6 pattern. Currently, only tests for presence of ':'.

Parameters:
address -
Returns:
boolean


Copyright © 2002-2010 The Apache Software Foundation. All Rights Reserved.