Class InetAddressUtils


  • public abstract class InetAddressUtils
    extends Object

    Abstract InetAddressUtils class.

    Version:
    $Id: $
    Author:
    Mathew Brozowski
    • Field Detail

      • NO_DIGITS_AFTER_DECIMAL

        protected static final DecimalFormat NO_DIGITS_AFTER_DECIMAL
        Always print at least one digit after the decimal point, and at most three digits after the decimal point.
      • ONE_DIGIT_AFTER_DECIMAL

        protected static final DecimalFormat ONE_DIGIT_AFTER_DECIMAL
        Print no digits after the decimal point (heh, nor a decimal point).
      • UNPINGABLE_ADDRESS

        public static final InetAddress UNPINGABLE_ADDRESS
      • UNPINGABLE_ADDRESS_IPV6

        public static final InetAddress UNPINGABLE_ADDRESS_IPV6
      • TWO_FIFTY_FIVES

        public static final InetAddress TWO_FIFTY_FIVES
      • ONE_TWENTY_SEVEN

        public static final InetAddress ONE_TWENTY_SEVEN
    • Constructor Detail

      • InetAddressUtils

        public InetAddressUtils()
    • Method Detail

      • getLocalHostAddress

        public static InetAddress getLocalHostAddress()
      • getLocalHostAddressAsString

        public static String getLocalHostAddressAsString()
      • getLocalHostName

        public static String getLocalHostName()
      • getInetAddress

        public static InetAddress getInetAddress​(int[] octets,
                                                 int offset,
                                                 int length)
      • getInetAddress

        public static InetAddress getInetAddress​(byte[] ipAddrOctets)
      • getInetAddress

        public static InetAddress getInetAddress​(String dottedNotation)

        getInetAddress

        Parameters:
        dottedNotation - a String object.
        Returns:
        a InetAddress object.
      • toIpAddrBytes

        public static byte[] toIpAddrBytes​(String dottedNotation)

        toIpAddrBytes

        Parameters:
        dottedNotation - a String object.
        Returns:
        an array of byte.
      • toIpAddrString

        public static String toIpAddrString​(InetAddress addr)

        toIpAddrString

        Parameters:
        addr - IP address
        Returns:
        a String object.
      • toIpAddrString

        public static String toIpAddrString​(byte[] addr)

        toIpAddrString

        Parameters:
        addr - an array of byte.
        Returns:
        a String object.
      • toUrlIpAddress

        public static String toUrlIpAddress​(InetAddress addr)
        Method that wraps IPv6 addresses in square brackets so that they are parsed correctly by the JMXServiceURL class.
      • getLowestInetAddress

        public static InetAddress getLowestInetAddress​(List<InetAddress> addresses)
        Given a list of IP addresses, return the lowest as determined by the numeric representation and not the alphanumeric string.
        Parameters:
        addresses - a List object.
        Returns:
        a InetAddress object.
      • isInetAddressInRange

        public static boolean isInetAddressInRange​(byte[] laddr,
                                                   String beginString,
                                                   String endString)
      • isInetAddressInRange

        public static boolean isInetAddressInRange​(String addrString,
                                                   String beginString,
                                                   String endString)
      • areSameInetAddress

        public static boolean areSameInetAddress​(byte[] leftInetAddr,
                                                 byte[] rightInetAddr)
      • isInetAddressInRange

        public static boolean isInetAddressInRange​(byte[] addr,
                                                   byte[] begin,
                                                   byte[] end)
      • isInetAddressInRange

        public static boolean isInetAddressInRange​(String ipAddr,
                                                   byte[] begin,
                                                   byte[] end)
      • convertCidrToInetAddressV4

        public static InetAddress convertCidrToInetAddressV4​(int cidr)
      • convertCidrToInetAddressV6

        public static InetAddress convertCidrToInetAddressV6​(int cidr)
      • normalize

        public static String normalize​(String ipAddrString)
        This function is used to ensure that an IP address string is in fully-qualified format without any "::" segments for an IPv6 address. FIXME: do we lose
      • macAddressStringToBytes

        public static byte[] macAddressStringToBytes​(String macAddress)
      • macAddressBytesToString

        public static String macAddressBytesToString​(byte[] macAddress)
      • normalizeMacAddress

        public static String normalizeMacAddress​(String macAddress)
      • isValidStpDesignatedPort

        public static boolean isValidStpDesignatedPort​(String bridgeDesignatedPort)
      • getBridgeDesignatedPortNumber

        public static int getBridgeDesignatedPortNumber​(String stpPortDesignatedPort)
      • isValidBridgeAddress

        public static boolean isValidBridgeAddress​(String bridgeAddress)
      • isValidStpBridgeId

        public static boolean isValidStpBridgeId​(String bridgeId)
      • getBridgeAddressFromStpBridgeId

        public static String getBridgeAddressFromStpBridgeId​(String bridgeId)
      • getIpAddressByHexString

        public static InetAddress getIpAddressByHexString​(String ipaddrhexstrng)
      • getHumanReadableIfSpeed

        public static String getHumanReadableIfSpeed​(long ifSpeed)
        Method used to convert an integer bits-per-second value to a more readable vale using commonly recognized abbreviation for network interface speeds. Feel free to expand it as necessary to accommodate different values.
        Parameters:
        ifSpeed - The bits-per-second value to be converted into a string description
        Returns:
        A string representation of the speed ("100 Mbps" for example)