Class MaskedBytes
This consists of a pair of byte arrays. One that represents the values, if known, and another that indicates which bits of the values array are actually known.
-
Method Summary
Modifier and TypeMethodDescriptionand(MaskedBytes that) Perform a bitwise andReturns the mask as an unsigned big integer.bigMaskSigned(Endian endian) Returns the mask as a signed big integer.Returns the value as an unsigned big integer.bigValueSigned(Endian endian) Returns the value as a signed big integer.copyOfRange(int start, int stop) Copy a range of the masked bytesbooleanZero out the first bitInvert the first bit, if it is knownbooleanisMasked()Returns true if any portion, even a single bit, of the value is unknown.negate()Invert the known bitsstatic MaskedBytesof(byte[] val, byte[] msk) Construct from arraysstatic MaskedBytesConstruct from longsstatic MaskedBytesof(BigInteger val, BigInteger msk, int length, Endian endian) Construct from big integersstatic MaskedBytesofKnown(byte[] val) Construct from known bytesstatic MaskedBytesofUnknown(int length) Construct completely unknownor(MaskedBytes that) Perform a bitwise orPerform sign extensiontoString()xor(MaskedBytes that) Perform a bitwise xorPerform zero/unsigned extension
-
Method Details
-
of
Construct from arraysThe given arrays are copied, and the mask is applied so that all unknown bits have 0s in the values array.
- Parameters:
val- the value arraymsk- the mask array- Returns:
- the masked bytes
-
of
Construct from big integers- Parameters:
val- the valuemsk- the bits of the value that are knownlength- the size of the value in bytesendian- the endianness of the bytes- Returns:
- the masked bytes
-
of
Construct from longs- Parameters:
val- the valuemsk- the bits of the value that are knownlength- the size of the value in bytesendian- the endianness of the bytes- Returns:
- the masked bytes
-
ofKnown
Construct from known bytesThe resulting mask is all 1s.
- Parameters:
val- the known values- Returns:
- the masked bytes
-
ofUnknown
Construct completely unknownThe contents of both arrays (value and mask) are all 0s
- Parameters:
length- the number of bytes- Returns:
- the masked bytes
-
equals
-
toString
-
isMasked
public boolean isMasked()Returns true if any portion, even a single bit, of the value is unknown.- Returns:
- true if any portion, even a single bit, of the value is unknown
-
bigValue
Returns the value as an unsigned big integer.- Parameters:
endian- the endianness of the bytes- Returns:
- the value as an unsigned big integer
-
bigValueSigned
Returns the value as a signed big integer.- Parameters:
endian- the endianness of the bytes- Returns:
- the value as a signed big integer
-
bigMask
Returns the mask as an unsigned big integer.- Parameters:
endian- the endianness of the bytes- Returns:
- the mask as an unsigned big integer
-
bigMaskSigned
Returns the mask as a signed big integer.- Parameters:
endian- the endianness of the bytes- Returns:
- the mask as a signed big integer
-
negate
-
and
Perform a bitwise andNote that known 0s in either operand cause known 0s in the result, even if the same bit of the other operand was unknown.
- Parameters:
that- the other operand- Returns:
- the result
-
or
Perform a bitwise orNote that known 1s in either operand cause known ss in the result, even if the same bit of the other operand was unknown.
- Parameters:
that- the other operand- Returns:
- the result
-
xor
Perform a bitwise xor- Parameters:
that- the other operand- Returns:
- the result
-
floatAbs
Zero out the first bitThe first bit becomes a known 0 in the result, even if it was unknown.
- Parameters:
endian- the endianness of the bytes- Returns:
- the result
-
floatNeg
Invert the first bit, if it is known- Parameters:
endian- the endianness of the bytes- Returns:
- the result
-
copyOfRange
Copy a range of the masked bytes- Parameters:
start- the first byte to includestop- the last byte, exclusive- Returns:
- the copy
-
sext
Perform sign extensionThe sign bit (known 0, known 1, or unknown) is extended to fill the requested size.
- Parameters:
size- the size in bytes of the resultendian- the endianness of the bytes- Returns:
- the extended masked bytes
-
zext
Perform zero/unsigned extensionKnown 0s fill to the requested size
- Parameters:
size- the size in bytes of the resultendian- the endianness of the bytes- Returns:
- the extended masked bytes
-