File: FileInfo.java

package info (click to toggle)
gpsprune 10-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,220 kB
  • ctags: 3,013
  • sloc: java: 22,662; sh: 23; makefile: 16; python: 15
file content (94 lines) | stat: -rw-r--r-- 1,626 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package tim.prune.data;

import java.util.ArrayList;

/**
 * Class to hold the information about the file(s)
 * from which the data was loaded from / saved to
 */
public class FileInfo
{
	/** List of sources */
	private ArrayList<SourceInfo> _sources = new ArrayList<SourceInfo>();


	/**
	 * Empty constructor
	 */
	public FileInfo()
	{}

	/**
	 * Private constructor for creating clone
	 * @param inList list of sources
	 */
	private FileInfo(ArrayList<SourceInfo> inList)
	{
		_sources = inList;
	}

	/**
	 * Add a data source to the list
	 * @param inInfo info object to add
	 */
	public void addSource(SourceInfo inInfo)
	{
		_sources.add(inInfo);
	}

	/**
	 * Replace the list of data sources with the given source
	 * @param inInfo new source
	 */
	public void replaceSource(SourceInfo inInfo)
	{
		_sources.clear();
		addSource(inInfo);
	}

	/**
	 * remove the last source added
	 */
	public void removeSource()
	{
		_sources.remove(_sources.size()-1);
	}

	/**
	 * @return the number of files loaded
	 */
	public int getNumFiles()
	{
		return _sources.size();
	}


	/**
	 * @return The source name, if a single file
	 */
	public String getFilename()
	{
		if (getNumFiles() == 1)
			return _sources.get(0).getName();
		return "";
	}

	/**
	 * @param inIndex index number
	 * @return source info object
	 */
	public SourceInfo getSource(int inIndex) {
		return _sources.get(inIndex);
	}

	/**
	 * Clone contents of file info
	 */
	@SuppressWarnings("unchecked")
	public FileInfo clone()
	{
		// copy source list
		ArrayList<SourceInfo> copy = (ArrayList<SourceInfo>) _sources.clone();
		return new FileInfo(copy);
	}
}