コード例 #1
0
ファイル: OutputMarshaller.java プロジェクト: Orlandos/drools
  public static void writeBehaviours(WindowNode windowNode, MarshallerWriteContext outCtx)
      throws IOException {
    Behavior[] behaviors = windowNode.getBehaviors();

    WindowMemory memory = (WindowMemory) outCtx.wm.getNodeMemory(windowNode);

    Object[] behaviorContexts = (Object[]) memory.behaviorContext;

    for (int i = 0; i < behaviors.length; i++) {
      if (windowNode.getBehaviors()[i] instanceof SlidingTimeWindow) {
        outCtx.writeShort(PersisterEnums.SLIDING_TIME_WIN);
        outCtx.writeInt(i);
        writeSlidingTimeWindowBehaviour(
            (SlidingTimeWindow) windowNode.getBehaviors()[i],
            (SlidingTimeWindowContext) behaviorContexts[i],
            outCtx);
      } else if (windowNode.getBehaviors()[i] instanceof SlidingLengthWindow) {
        outCtx.writeShort(PersisterEnums.SLIDING_LENGTH_WIN);
        outCtx.writeInt(i);
        writeSlidingLengthWindowBehaviour(
            (SlidingLengthWindow) windowNode.getBehaviors()[i],
            (SlidingLengthWindowContext) behaviorContexts[i],
            outCtx);
      }
    }
    outCtx.writeShort(PersisterEnums.END);
  }
コード例 #2
0
 public static void readBehaviors(
     WindowNode windowNode, WindowMemory memory, MarshallerReaderContext inCtx)
     throws IOException {
   short token = -1;
   while ((token = inCtx.readShort()) != PersisterEnums.END) {
     int i = inCtx.readInt();
     Object object = ((Object[]) memory.behaviorContext)[i];
     switch (token) {
       case PersisterEnums.SLIDING_TIME_WIN:
         {
           readSlidingTimeWindowBehaviour(
               windowNode,
               memory,
               (SlidingTimeWindow) windowNode.getBehaviors()[i],
               (SlidingTimeWindowContext) object,
               inCtx);
           break;
         }
       case PersisterEnums.SLIDING_LENGTH_WIN:
         {
           readSlidingLengthWindowBehaviour(
               windowNode,
               memory,
               (SlidingLengthWindow) windowNode.getBehaviors()[i],
               (SlidingLengthWindowContext) object,
               inCtx);
           break;
         }
     }
   }
 }