-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ter to Oracle JDBC import module #437 [skip ci]
- Loading branch information
Showing
90 changed files
with
2,347 additions
and
1,477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
dbptk-model/src/main/java/com/databasepreservation/common/InputStreamProviderImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.databasepreservation.common; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.databasepreservation.model.exception.ModuleException; | ||
|
||
/** | ||
* @author Miguel Guimarães <mguimaraes@keep.pt> | ||
*/ | ||
public class InputStreamProviderImpl implements InputStreamProvider { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(InputStreamProviderImpl.class); | ||
|
||
private InputStream inputStream; | ||
private long size; | ||
|
||
public InputStreamProviderImpl(InputStream inputStream) { | ||
this.inputStream = inputStream; | ||
} | ||
|
||
|
||
public InputStreamProviderImpl(InputStream inputStream, long size) { | ||
this.inputStream = inputStream; | ||
this.size = size; | ||
} | ||
|
||
/** | ||
* Create a new input stream to read data | ||
* <p> | ||
* Contract: The stream must be closed elsewhere. It is not closed automatically | ||
* in any way, not even by cleanResources | ||
* | ||
* @return the new input stream | ||
* @throws ModuleException | ||
* if the input stream could not be created | ||
*/ | ||
@Override | ||
public InputStream createInputStream() throws ModuleException { | ||
return inputStream; | ||
} | ||
|
||
/** | ||
* Free all underlying resources, except for the stream itself. | ||
*/ | ||
@Override | ||
public void cleanResources() { | ||
try { | ||
inputStream.close(); | ||
} catch (IOException e) { | ||
LOGGER.debug("Could not close the stream", e); | ||
} | ||
} | ||
|
||
/** | ||
* @return the total number of bytes that can be provided by the InputStream | ||
* created with #createInputStream | ||
* @throws ModuleException | ||
* if the size could not be obtained | ||
*/ | ||
@Override | ||
public long getSize() throws ModuleException { | ||
return size; | ||
} | ||
} |
Oops, something went wrong.