Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"). You may not
   * use this file except in compliance with the License. A copy of the License is
   * located at
   * 
   * http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file is distributed on
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.simpleworkflow.flow.worker;
 
 import java.util.List;
 
 
 
 class HistoryHelper {
 
     private static final Log historyLog = LogFactory.getLog(HistoryHelper.class.getName() + ".history");
 
     class EventsIterator implements Iterator<HistoryEvent> {
 
         private final Iterator<DecisionTaskdecisionTasks;
 
         private DecisionTask decisionTask;
 
         private List<HistoryEventevents;
 
         private int index;
 
         public EventsIterator(Iterator<DecisionTaskdecisionTasks) {
             this. = decisionTasks;
             if (decisionTasks.hasNext()) {
                  = decisionTasks.next();
                  = .getEvents();
                 if (.isTraceEnabled()) {
                     .trace(WorkflowExecutionUtils.prettyPrintHistory(true));
                 }
             }
             else {
                  = null;
             }
         }
 
         @Override
         public boolean hasNext() {
             return  != null && ( < .size() || .hasNext());
         }
 
         @Override
         public HistoryEvent next() {
             if ( == .size()) {
                  = .next();
                  = .getEvents();
                 if (.isTraceEnabled()) {
                     .trace(WorkflowExecutionUtils.prettyPrintHistory(true));
                 }
                  = 0;
             }
             return .get(++);
         }
 
         public DecisionTask getDecisionTask() {
             return ;
         }
 
         public List<HistoryEventgetEvents() {
             return ;
         }
 
         public boolean isNextDecisionTimedOut() {
             int i = ;
             while (true) {
                 for (; i < .size(); i++) {
                     HistoryEvent event = .get(i);
                     EventType eventType = EventType.fromValue(event.getEventType());
                     if (eventType.equals(.)) {
                         return true;
                     }
                     else if (eventType.equals(.)) {
                         return false;
                     }
                 }
                 if (!.hasNext()) {
                     return false;
                 }
                  = .next();
                 List<HistoryEventnextPageEvents = .getEvents();
                if (.isTraceEnabled()) {
                    .trace(WorkflowExecutionUtils.prettyPrintHistory(nextPageEventstrue));
                }
                .addAll(nextPageEvents);
            }
        }
        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }
    }
    private final EventsIterator events;
    public HistoryHelper(Iterator<DecisionTaskdecisionTasks) {
        this. = new EventsIterator(decisionTasks);
    }
    public EventsIterator getEvents() {
        return ;
    }
    public String toString() {
        return WorkflowExecutionUtils.prettyPrintHistory(.getEvents(), true);
    }
    public DecisionTask getDecisionTask() {
        return .getDecisionTask();
    }
    public long getLastNonReplayEventId() {
        Long result = getDecisionTask().getPreviousStartedEventId();
        if (result == null) {
            return 0;
        }
        return result;
    }
New to GrepCode? Check out our FAQ X