]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/save/xml/GpxCacherList.java
Version 11, August 2010
[GpsPrune.git] / tim / prune / save / xml / GpxCacherList.java
1 package tim.prune.save.xml;
2
3 import tim.prune.data.DataPoint;
4 import tim.prune.data.FileInfo;
5 import tim.prune.data.SourceInfo;
6
7 /**
8  * Class to hold a list of GpxCacher objects
9  * and get the original source xml for data points
10  */
11 public class GpxCacherList
12 {
13         /** Array of Gpx Cachers */
14         private GpxCacher[] _cacherList = null;
15
16         /**
17          * Constructor
18          * @param inInfo file info object
19          */
20         public GpxCacherList(FileInfo inInfo)
21         {
22                 int numFiles = inInfo.getNumFiles();
23                 _cacherList = new GpxCacher[numFiles];
24                 for (int i=0; i<numFiles; i++) {
25                         SourceInfo info = inInfo.getSource(i);
26                         if (info.getFileType() == SourceInfo.FILE_TYPE.GPX) {
27                                 _cacherList[i] = new GpxCacher(info);
28                         }
29                 }
30         }
31
32         /**
33          * Get the source for the given data point
34          * @param inPoint point to look for
35          * @return source string or null if not found
36          */
37         public String getSourceString(DataPoint inPoint)
38         {
39                 String str = null;
40                 // Loop over sources
41                 for (int i=0; i<_cacherList.length && (str == null); i++) {
42                         GpxCacher cacher = _cacherList[i];
43                         if (cacher != null) {
44                                 str = cacher.getSourceString(inPoint);
45                         }
46                 }
47                 return str;
48         }
49
50         /**
51          * @return the first non-empty header from the list
52          */
53         public String getFirstHeader()
54         {
55                 String str = null;
56                 // Loop over sources
57                 for (int i=0; i<_cacherList.length && (str == null || str.equals("")); i++)
58                 {
59                         GpxCacher cacher = _cacherList[i];
60                         if (cacher != null) {
61                                 str = cacher.getHeaderString();
62                         }
63                 }
64                 return str;
65         }
66 }