comparison src/org/tmatesoft/hg/internal/DataAccess.java @ 158:b413b16d10a5

Integer offsets and file length explictly, rather than casts throughout code. Inflater may benefit from total length hint, but shall calculate it by its own if needed
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 09 Mar 2011 13:16:37 +0100
parents d5268ca7715b
children 5e95b0da26f2
comparison
equal deleted inserted replaced
157:d5268ca7715b 158:b413b16d10a5
30 */ 30 */
31 public class DataAccess { 31 public class DataAccess {
32 public boolean isEmpty() { 32 public boolean isEmpty() {
33 return true; 33 return true;
34 } 34 }
35 public long length() { 35 public int length() {
36 return 0; 36 return 0;
37 } 37 }
38 /** 38 /**
39 * get this instance into initial state 39 * get this instance into initial state
40 * @throws IOException 40 * @throws IOException
43 public DataAccess reset() throws IOException { 43 public DataAccess reset() throws IOException {
44 // nop, empty instance is always in the initial state 44 // nop, empty instance is always in the initial state
45 return this; 45 return this;
46 } 46 }
47 // absolute positioning 47 // absolute positioning
48 public void seek(long offset) throws IOException { 48 public void seek(int offset) throws IOException {
49 throw new UnsupportedOperationException(); 49 throw new UnsupportedOperationException();
50 } 50 }
51 // relative positioning 51 // relative positioning
52 public void skip(int bytes) throws IOException { 52 public void skip(int bytes) throws IOException {
53 throw new UnsupportedOperationException(); 53 throw new UnsupportedOperationException();
93 93
94 // XXX decide whether may or may not change position in the DataAccess 94 // XXX decide whether may or may not change position in the DataAccess
95 // FIXME exception handling is not right, just for the sake of quick test 95 // FIXME exception handling is not right, just for the sake of quick test
96 public byte[] byteArray() throws IOException { 96 public byte[] byteArray() throws IOException {
97 reset(); 97 reset();
98 byte[] rv = new byte[(int) length()]; 98 byte[] rv = new byte[length()];
99 readBytes(rv, 0, rv.length); 99 readBytes(rv, 0, rv.length);
100 return rv; 100 return rv;
101 } 101 }
102 } 102 }