Package jadex.binary

Class FramingEncodingContext

java.lang.Object
jadex.binary.AbstractEncodingContext
jadex.binary.FramingEncodingContext
All Implemented Interfaces:
IEncodingContext, jadex.common.transformation.traverser.IRootObjectContext, jadex.common.transformation.traverser.IUserContextContainer

public class FramingEncodingContext extends AbstractEncodingContext
Encoding context with framing output.
  • Field Details

    • buffer

      protected byte[] buffer
      The buffer.
    • framestack

      protected Deque<jadex.common.Tuple2<Integer,Boolean>> framestack
      The frame stack, buffer position and fixed size marker.
  • Constructor Details

    • FramingEncodingContext

      public FramingEncodingContext(Object rootobject, Object usercontext, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, ClassLoader classloader, SerializationConfig config)
      Creates an encoding context.
      Parameters:
      usercontext - A user context.
      preprocessors - The preprocessors.
      classloader - The classloader.
  • Method Details

    • startObjectFrame

      public void startObjectFrame(boolean fixedsize)
      Starts an object frame when using a context with framing support.
      Specified by:
      startObjectFrame in interface IEncodingContext
      Overrides:
      startObjectFrame in class AbstractEncodingContext
      Parameters:
      fixedsize - If true, use fixed-size (integer) framing. Set true if the object being framed is expected to be larger than 127 bytes (same type of object MUST use either fixed OR variable framing).
    • stopObjectFrame

      public void stopObjectFrame()
      Stops an object frame when using a context with framing support.
      Specified by:
      stopObjectFrame in interface IEncodingContext
      Overrides:
      stopObjectFrame in class AbstractEncodingContext
    • writeByte

      public void writeByte(byte b)
      Description copied from interface: IEncodingContext
      Writes a byte.
      Parameters:
      b - The byte.
    • write

      public void write(byte[] b)
      Description copied from interface: IEncodingContext
      Writes a byte array.
      Parameters:
      b - The byte array.
    • toByteArray

      public byte[] toByteArray()
      Returns the current data buffer, trimmed to size.
      Returns:
      The buffer.
    • ensureSpace

      protected void ensureSpace(int requiredsize)
      Ensures sufficient space in buffer.
      Parameters:
      requiredsize - Required space in buffer.