inet.ipaddr.mac

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
      • 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.
    • Method Detail

      • getBitCount

        public int getBitCount()
        Specified by:
        getBitCount in interface AddressItem
        Returns:
        the number of bits in this item
      • getByteCount

        public int getByteCount()
        Description copied from interface: AddressComponent
        returns the number of bytes in each of the address components represented by this instance
        Specified by:
        getByteCount in interface AddressComponent
        Returns:
      • 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 AddressTypeException. 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 AddressTypeException. 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:
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals(java.lang.Object other)
        Specified by:
        equals in interface AddressSegment
        Overrides:
        equals in class java.lang.Object
      • contains

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

        public boolean isFullRange()
        Specified by:
        isFullRange in interface AddressItem
        Overrides:
        isFullRange in class AddressDivision
        Returns:
        whether this address item represents all possible values attainable by an address item of this type.
      • getDefaultTextualRadix

        public int getDefaultTextualRadix()
        Specified by:
        getDefaultTextualRadix in class AddressDivisionBase
        Returns:
        the default radix for textual representations of addresses (10 for IPv4, 16 for IPv6)
      • getMaxDigitCount

        public int getMaxDigitCount()
        Specified by:
        getMaxDigitCount in class AddressDivisionBase
        Returns:
        the number of digits for the maximum possible value of the division when using the default radix
      • iterator

        public java.util.Iterator<MACAddressSegment> iterator()
        Description copied from interface: AddressComponent
        An address component can represent a single segment, address, or section, or it can represent multiple, typically a subnet or range of segment, address, or section values. Call AddressItem.isMultiple() to determine if this instance represents multiple. This method iterates through the individual elements.
        Specified by:
        iterator in interface AddressComponent
        Specified by:
        iterator in interface AddressSegment
        Specified by:
        iterator in interface java.lang.Iterable<MACAddressSegment>
      • 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 section represents a range of values outside of the network prefix length, then this is printed as a range of two hex values.
        Specified by:
        toHexString in interface AddressComponent
      • toNormalizedString

        public java.lang.String toNormalizedString()
        Description copied from interface: AddressComponent
        Produces a string that is somewhat similar for all address components of the same type.
        Specified by:
        toNormalizedString in interface AddressComponent
        Returns: