org.apache.lenya.net
Class InetAddressUtil

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.lenya.net.InetAddressUtil
All Implemented Interfaces:
org.apache.avalon.framework.logger.LogEnabled

public class InetAddressUtil
extends org.apache.avalon.framework.logger.AbstractLogEnabled

A utility class for InetAddress. Also see http://jodies.de/ipcalc


Constructor Summary
InetAddressUtil(org.apache.avalon.framework.logger.Logger logger)
          Ctor.
 
Method Summary
 int checkNetmask(java.net.InetAddress netmask)
          Deprecated. This was an internal implementation detail of the method contains(java.net.InetAddress, java.net.InetAddress, java.net.InetAddress) and should never have been made public. Furthermore it's broken for IPv6. (However, there is no real replacement. If you need this functionality, you should rewrite it yourself.)
 boolean contains(java.net.InetAddress network, java.net.InetAddress netmask, java.net.InetAddress ip)
          Checks if a subnet contains a specific IP address.
static java.net.InetAddress getAddress(java.lang.String string)
          Deprecated. This was an internal implementation detail of the method contains(java.net.InetAddress, java.net.InetAddress, java.net.InetAddress) and should never have been made public. (And it's unnecessary too, as well as broken for IPv6. ;-) Use InetAddress.getByName(string) instead.
static int getClassPart(java.net.InetAddress ip, int partNumber)
          Deprecated. This was an internal implementation detail of the method contains(java.net.InetAddress, java.net.InetAddress, java.net.InetAddress) and should never have been made public. (And it's inefficient and unnecessary too, as well as broken for IPv6. ;-) Use ip.getAddress()[partNumber] instead.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InetAddressUtil

public InetAddressUtil(org.apache.avalon.framework.logger.Logger logger)
Ctor.

Parameters:
logger - The logger.
Method Detail

contains

public boolean contains(java.net.InetAddress network,
                        java.net.InetAddress netmask,
                        java.net.InetAddress ip)
Checks if a subnet contains a specific IP address.

Parameters:
network - The network address.
netmask - The subnet mask.
ip - The IP address to check.
Returns:
A boolean value.

getClassPart

public static int getClassPart(java.net.InetAddress ip,
                               int partNumber)
Deprecated. This was an internal implementation detail of the method contains(java.net.InetAddress, java.net.InetAddress, java.net.InetAddress) and should never have been made public. (And it's inefficient and unnecessary too, as well as broken for IPv6. ;-) Use ip.getAddress()[partNumber] instead.

Returns the n-th part of an InetAddress.

Parameters:
ip - The address.
partNumber - The number of the part.
Returns:
An integer value.

checkNetmask

public int checkNetmask(java.net.InetAddress netmask)
Deprecated. This was an internal implementation detail of the method contains(java.net.InetAddress, java.net.InetAddress, java.net.InetAddress) and should never have been made public. Furthermore it's broken for IPv6. (However, there is no real replacement. If you need this functionality, you should rewrite it yourself.)

Check netmask, e.g. 255.255.255.240 is fine, 255.255.240.16 is illegal (needs to be 255.255.240.0)

Parameters:
netmask - The netmask address.
Returns:
An integer value. -1 if illegal netmask, otherwise 0, 1, 2, 3

getAddress

public static java.net.InetAddress getAddress(java.lang.String string)
                                       throws java.net.UnknownHostException
Deprecated. This was an internal implementation detail of the method contains(java.net.InetAddress, java.net.InetAddress, java.net.InetAddress) and should never have been made public. (And it's unnecessary too, as well as broken for IPv6. ;-) Use InetAddress.getByName(string) instead.

Converts a string to an IP addres.

Parameters:
string - The IP address, represented by a string.
Returns:
An InetAddress object.
Throws:
java.net.UnknownHostException


Copyright © 1999-2006 Apache Software Foundation. All Rights Reserved.