Mercurial > jhg
comparison src/com/tmate/hgkit/fs/DataAccessProvider.java @ 51:9429c7bd1920 wrap-data-access
Try DataAccess to reach revision data instead of plain byte arrays
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Sun, 16 Jan 2011 01:20:26 +0100 | 
| parents | b0a15cefdfd6 | 
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| 50:f1db8610da62 | 51:9429c7bd1920 | 
|---|---|
| 70 public boolean isEmpty() { | 70 public boolean isEmpty() { | 
| 71 return position + (buffer == null ? 0 : buffer.position()) >= size; | 71 return position + (buffer == null ? 0 : buffer.position()) >= size; | 
| 72 } | 72 } | 
| 73 | 73 | 
| 74 @Override | 74 @Override | 
| 75 public long length() { | |
| 76 return size; | |
| 77 } | |
| 78 | |
| 79 @Override | |
| 80 public void reset() throws IOException { | |
| 81 seek(0); | |
| 82 } | |
| 83 | |
| 84 @Override | |
| 75 public void seek(long offset) { | 85 public void seek(long offset) { | 
| 76 assert offset >= 0; | 86 assert offset >= 0; | 
| 77 // offset may not necessarily be further than current position in the file (e.g. rewind) | 87 // offset may not necessarily be further than current position in the file (e.g. rewind) | 
| 78 if (buffer != null && /*offset is within buffer*/ offset >= position && (offset - position) < buffer.limit()) { | 88 if (buffer != null && /*offset is within buffer*/ offset >= position && (offset - position) < buffer.limit()) { | 
| 79 buffer.position((int) (offset - position)); | 89 buffer.position((int) (offset - position)); | 
| 172 public boolean isEmpty() { | 182 public boolean isEmpty() { | 
| 173 return bufferStartInFile + buffer.position() >= size; | 183 return bufferStartInFile + buffer.position() >= size; | 
| 174 } | 184 } | 
| 175 | 185 | 
| 176 @Override | 186 @Override | 
| 187 public long length() { | |
| 188 return size; | |
| 189 } | |
| 190 | |
| 191 @Override | |
| 192 public void reset() throws IOException { | |
| 193 seek(0); | |
| 194 } | |
| 195 | |
| 196 @Override | |
| 177 public void seek(long offset) throws IOException { | 197 public void seek(long offset) throws IOException { | 
| 178 if (offset > size) { | 198 if (offset > size) { | 
| 179 throw new IllegalArgumentException(); | 199 throw new IllegalArgumentException(); | 
| 180 } | 200 } | 
| 181 if (offset < bufferStartInFile + buffer.limit() && offset >= bufferStartInFile) { | 201 if (offset < bufferStartInFile + buffer.limit() && offset >= bufferStartInFile) { | 
