Interface Mask

All Known Implementing Classes:
MaskImpl

public interface Mask
The Mask class is used to perform some basic bit tests on an array of bits.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    applyMask(byte[] cde, byte[] results)
    Apply the mask to a byte array.
    void
    applyMask(byte[] cde, int cdeOffset, byte[] results, int resultsOffset)
    Apply the mask to a byte array.
    byte[]
    Apply the mask to a memory buffer.
    byte[]
    complementMask(byte[] msk, byte[] results)
    applies the complement of the mask to the given byte array.
    boolean
    equalMaskedValue(byte[] cde, byte[] target)
    Tests if the results of apply the mask to the given array matches a target array.
    boolean
    equals(byte[] mask)
    Check if the mask represented by the byte array is equal to this one.
    boolean
    Test if the given object is equal to this object.
    byte[]
    Returns the bytes that make up this mask.
    boolean
    subMask(byte[] msk)
    Tests if the given mask matches the this mask for the first n bytes, where n is the size of the given mask.
  • Method Details

    • equals

      boolean equals(Object obj)
      Test if the given object is equal to this object. Two masks are equal if they have exactly the same values in thier byte arrays.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to be tested for equals
      Returns:
      true if the object is equal to this mask, false otherwise.
    • equals

      boolean equals(byte[] mask)
      Check if the mask represented by the byte array is equal to this one.
      Parameters:
      mask - mask represented as byte array
      Returns:
      true if the masks are the same, false otherwise
    • applyMask

      byte[] applyMask(byte[] cde, byte[] results) throws IncompatibleMaskException
      Apply the mask to a byte array.
      Parameters:
      cde - the array that contains the values to be masked
      results - the array to contain the results.
      Returns:
      the resulting byte array.
      Throws:
      IncompatibleMaskException - thrown if byte arrays are not of the correct size
    • applyMask

      void applyMask(byte[] cde, int cdeOffset, byte[] results, int resultsOffset) throws IncompatibleMaskException
      Apply the mask to a byte array.
      Parameters:
      cde - the array that contains the values to be masked
      cdeOffset - the offset into the array that contains the values to be masked
      results - the array to contain the results.
      resultsOffset - the offset into the array that contains the results
      Throws:
      IncompatibleMaskException - thrown if byte arrays are not of the correct size
    • applyMask

      byte[] applyMask(MemBuffer buffer) throws MemoryAccessException
      Apply the mask to a memory buffer.
      Parameters:
      buffer - the memory buffer that contains the values to be masked
      Returns:
      the resulting masked byte array.
      Throws:
      MemoryAccessException - thrown if mask exceeds the available data within buffer
    • equalMaskedValue

      boolean equalMaskedValue(byte[] cde, byte[] target) throws IncompatibleMaskException
      Tests if the results of apply the mask to the given array matches a target array.
      Parameters:
      cde - the source bytes.
      target - the result bytes to be tested.
      Returns:
      true if the target array is equal to the source array with the mask applied.
      Throws:
      IncompatibleMaskException - thrown if byte arrays are not of the correct size
    • complementMask

      byte[] complementMask(byte[] msk, byte[] results) throws IncompatibleMaskException
      applies the complement of the mask to the given byte array.
      Parameters:
      msk - the bytes to apply the inverted mask.
      results - the array for storing the results.
      Returns:
      the results array.
      Throws:
      IncompatibleMaskException - thrown if byte arrays are not of the correct size
    • subMask

      boolean subMask(byte[] msk) throws IncompatibleMaskException
      Tests if the given mask matches the this mask for the first n bytes, where n is the size of the given mask.
      Parameters:
      msk - the bytes to be tested to see if they match the first bytes of this mask.
      Returns:
      true if the bytes match up to the length of the passed in byte array.
      Throws:
      IncompatibleMaskException - thrown if byte arrays are not of the correct size
    • getBytes

      byte[] getBytes()
      Returns the bytes that make up this mask.