Class IPAddr

java.lang.Object
org.apache.james.jspf.core.IPAddr

public class IPAddr extends Object
  • Method Details

    • getAddress

      public static IPAddr getAddress(String netAddress, int maskLength) throws PermErrorException
      Get ipAddress for the given String and netmask
      Parameters:
      netAddress - The ipAddress given as String
      maskLength - The netmask
      Returns:
      IpAddress AAn Arraylist which contains all ipAddresses
      Throws:
      PermErrorException - on error
    • getAddress

      public static IPAddr getAddress(String netAddress) throws PermErrorException
      Throws:
      PermErrorException
      See Also:
    • isIPAddr

      public static boolean isIPAddr(String data)
      Check if a the Object is instance of this class
      Parameters:
      data - The object to check
      Returns:
      true or false
    • setMask

      public void setMask(int maskLength)
      create series of 16 bit masks for each ip block
      Parameters:
      maskLength - The netmask
    • stripDot

      public static String stripDot(String data)
      Strip the last char of a string when it ends with a dot
      Parameters:
      data - The String where the dot should removed
      Returns:
      modified The Given String with last char stripped
    • getIPAddress

      public String getIPAddress()
      See Also:
    • getMaskedIPAddress

      public String getMaskedIPAddress()
      See Also:
      • getIPAddress(int[])
    • getNibbleFormat

      public String getNibbleFormat()
      Return the NibbleFormat of the IPAddr
      Returns:
      ipAddress The ipAddress in nibbleFormat
    • getReverseIP

      public String getReverseIP()
      Get reverse ipAddress
      Returns:
      reverse ipAddress
    • getMaskLength

      public int getMaskLength()
      Get mask length
      Returns:
      maskLength
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getInAddress

      public static String getInAddress(String ipAddress) throws PermErrorException
      This method return the InAddress for the given ip.
      Parameters:
      ipAddress - - ipAddress that should be processed
      Returns:
      the inAddress (in-addr or ip6)
      Throws:
      PermErrorException - if the ipAddress is not valid (rfc conform)
    • isValidIP

      public static boolean isValidIP(String ip)
      Check if the given IP is valid. Works with ipv4 and ip6
      Parameters:
      ip - The ipaddress to check
      Returns:
      true or false
    • isIPV6

      public static boolean isIPV6(String ip)
      Return if the given ipAddress is ipv6
      Parameters:
      ip - The ipAddress
      Returns:
      true or false
    • getReadableIP

      public static String getReadableIP(String ip)
      This method try to covnert an ip address to an easy readable ip. See http://java.sun.com/j2se/1.4.2/docs/api/java/net/Inet6Address.html for the format it returns. For ipv4 it make no convertion
      Parameters:
      ip - The ip which should be tried to convert
      Returns:
      ip The converted ip
    • getProperIpAddress

      public static String getProperIpAddress(String ip) throws PermErrorException
      This method convert the given ip to the proper format. Convertion will only done if the given ipAddress is ipv6 and ipv4-mapped This must be done to correct handle IPv4-mapped-addresses. See: http://java.sun.com/j2se/1.4.2/docs/api/java/net/Inet6Address.html Special IPv6 address: IPv4-mapped address: Of the form::ffff:w.x.y.z, this IPv6 address is used to represent an IPv4 address. It allows the native program to use the same address data structure and also the same socket when communicating with both IPv4 and IPv6 nodes. In InetAddress and Inet6Address, it is used for internal representation; it has no functional role. Java will never return an IPv4-mapped address. These classes can take an IPv4-mapped address as input, both in byte array and text representation. However, it will be converted into an IPv4 address.
      Parameters:
      ip - the ipAddress to convert
      Returns:
      return converted ip
      Throws:
      PermErrorException - if the given ipAddress is invalid