source: osm/applications/editors/josm/plugins/opendata/includes/org/j7zip/Common/ByteBuffer.java@ 29679

Last change on this file since 29679 was 29679, checked in by donvip, 11 years ago

[josm_opendata] Add .7z archive read support

File size: 972 bytes
Line 
1package org.j7zip.Common;
2
3public class ByteBuffer {
4 int _capacity;
5 byte [] _items;
6
7 public ByteBuffer() {
8 _capacity = 0;
9 _items = null;
10 }
11
12 public byte [] data() { return _items; }
13
14 public int GetCapacity() { return _capacity; }
15
16 public void SetCapacity(int newCapacity) {
17 if (newCapacity == _capacity)
18 return;
19
20 byte [] newBuffer;
21 if (newCapacity > 0) {
22 newBuffer = new byte[newCapacity];
23 if(_capacity > 0) {
24 int len = _capacity;
25 if (newCapacity < len) len = newCapacity;
26
27 System.arraycopy(_items,0,newBuffer,0,len); // for (int i = 0 ; i < len ; i++) newBuffer[i] = _items[i];
28 }
29 } else
30 newBuffer = null;
31
32 // delete []_items;
33 _items = newBuffer;
34 _capacity = newCapacity;
35 }
36}
Note: See TracBrowser for help on using the repository browser.