org.apache.commons.ssl.util

## Class IPAddressParser

- java.lang.Object
- - org.apache.commons.ssl.util.IPAddressParser

    public class IPAddressParser
    extends java.lang.Object

Parses String representations of IPv4 and IPv6 addresses, and converts them to byte[]. Returns null if the supplied String is not a valid IP address.

IPv6 addresses are allowed to include square brackets (e.g., "[::a:b:c:d]"), but IPv4 addresses are not. This is to help in situation where an IPv6 literal address is encoded directly inside a URL (the square brackets allow the web client to separate the IPv6 address from its port, since the colon character is overloaded in that context).

### Constructor Summary

Constructors
Constructor and Description
`IPAddressParser()`

### Method Summary

Methods
`private static java.lang.String` `b2s(byte b)`
`private static java.lang.String` `ip4ToHex(byte[] b)`
`static byte[]` `parseIPv4Literal(java.lang.String s)` Converts the supplied IPv4 literal to byte[], or null if the IPv4 address was invalid.
`static byte[]` `parseIPv6Literal(java.lang.String s)` Converts the supplied IPv6 literal to byte[], or null if the IPv6 address was invalid.
`private static java.lang.String` `prependZeroes(java.lang.String s)`
`private static java.lang.String[]` `splitOnColon(java.lang.String s)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### IPAddressParser

    public IPAddressParser()

### Method Detail

#### parseIPv4Literal

    public static byte[] parseIPv4Literal(java.lang.String s)

Converts the supplied IPv4 literal to byte[], or null if the IPv4 address was invalid.

Parameters:
  `s` - Literal IPv4 address.
Returns:
  byte[] array or null if the supplied IPv4 address was invalid.

#### parseIPv6Literal

    public static byte[] parseIPv6Literal(java.lang.String s)

Converts the supplied IPv6 literal to byte[], or null if the IPv6 address was invalid.

Parameters:
  `s` - Literal IPv6 address.
Returns:
  byte[] array or null if the supplied IPv6 address was invalid.

#### prependZeroes

    private static java.lang.String prependZeroes(java.lang.String s)

#### splitOnColon

    private static java.lang.String[] splitOnColon(java.lang.String s)

#### ip4ToHex

    private static java.lang.String ip4ToHex(byte[] b)

#### b2s

    private static java.lang.String b2s(byte b)