Debian Codegraph @

src/main/org/h2/store/fs/FakeFileChannel.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.store.fs;
7
8 import java.io.IOException;
9 import java.nio.ByteBuffer;
10 import java.nio.MappedByteBuffer;
11 import java.nio.channels.FileChannel;
12 import java.nio.channels.FileLock;
13 import java.nio.channels.ReadableByteChannel;
14 import java.nio.channels.WritableByteChannel;
15
16 /**
17 * Fake file channel to use by in-memory and ZIP file systems.
18 */
19 public class FakeFileChannel extends FileChannel {
20
21 /**
22 * No need to allocate these, they have no state
23 */
24 public static final FakeFileChannel INSTANCE = new FakeFileChannel();
25
26 private FakeFileChannel() {}
27
28 @Override
29 protected void implCloseChannel() throws IOException {
30 throw new IOException();
31 }
32
33 @Override
34 public FileLock lock(long position, long size, boolean shared) throws IOException {
35 throw new IOException();
36 }
37
38 @Override
39 public MappedByteBuffer map(MapMode mode, long position, long size) throws IOException {
40 throw new IOException();
41 }
42
43 @Override
44 public long position() throws IOException {
45 throw new IOException();
46 }
47
48 @Override
49 public FileChannel position(long newPosition) throws IOException {
50 throw new IOException();
51 }
52
53 @Override
54 public int read(ByteBuffer dst) throws IOException {
55 throw new IOException();
56 }
57
58 @Override
59 public int read(ByteBuffer dst, long position) throws IOException {
60 throw new IOException();
61 }
62
63 @Override
64 public long read(ByteBuffer[] dsts, int offset, int length) throws IOException {
65 throw new IOException();
66 }
67
68 @Override
69 public long size() throws IOException {
70 throw new IOException();
71 }
72
73 @Override
74 public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException {
75 throw new IOException();
76 }
77
78 @Override
79 public long transferTo(long position, long count, WritableByteChannel target) throws IOException {
80 throw new IOException();
81 }
82
83 @Override
84 public FileChannel truncate(long size) throws IOException {
85 throw new IOException();
86 }
87
88 @Override
89 public FileLock tryLock(long position, long size, boolean shared) throws IOException {
90 throw new IOException();
91 }
92
93 @Override
94 public int write(ByteBuffer src) throws IOException {
95 throw new IOException();
96 }
97
98 @Override
99 public int write(ByteBuffer src, long position) throws IOException {
100 throw new IOException();
101 }
102
103 @Override
104 public long write(ByteBuffer[] srcs, int offset, int len) throws IOException {
105 throw new IOException();
106 }
107
108 @Override
109 public void force(boolean metaData) throws IOException {
110 throw new IOException();
111 }
112 }