Exemplo n.º 1
0
  public static void writeActionQueue(MarshallerWriteContext context) throws IOException {
    ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;

    WorkingMemoryAction[] queue =
        wm.getActionQueue().toArray(new WorkingMemoryAction[wm.getActionQueue().size()]);
    for (int i = queue.length - 1; i >= 0; i--) {
      context.writeShort(PersisterEnums.WORKING_MEMORY_ACTION);
      queue[i].write(context);
    }
    context.writeShort(PersisterEnums.END);
  }
  public static void writeActionQueue(
      MarshallerWriteContext context, ProtobufMessages.RuleData.Builder _session)
      throws IOException {

    ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
    if (!wm.getActionQueue().isEmpty()) {
      ProtobufMessages.ActionQueue.Builder _queue = ProtobufMessages.ActionQueue.newBuilder();

      WorkingMemoryAction[] queue =
          wm.getActionQueue().toArray(new WorkingMemoryAction[wm.getActionQueue().size()]);
      for (int i = queue.length - 1; i >= 0; i--) {
        _queue.addAction(queue[i].serialize(context));
      }
      _session.setActionQueue(_queue.build());
    }
  }
 public static void readActionQueue(MarshallerReaderContext context)
     throws IOException, ClassNotFoundException {
   ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
   Queue<WorkingMemoryAction> actionQueue = wm.getActionQueue();
   while (context.readShort() == PersisterEnums.WORKING_MEMORY_ACTION) {
     actionQueue.offer(PersisterHelper.readWorkingMemoryAction(context));
   }
 }