- All Implemented Interfaces:
java.io.Serializable
- Enclosing class:
- ParsedIPAddress
public static class ParsedIPAddress.SpecificValueMasker
extends ParsedIPAddress.Masker
When the part of a mask covering a range of values is a mix of ones and zeros,
then there may be an intermediate value in the range that when masked, produces the new
upper and lower values.
For instance, consider the simple range 2 to 5 with mask of 2.
The value when masked to give the lowest masked value is not the lowest in the range 2, it is 5. Masking 5 with 2 gives 0.
The value when masked to give the highest masked value is not the highest in the range 5, it is 2. Masking 2 with 2 gives 2.
When the mask has a 0 in the highest bit in the range of values, then the two values that give the highest and lowest are
0000... and 1111.... This is because in any range 0xxxx to 1xxxx, the values 01111 and 10000 are in the range (they must be there
to get from 0xxxx to 1xxxx. And so if you ignore the top bit, the values 0000 and 1111 always give you the lowest and highest.
In this case, FullRangeMasker can be used instead of this class. For instance, you can use the values 011 to 100 (ie 3 and 4)
to get the ranged values 2 and 0 in the example above.
However, when the mask has a 1 bit to match the highest bit in the range of values, you cannot use 01111... and 10000...
In such cases, there are other values that when masked produce the new lowest and highest.
For example, with the range 1 (001) to 6 (110) and the mask of 5 (101),
the lowest value when masked is 2 (010) to give 0,
and the highest value when masked is 5 (101), to give masked value of 5.
Neither of these values are the range boundaries 1 or 6. Neither of these values is all ones or all zeros.
This situation can occur when the mask itself is not all ones or all zeros, and when the highest bit in the range (the 3rd bit, ie 100 in the example)
has a corresponding value of 1 in the given mask (101 in the example).
- Author:
- seancfoley
- See Also:
- Serialized Form