Project

General

Profile

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

    
12
import java.util.HashMap;
13
import java.util.List;
14
import eu.etaxonomy.cdm.io.common.ObservableBase;
15
import eu.etaxonomy.cdm.io.dwca.TermUri;
16
import eu.etaxonomy.cdm.io.stream.IItemStream;
17
import eu.etaxonomy.cdm.io.stream.StreamItem;
18

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

    
26
	private List<HashMap<String, String>> innerStream;
27
	int index = 0;
28
	private TermUri termUri;
29
	private String streamLocation;
30
	
31
	/**
32
	 * @param innerStream
33
	 */
34
	public ExcelMapReader(List<HashMap<String, String>> innerStream, TermUri termUri, String streamLocation) {
35
		super();
36
		this.innerStream = innerStream;
37
		index = 0;
38
		this.termUri = termUri;
39
		this.streamLocation = streamLocation;
40
	}
41

    
42
	/* (non-Javadoc)
43
	 * @see eu.etaxonomy.cdm.io.dwca.in.IReader#read()
44
	 */
45
	@Override
46
	public StreamItem read() {
47
		HashMap<String, String> map = innerStream.get(index++);
48
		StreamItem item = convertMapToItem(map);
49
		return item;
50
	}
51

    
52
	/**
53
	 * @param map
54
	 * @return
55
	 */
56
	private StreamItem convertMapToItem(HashMap<String, String> map) {
57
		StreamItem result = new StreamItem(termUri, map, streamLocation);
58
		return result;
59
	}
60

    
61
	/* (non-Javadoc)
62
	 * @see eu.etaxonomy.cdm.io.dwca.in.IReader#hasNext()
63
	 */
64
	@Override
65
	public boolean hasNext() {
66
		return innerStream.size() > index;
67
	}
68

    
69
	/* (non-Javadoc)
70
	 * @see eu.etaxonomy.cdm.io.stream.IItemStream#getTerm()
71
	 */
72
	@Override
73
	public TermUri getTerm() {
74
		return termUri;
75
	}
76

    
77
	/* (non-Javadoc)
78
	 * @see eu.etaxonomy.cdm.io.stream.IItemStream#getItemLocation()
79
	 */
80
	@Override
81
	public String getItemLocation() {
82
		//FIXME better dont use ExcelUtils !!
83
		return "FIXME";
84
	}
85

    
86
	/* (non-Javadoc)
87
	 * @see eu.etaxonomy.cdm.io.stream.IItemStream#getStreamLocation()
88
	 */
89
	@Override
90
	public String getStreamLocation() {
91
		return streamLocation;
92
	}
93

    
94

    
95
}
(1-1/6)