Module inet.ipaddr

Class MACAddressSegment

    • Constructor Detail

      • MACAddressSegment

        public MACAddressSegment​(int value)
        Constructs a segment of an IPv4 or IPv6 address with the given value.
        Parameters:
        value - the value of the segment
        Throws:
        AddressValueException - if value is negative or too large
      • MACAddressSegment

        public MACAddressSegment​(int lower,
                                 int upper)
        Constructs a segment of a MAC address that represents a range of values.
        Parameters:
        lower - the lower value of the range of values represented by the segment.
        upper - the upper value of the range of values represented by the segment.
        Throws:
        AddressValueException - if value is negative or too large
    • Method Detail

      • getBitCount

        public int getBitCount()
        Description copied from interface: AddressItem
        Provides the number of bits comprising this address item
        Specified by:
        getBitCount in interface AddressItem
        Returns:
        the number of bits
      • getByteCount

        public int getByteCount()
        Description copied from interface: AddressItem
        Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8
        Specified by:
        getByteCount in interface AddressItem
        Returns:
        the number of bytes
      • reverseBits

        public MACAddressSegment reverseBits​(boolean perByte)
        Description copied from interface: AddressComponent
        Returns a new AddressComponent with the bits reversed. If this component represents a range of values that cannot be reversed, then this throws IncompatibleAddressException. In a range the most significant bits stay constant while the least significant bits range over different values, so reversing that scenario results in a series of non-consecutive values, in most cases, which cannot be represented with a single AddressComponent object.

        In such cases where isMultiple() is true, call iterator(), getLower(), getUpper() or some other methods to break the series down into a series representing a single value.

        Specified by:
        reverseBits in interface AddressComponent
        Specified by:
        reverseBits in interface AddressSegment
        Parameters:
        perByte - if true, only the bits in each byte are reversed, if false, then all bits in the component are reversed
        Returns:
      • reverseBytes

        public MACAddressSegment reverseBytes()
        Description copied from interface: AddressComponent
        Returns an AddressComponent with the bytes reversed. If this component represents a range of values that cannot be reversed, then this throws IncompatibleAddressException. In a range the most significant bits stay constant while the least significant bits range over different values, so reversing that scenario results in a series of non-consecutive values, in most cases, which cannot be represented with a single AddressComponent object.

        In such cases where isMultiple() is true, call iterator(), getLower(), getUpper() or some other methods to break the series down into a series representing a single value.

        Specified by:
        reverseBytes in interface AddressComponent
        Specified by:
        reverseBytes in interface AddressSegment
        Returns:
      • equals

        public boolean equals​(java.lang.Object other)
        Description copied from class: AddressDivisionBase
        Two divisions are equal if they: - they match type/version (ipv4, ipv6, mac, or a specific division class) - match bit counts - match values Prefix lengths, for those divisions that have them, are ignored.
        Specified by:
        equals in interface AddressSegment
        Overrides:
        equals in class AddressDivision
      • contains

        public boolean contains​(MACAddressSegment other)
        Parameters:
        other -
        Returns:
        whether this subnet segment contains the given address segment
      • getDefaultTextualRadix

        public int getDefaultTextualRadix()
      • getMaxDigitCount

        public int getMaxDigitCount()
      • matchesWithMask

        public boolean matchesWithMask​(int lowerValue,
                                       int upperValue,
                                       int mask)
        Specified by:
        matchesWithMask in interface AddressSegment
      • prefixEquals

        public boolean prefixEquals​(AddressSegment o,
                                    int segmentPrefixLength)
        Description copied from interface: AddressSegment
        Returns whether the given prefix bits match the same bits of the given segment.
        Specified by:
        prefixEquals in interface AddressSegment
        Returns:
      • toHexString

        public java.lang.String toHexString​(boolean with0xPrefix)
        Description copied from interface: AddressComponent
        Writes this address component as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.

        If this component represents a range of values outside of the network prefix length, then this is printed as a range of two hex values.

        For instance, for IPv4 addresses there are 8 hex characters, for IPv6 addresses there are 32 hex characters.

        Specified by:
        toHexString in interface AddressComponent
      • containsPrefixBlock

        public boolean containsPrefixBlock​(int divisionPrefixLen)
        Description copied from interface: AddressItem
        Returns whether the values of this series contains the prefix block for the given prefix length.

        Use AddressItem.getMinPrefixLengthForBlock() to determine the smallest prefix length for which this method returns true.

        Specified by:
        containsPrefixBlock in interface AddressItem
        Returns:
        whether the division range includes the block of values for the given prefix length
      • containsSinglePrefixBlock

        public boolean containsSinglePrefixBlock​(int divisionPrefixLen)
        Returns whether the division range matches exactly the block of values for the given prefix length.
        Specified by:
        containsSinglePrefixBlock in interface AddressItem
        Parameters:
        divisionPrefixLen -
        Returns:
        whether the range of this division matches the range for a single prefix with a single value and the given prefix length.