Package org.apache.james.jspf.core
Class IPAddr
java.lang.Object
org.apache.james.jspf.core.IPAddr
-
Method Summary
Modifier and TypeMethodDescriptionstatic IPAddr
getAddress
(String netAddress) static IPAddr
getAddress
(String netAddress, int maskLength) Get ipAddress for the given String and netmaskstatic String
getInAddress
(String ipAddress) This method return the InAddress for the given ip.int
Get mask lengthReturn the NibbleFormat of the IPAddrstatic String
This method convert the given ip to the proper format.static String
getReadableIP
(String ip) This method try to covnert an ip address to an easy readable ip.Get reverse ipAddressstatic boolean
Check if a the Object is instance of this classstatic boolean
Return if the given ipAddress is ipv6static boolean
Check if the given IP is valid.void
setMask
(int maskLength) create series of 16 bit masks for each ip blockstatic String
Strip the last char of a string when it ends with a dottoString()
-
Method Details
-
getAddress
Get ipAddress for the given String and netmask- Parameters:
netAddress
- The ipAddress given as StringmaskLength
- The netmask- Returns:
- IpAddress AAn Arraylist which contains all ipAddresses
- Throws:
PermErrorException
- on error
-
getAddress
- Throws:
PermErrorException
- See Also:
-
isIPAddr
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
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
- See Also:
-
getMaskedIPAddress
- See Also:
-
getNibbleFormat
Return the NibbleFormat of the IPAddr- Returns:
- ipAddress The ipAddress in nibbleFormat
-
getReverseIP
Get reverse ipAddress- Returns:
- reverse ipAddress
-
getMaskLength
public int getMaskLength()Get mask length- Returns:
- maskLength
-
toString
-
getInAddress
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
Check if the given IP is valid. Works with ipv4 and ip6- Parameters:
ip
- The ipaddress to check- Returns:
- true or false
-
isIPV6
Return if the given ipAddress is ipv6- Parameters:
ip
- The ipAddress- Returns:
- true or false
-
getReadableIP
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
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
-