/**
* <p>
* Validates whether the character is possible in the context of the set of possible base 64 values.
* </p>
*
* @param numBits number of least significant bits to check
* @param context the context to be used
*
* @throws IllegalArgumentException if the bits being checked contain any non-zero value
*/
private long validateCharacter(final int numBitsToDrop, final Context context) {
i**f ((context.ibitWorkArea & numBitsToDrop) != 0)** {
throw new IllegalArgumentException(
"Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible value");
}
return context.ibitWorkArea >> numBitsToDrop;
}
我很疑惑的地方是:验证结尾两个或四个比特为0,不应该是&3 或者 &15吗?详细的代码不再贴了,有能解惑的大神先行拜谢了。
问题解决参见:问题解决结果