|
1 | 1 | /** |
2 | | - * Copyright 2015-2019 Kaitai Project: MIT license |
| 2 | + * Copyright 2015-2020 Kaitai Project: MIT license |
3 | 3 | * |
4 | 4 | * Permission is hereby granted, free of charge, to any person obtaining |
5 | 5 | * a copy of this software and associated documentation files (the |
@@ -48,25 +48,55 @@ public class ByteBufferKaitaiStream extends KaitaiStream { |
48 | 48 | * @throws IOException if file can't be read |
49 | 49 | */ |
50 | 50 | public ByteBufferKaitaiStream(String fileName) throws IOException { |
| 51 | + super(0); |
51 | 52 | fc = FileChannel.open(Paths.get(fileName), StandardOpenOption.READ); |
52 | 53 | bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); |
53 | 54 | } |
54 | 55 |
|
55 | 56 | /** |
56 | 57 | * Initializes a stream that will get data from given byte array when read. |
57 | 58 | * Internally, ByteBuffer wrapping given array will be used. |
| 59 | + * |
58 | 60 | * @param arr byte array to read |
59 | 61 | */ |
60 | 62 | public ByteBufferKaitaiStream(byte[] arr) { |
| 63 | + this(arr, 0); |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * Initializes a stream that will get data from given byte array when read. |
| 68 | + * Internally, ByteBuffer wrapping given array will be used. |
| 69 | + * |
| 70 | + * @param arr byte array to read |
| 71 | + * @param offset offset from the root stream where this stream begins |
| 72 | + * |
| 73 | + * @since 0.9 |
| 74 | + */ |
| 75 | + public ByteBufferKaitaiStream(byte[] arr, long offset) { |
| 76 | + super(offset); |
61 | 77 | fc = null; |
62 | 78 | bb = ByteBuffer.wrap(arr); |
63 | 79 | } |
64 | 80 |
|
65 | 81 | /** |
66 | 82 | * Initializes a stream that will get data from given ByteBuffer when read. |
| 83 | + * |
67 | 84 | * @param buffer ByteBuffer to read |
68 | 85 | */ |
69 | 86 | public ByteBufferKaitaiStream(ByteBuffer buffer) { |
| 87 | + this(buffer, 0); |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * Initializes a stream that will get data from given ByteBuffer when read. |
| 92 | + * |
| 93 | + * @param buffer ByteBuffer to read |
| 94 | + * @param offset offset from the root stream where this stream begins |
| 95 | + * |
| 96 | + * @since 0.9 |
| 97 | + */ |
| 98 | + public ByteBufferKaitaiStream(ByteBuffer buffer, long offset) { |
| 99 | + super(offset); |
70 | 100 | fc = null; |
71 | 101 | bb = buffer; |
72 | 102 | } |
|
0 commit comments