Exemple #1
0
        /**
         * /// Gets the set of lines from the file
         *
         * /// @param file the name of the file
         */
        private List <String> GetBatchItems(String file)
        {
            var list = BatchFile.GetLines(file, _skip);

            if (_totalBatches > 1)
            {
                var linesPerBatch = list.Count / _totalBatches;
                if (linesPerBatch < 1)
                {
                    linesPerBatch = 1;
                }
                if (_whichBatch >= _totalBatches)
                {
                    _whichBatch = _totalBatches - 1;
                }
                var startLine = _whichBatch * linesPerBatch;
                // last batch needs to get all remaining lines
                if (_whichBatch == (_totalBatches - 1))
                {
                    list = list.GetRange(startLine, list.Count);
                }
                else
                {
                    list = list.GetRange(startLine, startLine + linesPerBatch);
                }
            }
            return(list);
        }
Exemple #2
0
        /**
         * /// Gets the next available batch item or null if no more are available
         *
         * /// @return the next available batch item
         * /// @throws IOException if an I/O error occurs while getting the next item from the batch file.
         */
        public BatchItem GetNextItem()
        {
            if (_curItem >= _items.Count)
            {
                return(null);
            }
            var line = _items[_curItem++];

            return(new BatchItem(BatchFile.GetFilename(line),
                                 BatchFile.GetReference(line)));
        }