Package org.cyclos.server.utils
Class InternetAddressHelper
- java.lang.Object
-
- org.cyclos.server.utils.InternetAddressHelper
-
public class InternetAddressHelper extends Object
Helper methods for internet addresses
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInternetAddressHelper.AddressTypeThe possible types for an internet address
-
Constructor Summary
Constructors Constructor Description InternetAddressHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisHostname(String address)Checks whether the given address is a valid hostnamestatic booleanisInternetAddressList(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 rangestatic booleanisIpAddress(String address)Checks whether the given address is a valid ip addressstatic booleanisIpRange(String address)Checks whether the given address is a valid ip address range, in the form: A.B.C.D-Estatic Stringnormalize(String address)Normalizes the given ip address.static StringpadAddress(String address)Pads an address, filling with zeroes on the left.static InternetAddressHelper.AddressTyperesolveAddressType(String address)Returns the address type, or null when invalidstatic Set<String>resolveAll(String addressList)Resolves all IP addresses from the given address list, returning them in numeric form.
-
-
-
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
-
resolveAddressType
public static InternetAddressHelper.AddressType resolveAddressType(String address)
Returns the address type, or null when invalid
-
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 seeisIpRange(String). The resulting collection contains all resolved ip addresses.
-
-