Class InternetAddressHelper


  • public class InternetAddressHelper
    extends Object
    Helper methods for internet addresses
    • Constructor Detail

      • InternetAddressHelper

        public InternetAddressHelper()
    • Method Detail

      • isHostname

        public static boolean isHostname​(String address)
        Checks whether the given address is a valid hostname
      • isInternetAddressList

        public static boolean isInternetAddressList​(String addresses)
        Returns whether the given string is a valid ip address list, that is, a newline-separated string where blank lines or lines starting with # are ignored, and others should either be a hostname, an IP address or a IP range
      • isIpAddress

        public static boolean isIpAddress​(String address)
        Checks whether the given address is a valid ip address
      • isIpRange

        public static boolean isIpRange​(String address)
        Checks whether the given address is a valid ip address range, in the form: A.B.C.D-E
      • normalize

        public static String normalize​(String address)
        Normalizes the given ip address. For example, 192.168.001.010 returns 192.168.1.10
      • padAddress

        public static String padAddress​(String address)
        Pads an address, filling with zeroes on the left. Example: 1.2.30.100 becomes 001.002.030.100
      • resolveAll

        public static Set<String> resolveAll​(String addressList)
        Resolves all IP addresses from the given address list, returning them in numeric form. The list is expected to be separated by line breaks. Lines are trimmed. Lines beginning with # are ignored. Each line may be an ip address, a hostname or an ip address range see isIpRange(String). The resulting collection contains all resolved ip addresses.