Project

General

Profile

Download (1.75 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.io.stream.excel;
10

    
11
import java.util.HashMap;
12
import java.util.List;
13

    
14
import eu.etaxonomy.cdm.io.common.ObservableBase;
15
import eu.etaxonomy.cdm.io.stream.IItemStream;
16
import eu.etaxonomy.cdm.io.stream.StreamItem;
17
import eu.etaxonomy.cdm.io.stream.terms.TermUri;
18

    
19
/**
20
 * @author a.oppermann
21
 \* @since 24.05.2013
22
 *
23
 */
24
public class ExcelMapReader extends ObservableBase implements IItemStream {
25

    
26
    private static final long serialVersionUID = -6409544362742718356L;
27

    
28
    private List<HashMap<String, String>> innerStream;
29
	int index = 0;
30
	private TermUri termUri;
31
	private String streamLocation;
32

    
33
	/**
34
	 * @param innerStream
35
	 */
36
	public ExcelMapReader(List<HashMap<String, String>> innerStream, TermUri termUri, String streamLocation) {
37
		super();
38
		this.innerStream = innerStream;
39
		index = 0;
40
		this.termUri = termUri;
41
		this.streamLocation = streamLocation;
42
	}
43

    
44
	@Override
45
	public StreamItem read() {
46
		HashMap<String, String> map = innerStream.get(index++);
47
		StreamItem item = convertMapToItem(map);
48
		return item;
49
	}
50

    
51
	private StreamItem convertMapToItem(HashMap<String, String> map) {
52
		StreamItem result = new StreamItem(termUri, map, streamLocation);
53
		return result;
54
	}
55

    
56
	@Override
57
	public boolean hasNext() {
58
		return innerStream.size() > index;
59
	}
60

    
61
	@Override
62
	public TermUri getTerm() {
63
		return termUri;
64
	}
65

    
66
	@Override
67
	public String getItemLocation() {
68
		//FIXME better dont use ExcelUtils !!
69
		return "FIXME";
70
	}
71

    
72
	@Override
73
	public String getStreamLocation() {
74
		return streamLocation;
75
	}
76
}
(1-1/3)