Skip to content
Snippets Groups Projects
Commit 830bf0e0 authored by Greg DiCristofaro's avatar Greg DiCristofaro
Browse files

return optional

parent 5066e978
No related branches found
No related tags found
No related merge requests found
......@@ -1080,7 +1080,7 @@ private boolean loadContentStream() throws TskCoreException {
return true;
} else if (tryContentStream) {
// only attempt to load if the flag indicates it should be tried
contentStream = getSleuthkitCase().getContentProvider().getContentStream(this);
contentStream = getSleuthkitCase().getContentProvider().getContentStream(this).orElse(null);
if (contentStream == null) {
// if no content stream could be loaded, mark tryContentStream as false so load
......@@ -1106,15 +1106,11 @@ private boolean useContentProvider() {
@Override
public final int read(byte[] buf, long offset, long len) throws TskCoreException {
//template method
//if localPath is set, use local, otherwise, use readCustom() supplied by derived class
if (useContentProvider()) {
if (loadContentStream()) {
return this.contentStream.read(buf, offset, len);
} else {
return 0;
}
if (useContentProvider() && loadContentStream()) {
return this.contentStream.read(buf, offset, len);
}
//if localPath is set, use local, otherwise, use readCustom() supplied by derived class
if (localPathSet) {
return readLocal(buf, offset, len);
} else {
......
......@@ -18,6 +18,8 @@
*/
package org.sleuthkit.datamodel;
import java.util.Optional;
/**
* Custom provider for content bytes.
*/
......@@ -44,14 +46,14 @@ public interface ContentStream {
public interface ContentProvider {
/**
* Provides a content stream for a content object or null if this
* Provides a content stream for a content object or empty if this
* provider has none to provide.
*
* @param content The content.
*
* @return The content stream or null if no stream can be provided
* @return The content stream or empty if no stream can be provided
* for this content.
*/
ContentStream getContentStream(Content content) throws TskCoreException;
Optional<ContentStream> getContentStream(Content content) throws TskCoreException;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment