Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/DataAccess.java @ 74:6f1b88693d48
Complete refactoring to org.tmatesoft
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 24 Jan 2011 03:14:45 +0100 |
parents | src/com/tmate/hgkit/fs/DataAccess.java@382cfe9463db |
children | a3a2e5deb320 |
comparison
equal
deleted
inserted
replaced
73:0d279bcc4442 | 74:6f1b88693d48 |
---|---|
1 /* | |
2 * Copyright (c) 2010 TMate Software Ltd | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; version 2 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * For information on how to redistribute this software under | |
14 * the terms of a license other than GNU General Public License | |
15 * contact TMate Software at support@svnkit.com | |
16 */ | |
17 package org.tmatesoft.hg.internal; | |
18 | |
19 import java.io.IOException; | |
20 | |
21 /** | |
22 * relevant parts of DataInput, non-stream nature (seek operation), explicit check for end of data. | |
23 * convenient skip (+/- bytes) | |
24 * Primary goal - effective file read, so that clients don't need to care whether to call few | |
25 * distinct getInt() or readBytes(totalForFewInts) and parse themselves instead in an attempt to optimize. | |
26 * | |
27 * @author Artem Tikhomirov | |
28 * @author TMate Software Ltd. | |
29 */ | |
30 public class DataAccess { | |
31 public boolean isEmpty() { | |
32 return true; | |
33 } | |
34 // absolute positioning | |
35 public void seek(long offset) throws IOException { | |
36 throw new UnsupportedOperationException(); | |
37 } | |
38 // relative positioning | |
39 public void skip(int bytes) throws IOException { | |
40 throw new UnsupportedOperationException(); | |
41 } | |
42 // shall be called once this object no longer needed | |
43 public void done() { | |
44 // no-op in this empty implementation | |
45 } | |
46 public int readInt() throws IOException { | |
47 byte[] b = new byte[4]; | |
48 readBytes(b, 0, 4); | |
49 return b[0] << 24 | (b[1] & 0xFF) << 16 | (b[2] & 0xFF) << 8 | (b[3] & 0xFF); | |
50 } | |
51 public long readLong() throws IOException { | |
52 byte[] b = new byte[8]; | |
53 readBytes(b, 0, 8); | |
54 int i1 = b[0] << 24 | (b[1] & 0xFF) << 16 | (b[2] & 0xFF) << 8 | (b[3] & 0xFF); | |
55 int i2 = b[4] << 24 | (b[5] & 0xFF) << 16 | (b[6] & 0xFF) << 8 | (b[7] & 0xFF); | |
56 return ((long) i1) << 32 | ((long) i2 & 0xFFFFFFFF); | |
57 } | |
58 public void readBytes(byte[] buf, int offset, int length) throws IOException { | |
59 throw new UnsupportedOperationException(); | |
60 } | |
61 public byte readByte() throws IOException { | |
62 throw new UnsupportedOperationException(); | |
63 } | |
64 } |