001package org.openimaj.picslurper;
002
003import java.io.FileInputStream;
004import java.io.FileNotFoundException;
005import java.io.InputStream;
006import java.util.Map;
007
008import backtype.storm.spout.SpoutOutputCollector;
009import backtype.storm.task.TopologyContext;
010
011public class LocalFileTweetSpout extends LocalTweetSpout {
012
013        /**
014         * 
015         */
016        private static final long serialVersionUID = 4651675626654237689L;
017        
018        private String[] files;
019        private int nextFileIndex;
020
021
022        public LocalFileTweetSpout(String... files) {
023                this.files = files;
024        }
025        
026        @SuppressWarnings("rawtypes")
027        @Override
028        public void open(Map conf, TopologyContext context,SpoutOutputCollector collector) {
029                super.open(conf, context, collector);
030                this.nextFileIndex = 0;
031        }
032
033        @Override
034        protected InputStream nextInputStream() throws FileNotFoundException {
035                if(this.nextFileIndex >= this.files.length) return null;
036                this.nextFileIndex++;
037                return new FileInputStream(this.files[this.nextFileIndex-1]);
038        }
039
040}