File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\store\fs\FileBase.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.store.fs;
8
9 import java.io.IOException;
10 import java.nio.ByteBuffer;
11 import java.nio.MappedByteBuffer;
12 import java.nio.channels.FileChannel;
13 import java.nio.channels.FileLock;
14 import java.nio.channels.ReadableByteChannel;
15 import java.nio.channels.WritableByteChannel;
16
17 /**
18 * The base class for file implementations.
19 */
20 public abstract class FileBase extends FileChannel {
21
22 public abstract long size() throws IOException;
23
24 public abstract long position() throws IOException;
25
26 public abstract FileChannel position(long newPosition) throws IOException;
27
28 public abstract int read(ByteBuffer dst) throws IOException;
29
30 public abstract int write(ByteBuffer src) throws IOException;
31
32 public synchronized int read(ByteBuffer dst, long position) throws IOException {
33 long oldPos = position();
34 position(position);
35 int len = read(dst);
36 position(oldPos);
37 return len;
38 }
39
40 public synchronized int write(ByteBuffer src, long position) throws IOException {
41 long oldPos = position();
42 position(position);
43 int len = write(src);
44 position(oldPos);
45 return len;
46 }
47
48 public abstract FileChannel truncate(long size) throws IOException;
49
50 public void force(boolean metaData) throws IOException {
51 // ignore
52 }
53
54 protected void implCloseChannel() throws IOException {
55 // ignore
56 }
57
58 public FileLock lock(long position, long size, boolean shared) throws IOException {
59 throw new UnsupportedOperationException();
60 }
61
62 public MappedByteBuffer map(MapMode mode, long position, long size) throws IOException {
63 throw new UnsupportedOperationException();
64 }
65
66 public long read(ByteBuffer[] dsts, int offset, int length) throws IOException {
67 throw new UnsupportedOperationException();
68 }
69
70 public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException {
71 throw new UnsupportedOperationException();
72 }
73
74 public long transferTo(long position, long count, WritableByteChannel target)
75 throws IOException {
76 throw new UnsupportedOperationException();
77 }
78
79 public FileLock tryLock(long position, long size, boolean shared) throws IOException {
80 throw new UnsupportedOperationException();
81 }
82
83 public long write(ByteBuffer[] srcs, int offset, int length) throws IOException {
84 throw new UnsupportedOperationException();
85 }
86
87 }
88