File: TileBytes.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (40 lines) | stat: -rw-r--r-- 812 bytes parent folder | download | duplicates (5)
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
package tim.prune.gui.map.tile;

/**
 * Container for the results of a TileWorker
 * having processed a tile definition
 */
public class TileBytes
{
	private byte[] _data = null;

	public void addBytes(byte[] inData, int inNumBytes)
	{
		if (inNumBytes > 0)
		{
			final int totalBytes = (_data == null ? 0 : _data.length) + inNumBytes;
			byte[] result = new byte[totalBytes];
			int targetIdx = 0;
			if (_data != null) {
				System.arraycopy(_data, 0, result, 0, _data.length);
				targetIdx = _data.length;
			}
			System.arraycopy(inData, 0, result, targetIdx, inNumBytes);
			_data = result;
		}
	}

	/**
	 * @return true if there are no bytes
	 */
	public boolean isEmpty() {
		return _data == null || _data.length == 0;
	}

	/**
	 * @return byte data
	 */
	public byte[] getData() {
		return _data;
	}
}