Interface PatchEncoder

All Superinterfaces:
CachedEncoder, Encoder
All Known Implementing Classes:
PackedEncodeOverlay, PatchPackedEncode

public interface PatchEncoder extends CachedEncoder
This is an encoder that produces encodings that can be retroactively patched. The contained encoding is expected to be byte based. The user can record a position in the encoding by calling the size() method in the middle of encoding, and then later use the returned offset to call the patchIntegerAttribute() method and modify the encoding at the recorded position.
  • Method Details

    • writeSpaceId

      void writeSpaceId(AttributeId attribId, long spaceId) throws IOException
      Write a given raw spaceid (as returned by AddressSpace.getSpaceID()) as an attribute. The effect is the same as if writeSpace() was called with the AddressSpace matching the spaceid, i.e. the decoder will read this as just space attribute.
      Parameters:
      attribId - is the attribute
      spaceId - is the given spaceid
      Throws:
      IOException - for problems writing to the stream
    • size

      int size()
      The returned value can be used as a position for later modification
      Returns:
      the number of bytes written to this stream so far
    • patchIntegerAttribute

      boolean patchIntegerAttribute(int pos, AttributeId attribId, long val)
      Replace an integer attribute for the element at the given position. The position is assumed to be at an open directive for the element containing the attribute to be patched.
      Parameters:
      pos - is the given position
      attribId - is the attribute to be patched
      val - is the new value to insert
      Returns:
      true if the attribute is successfully patched