Class MemoryByte


  • public class MemoryByte
    extends Object
    A byte of memory in a memory block. Each byte of memory has a value and attributes indicating if the byte is read-only, valid, or if its value has changed.

    Clients may instantiate this class. Clients may subclass this class to add other attributes to a memory byte, as required.

    Since:
    3.1
    See Also:
    IMemoryBlockExtension
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static byte BIG_ENDIAN
      Bit mask used to indicate a this byte of memory is big endian.
      static byte CHANGED
      Bit mask used to indicate a byte has changed since the last suspend event.
      static byte ENDIANESS_KNOWN
      Bit mask used to indicate that the endianess of this byte of memory is known.
      protected byte flags
      Attribute flags.
      static byte HISTORY_KNOWN
      Bit mask used to indicate a memory byte has history to determine if its value has changed.
      static byte READABLE
      Bit mask used to indicate a byte is readable.
      protected byte value
      Value of this byte.
      static byte WRITABLE
      Bit mask used to indicate a byte is writable.
    • Constructor Summary

      Constructors 
      Constructor Description
      MemoryByte()
      Constructs a readable, writable memory byte without a change history, and a value of 0.
      MemoryByte​(byte byteValue)
      Constructs a readable, writable memory byte without a change history, with the given value.
      MemoryByte​(byte byteValue, byte byteFlags)
      Constructs a memory byte with the given value and attributes.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte getFlags()
      Returns this memory byte's attribute as a bit mask.
      byte getValue()
      Returns the value of this memory byte.
      boolean isBigEndian()
      Returns whether this byte of memory is big endian.
      boolean isChanged()
      Returns whether this memory byte has changed.
      boolean isEndianessKnown()
      Returns whether the endianess of this byte of memory is known.
      boolean isHistoryKnown()
      Returns whether the history of this byte is known.
      boolean isReadable()
      Returns whether this memory byte is readable.
      boolean isWritable()
      Returns whether this memory byte is writable.
      void setBigEndian​(boolean isBigEndian)
      Sets whether this byte of memory is big endian.
      void setChanged​(boolean changed)
      Sets whether this memory byte has changed.
      void setEndianessKnown​(boolean isEndianessKnown)
      Sets whether the endianess of this byte of memory is known.
      void setFlags​(byte flags)
      Sets this memory byte's attributes based on the given bit mask.
      void setHistoryKnown​(boolean known)
      Sets whether the history of this byte is known.
      void setReadable​(boolean readable)
      Sets whether this memory byte is readable.
      void setValue​(byte value)
      Sets the value of this memory byte.
      void setWritable​(boolean writable)
      Sets whether this memory byte is writable.
    • Field Detail

      • WRITABLE

        public static final byte WRITABLE
        Bit mask used to indicate a byte is writable.
        See Also:
        Constant Field Values
      • READABLE

        public static final byte READABLE
        Bit mask used to indicate a byte is readable. A memory byte is readable when its value and attributes are retrievable. Otherwise, a byte is considered non-readable.
        See Also:
        Constant Field Values
      • HISTORY_KNOWN

        public static final byte HISTORY_KNOWN
        Bit mask used to indicate a memory byte has history to determine if its value has changed. When a memory byte's history is unknown, the change state has no meaning.
        See Also:
        Constant Field Values
      • BIG_ENDIAN

        public static final byte BIG_ENDIAN
        Bit mask used to indicate a this byte of memory is big endian. If this byte of memory is little endian, turn this bit mask to off.
        See Also:
        Constant Field Values
      • ENDIANESS_KNOWN

        public static final byte ENDIANESS_KNOWN
        Bit mask used to indicate that the endianess of this byte of memory is known. When a memory byte's endianess is unknown, the endianess of this byte has no meaning.
        See Also:
        Constant Field Values
      • value

        protected byte value
        Value of this byte.
      • flags

        protected byte flags
        Attribute flags.

        To specify READABLE: flags |= MemoryByte.READABLE; To specify WRITABLE: flags |= MemoryByte.WRITABLE;

    • Constructor Detail

      • MemoryByte

        public MemoryByte()
        Constructs a readable, writable memory byte without a change history, and a value of 0. The byte's endianess is known and is little endian by default.
      • MemoryByte

        public MemoryByte​(byte byteValue)
        Constructs a readable, writable memory byte without a change history, with the given value. The byte's endianess is known and is little endian by default.
        Parameters:
        byteValue - value of this memory byte
      • MemoryByte

        public MemoryByte​(byte byteValue,
                          byte byteFlags)
        Constructs a memory byte with the given value and attributes.
        Parameters:
        byteValue - value of this memory byte
        byteFlags - attributes of the byte specified as a bit mask
    • Method Detail

      • getFlags

        public byte getFlags()
        Returns this memory byte's attribute as a bit mask.
        Returns:
        this memory byte's attribute as a bit mask
      • setFlags

        public void setFlags​(byte flags)
        Sets this memory byte's attributes based on the given bit mask.
        Parameters:
        flags - bit mask of attributes
      • getValue

        public byte getValue()
        Returns the value of this memory byte.
        Returns:
        the value of this memory byte
      • setValue

        public void setValue​(byte value)
        Sets the value of this memory byte.
        Parameters:
        value - the new value of this memory byte
      • setReadable

        public void setReadable​(boolean readable)
        Sets whether this memory byte is readable. A memory byte is considered readable when its value and attributes are retrievable.
        Parameters:
        readable - whether this memory byte is readable
      • isReadable

        public boolean isReadable()
        Returns whether this memory byte is readable. A memory byte is considered readable when its value and attributes are retrievable.
        Returns:
        whether this memory byte is readable
      • setWritable

        public void setWritable​(boolean writable)
        Sets whether this memory byte is writable.
        Parameters:
        writable - whether this memory byte is writable.
      • isWritable

        public boolean isWritable()
        Returns whether this memory byte is writable.
        Returns:
        whether this memory byte is writable
      • setChanged

        public void setChanged​(boolean changed)
        Sets whether this memory byte has changed.
        Parameters:
        changed - whether this memory byte has changed
      • isChanged

        public boolean isChanged()
        Returns whether this memory byte has changed.
        Returns:
        whether this memory byte has changed
      • setHistoryKnown

        public void setHistoryKnown​(boolean known)
        Sets whether the history of this byte is known. When history is unknown, the change state of a memory byte has no meaning.
        Parameters:
        known - whether the change state of this byte is known
      • isHistoryKnown

        public boolean isHistoryKnown()
        Returns whether the history of this byte is known. When history is unknown, the change state of a memory byte has no meaning.
        Returns:
        whether the change state of this byte is known
      • setBigEndian

        public void setBigEndian​(boolean isBigEndian)
        Sets whether this byte of memory is big endian.
        Parameters:
        isBigEndian - whether the byte of memory is big endian.
      • isBigEndian

        public boolean isBigEndian()
        Returns whether this byte of memory is big endian.
        Returns:
        whether the byte of memory is big endian.
      • setEndianessKnown

        public void setEndianessKnown​(boolean isEndianessKnown)
        Sets whether the endianess of this byte of memory is known. If the endianess is unknown, the endianess of this byte has no meaning.
        Parameters:
        isEndianessKnown - whether the endianess of this byte is known.
      • isEndianessKnown

        public boolean isEndianessKnown()
        Returns whether the endianess of this byte of memory is known. If the endianess is unknown, the endianess of this byte has no meaning.
        Returns:
        whether the endianess of this byte of memory is known.