]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/function/cache/RowInfo.java
dc90abd65066d6cd16868ca3a1ce693ec4a5f642
[GpsPrune.git] / tim / prune / function / cache / RowInfo.java
1 package tim.prune.function.cache;
2
3 /**
4  * Class to hold the information for a single table row.
5  * Used to describe a tileset or for a single zoom level of a tileset.
6  */
7 public class RowInfo
8 {
9         private int _zoom = -1;
10         private int _minZoom = -1, _maxZoom = -1;
11         private int _numTiles = 0;
12         private long _totalSize = 0L;
13         private boolean _unexpected = false;
14
15
16         /**
17          * Set the zoom level
18          * @param inZoom zoom level
19          */
20         public void setZoom(int inZoom) {
21                 _zoom = inZoom;
22         }
23
24         /**
25          * Add a zoom level and adjust max/min
26          * @param inZoom zoom level
27          */
28         public void addZoom(int inZoom)
29         {
30                 if (_minZoom < 0 || _minZoom > inZoom)
31                         _minZoom = inZoom;
32                 if (_maxZoom < inZoom)
33                         _maxZoom = inZoom;
34         }
35
36         /**
37          * @return the zoom level
38          */
39         public int getZoom() {
40                 return _zoom;
41         }
42
43         /**
44          * @return the zoom range as a string
45          */
46         public String getZoomRange()
47         {
48                 if (_minZoom < 0 && _maxZoom < 0) return "";
49                 if (_minZoom == _maxZoom || _maxZoom < 0) return "" + _minZoom;
50                 if (_minZoom < 0) return "" + _maxZoom;
51                 return "" + _minZoom + " - " + _maxZoom;
52         }
53
54         /**
55          * Add a single tile of the given size
56          * @param inSize size in bytes
57          */
58         public void addTile(long inSize) {
59                 addTiles(1, inSize);
60         }
61
62         /**
63          * Add the given tiles
64          * @param inNumTiles number of tiles to add
65          * @param inSize total size of the tiles in bytes
66          */
67         public void addTiles(int inNumTiles, long inSize)
68         {
69                 _numTiles += inNumTiles;
70                 _totalSize += inSize;
71         }
72
73         /**
74          * @return the total number of tiles found
75          */
76         public int getNumTiles() {
77                 return _numTiles;
78         }
79
80         /**
81          * @return the total size of the tiles in bytes
82          */
83         public long getTotalSize() {
84                 return _totalSize;
85         }
86
87         /**
88          * Mark that an unexpected file or directory was found
89          */
90         public void foundUnexpected() {
91                 _unexpected = true;
92         }
93
94         /**
95          * @return true if any unexpected files or directories were found
96          */
97         public boolean wasUnexpected() {
98                 return _unexpected;
99         }
100
101         /**
102          * Add the given RowInfo object to this one
103          * @param inOther other row object
104          */
105         public void addRow(RowInfo inOther)
106         {
107                 if (inOther == null)
108                         return;
109                 _numTiles  += inOther._numTiles;
110                 _totalSize += inOther._totalSize;
111                 // TODO: Max age
112                 // Zoom range
113                 if (inOther._minZoom > 0)
114                         addZoom(inOther._minZoom);
115                 if (inOther._maxZoom > 0)
116                         addZoom(inOther._maxZoom);
117                 if (inOther._zoom > 0)
118                         addZoom(inOther._zoom);
119                 _unexpected = _unexpected || inOther._unexpected;
120         }
121 }