001    /**
002     * Copyright 2004-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.common.threads;
017    
018    import java.util.List;
019    
020    import org.kuali.common.threads.listener.ProgressNotifier;
021    
022    /**
023     * Provides context for iterating over the elements in a list. Offset and length control what portion of the list is
024     * iterated over. The ElementHandler is invoked each time an element in the list is encountered.
025     *
026     * @param <T>
027     */
028    public class ListIteratorContext<T> {
029        int id;
030        int offset;
031        int length;
032        ThreadHandler<T> threadHandler;
033        ProgressNotifier<T> notifier;
034        List<T> list;
035        ElementHandler<T> elementHandler;
036    
037        public ListIteratorContext() {
038            this(0, 0, 0, null);
039        }
040    
041        public ListIteratorContext(int id, int offset, int length, List<T> list) {
042            super();
043            this.id = id;
044            this.offset = offset;
045            this.length = length;
046            this.list = list;
047        }
048    
049        public int getId() {
050            return id;
051        }
052    
053        public void setId(int id) {
054            this.id = id;
055        }
056    
057        public int getOffset() {
058            return offset;
059        }
060    
061        public void setOffset(int offset) {
062            this.offset = offset;
063        }
064    
065        public int getLength() {
066            return length;
067        }
068    
069        public void setLength(int length) {
070            this.length = length;
071        }
072    
073        public ThreadHandler<T> getThreadHandler() {
074            return threadHandler;
075        }
076    
077        public void setThreadHandler(ThreadHandler<T> threadHandler) {
078            this.threadHandler = threadHandler;
079        }
080    
081        public ProgressNotifier<T> getNotifier() {
082            return notifier;
083        }
084    
085        public void setNotifier(ProgressNotifier<T> tracker) {
086            this.notifier = tracker;
087        }
088    
089        public List<T> getList() {
090            return list;
091        }
092    
093        public void setList(List<T> list) {
094            this.list = list;
095        }
096    
097        public ElementHandler<T> getElementHandler() {
098            return elementHandler;
099        }
100    
101        public void setElementHandler(ElementHandler<T> elementHandler) {
102            this.elementHandler = elementHandler;
103        }
104    
105    }