- java.lang.Object
-
- inet.ipaddr.format.AddressDivisionBase
-
- All Implemented Interfaces:
AddressGenericDivision
,AddressItem
,AddressStringDivision
,java.io.Serializable
,java.lang.Comparable<AddressItem>
- Direct Known Subclasses:
AddressDivision
,IPAddressLargeDivision
public abstract class AddressDivisionBase extends java.lang.Object implements AddressGenericDivision
Base class for address divisions.- Author:
- sfoley
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static char[]
EXTENDED_DIGITS
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
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.byte[]
getBytes()
Gets the bytes for the lowest address in the range represented by this address division.byte[]
getBytes(byte[] bytes)
Equivalent togetBytes(byte[], int)
with index of 0.byte[]
getBytes(byte[] bytes, int index)
Gets the value for the lowest address in the range represented by this address division.static int
getDigitCount(long value, int radix)
static int
getDigitCount(java.math.BigInteger val, java.math.BigInteger radix)
int
getLowerStandardString(int segmentIndex, AddressSegmentParams params, java.lang.StringBuilder appendable)
Configures a segment string according to the given params and the given segment index, but using only the lower value of the segment range, if there is a range.int
getStandardString(int segmentIndex, AddressSegmentParams params, java.lang.StringBuilder appendable)
Produces a string to represent the segment, using wildcards and range characters.byte[]
getUpperBytes()
byte[]
getUpperBytes(byte[] bytes)
Copies the bytes of the largest address item represented by this address item into the supplied array, and returns that array.byte[]
getUpperBytes(byte[] bytes, int index)
Copies the bytes of the largest address item represented by this address item into the supplied array at the given index, and returns that array.int
hashCode()
java.lang.String
toString()
-
Methods inherited from interface inet.ipaddr.format.AddressItem
compareTo, containsPrefixBlock, containsSinglePrefixBlock, getBitCount, getByteCount, getCount, getMinPrefixLengthForBlock, getPrefixCount, getPrefixLengthForSingleBlock, getUpperValue, getValue, includesMax, includesZero, isFullRange, isMax, isMultiple, isZero
-
Methods inherited from interface inet.ipaddr.format.string.AddressStringDivision
getDigitCount, getMaxDigitCount, isBoundedBy
-
-
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
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.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getBytes
public byte[] getBytes()
Gets the bytes for the lowest address in the range represented by this address division.Since bytes are signed values while addresses are unsigned, values greater than 127 are represented as the (negative) two's complement value of the actual value. You can get the unsigned integer value i from byte b using i = 0xff & b.
- Specified by:
getBytes
in interfaceAddressItem
- Returns:
-
getBytes
public byte[] getBytes(byte[] bytes, int index)
Gets the value for the lowest address in the range represented by this address division.If the value fits in the specified array at the specified index, the same array is returned with the value copied at the specified index. Otherwise, a new array is allocated and returned with the value copied at the specified index, and the rest of the array contents the same as the original.
You can use
AddressItem.getBitCount()
to determine the required array length for the bytes.Since bytes are signed values while addresses are unsigned, values greater than 127 are represented as the (negative) two's complement value of the actual value. You can get the unsigned integer value i from byte b using i = 0xff & b.
- Specified by:
getBytes
in interfaceAddressItem
- Returns:
-
getBytes
public byte[] getBytes(byte[] bytes)
Equivalent togetBytes(byte[], int)
with index of 0.- Specified by:
getBytes
in interfaceAddressItem
- Returns:
- the bytes of the lowest address represented by this address item.
-
getUpperBytes
public byte[] getUpperBytes()
- Specified by:
getUpperBytes
in interfaceAddressItem
- Returns:
- the bytes of the largest address item represented by this address item
-
getUpperBytes
public byte[] getUpperBytes(byte[] bytes, int index)
Description copied from interface:AddressItem
Copies the bytes of the largest address item represented by this address item into the supplied array at the given index, and returns that array. If the supplied array is null or of insufficient size, a new array is created and returned.- Specified by:
getUpperBytes
in interfaceAddressItem
- Returns:
- the bytes of the largest address represented by this address item.
-
getUpperBytes
public byte[] getUpperBytes(byte[] bytes)
Description copied from interface:AddressItem
Copies the bytes of the largest address item represented by this address item into the supplied array, and returns that array. If the supplied array is null or of insufficient size, a new array is created and returned, with the rest of the array contents the same as the original.- Specified by:
getUpperBytes
in interfaceAddressItem
- Returns:
- the bytes of the largest address represented by this address item.
-
getDigitCount
public static int getDigitCount(java.math.BigInteger val, java.math.BigInteger radix)
-
getDigitCount
public static int getDigitCount(long value, int radix)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getLowerStandardString
public int getLowerStandardString(int segmentIndex, AddressSegmentParams params, java.lang.StringBuilder appendable)
Description copied from interface:AddressStringDivision
Configures a segment string according to the given params and the given segment index, but using only the lower value of the segment range, if there is a range.If appendable is null, simply returns the length of the string that would have been appended.
- Specified by:
getLowerStandardString
in interfaceAddressStringDivision
- Returns:
-
getStandardString
public int getStandardString(int segmentIndex, AddressSegmentParams params, java.lang.StringBuilder appendable)
Produces a string to represent the segment, using wildcards and range characters. Use this instead of getWildcardString() if you have a customized wildcard or range separator or you have a non-zero leadingZeroCount, or you have a non-standard radix (for IPv4 standard radix is 10, for IPv6 it is 16)- Specified by:
getStandardString
in interfaceAddressStringDivision
- Returns:
-
-