Skip to content

Commit 10a2b23

Browse files
committed
Introduced the StreamProvider API
1 parent 8c761fe commit 10a2b23

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

snaploader/src/main/java/electrostatic/snaploader/filesystem/InputStreamProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
*
4141
* @author pavl_g
4242
*/
43-
public interface InputStreamProvider extends AutoCloseable {
43+
public interface InputStreamProvider extends StreamProvider {
4444

4545
/**
4646
* Retrieves the input stream object associated with this filesystem entry.

snaploader/src/main/java/electrostatic/snaploader/filesystem/OutputStreamProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
*
4141
* @author pavl_g
4242
*/
43-
public interface OutputStreamProvider extends AutoCloseable {
43+
public interface OutputStreamProvider extends StreamProvider {
4444

4545
/**
4646
* Retrieves the input stream provider object (the filesystem locator object).
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2023-2024, The Electrostatic-Sandbox Distributed Simulation Framework, jSnapLoader
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are
7+
* met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of 'Electrostatic-Sandbox' nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
package electrostatic.snaploader.filesystem;
34+
35+
/**
36+
* A generic interface providing the main entry for
37+
* all stream providers for buffered IO operations.
38+
*
39+
* @author pavl_g
40+
*/
41+
public interface StreamProvider extends AutoCloseable {
42+
43+
/**
44+
* Initializes the buffered stream handler object.
45+
*
46+
* @param size the size of the buffered IO in bytes or zero
47+
* for auto filesystem size
48+
*/
49+
void initialize(int size);
50+
51+
/**
52+
* Generates a unique hash key for this object
53+
* using an MSB to LSB spreading algorithm.
54+
*
55+
* @return an XoR operation of the MSBs (Most Significant Bits) with
56+
* the LSBs (the Least Significant Bits) of the object hash code
57+
*/
58+
default int getHashKey() {
59+
return (hashCode() >>> 16) ^ hashCode();
60+
}
61+
}

snaploader/src/main/java/electrostatic/snaploader/UnSupportedSystemError.java renamed to snaploader/src/main/java/electrostatic/snaploader/throwable/UnSupportedSystemError.java

File renamed without changes.

0 commit comments

Comments
 (0)