Interface RandomAccessData
-
- All Known Implementing Classes:
ByteArrayRandomAccessData
,RandomAccessDataFile
public interface RandomAccessData
Interface that provides read-only random access to some underlying data. Implementations must allow concurrent reads in a thread-safe manner.- Author:
- Phillip Webb
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
RandomAccessData.ResourceAccess
Lock modes for accessing the underlying resource.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description InputStream
getInputStream(RandomAccessData.ResourceAccess access)
Returns anInputStream
that can be used to read the underlying data.long
getSize()
Returns the size of the data.RandomAccessData
getSubsection(long offset, long length)
Returns a newRandomAccessData
for a specific subsection of this data.
-
-
-
Method Detail
-
getInputStream
InputStream getInputStream(RandomAccessData.ResourceAccess access) throws IOException
Returns anInputStream
that can be used to read the underlying data. The caller is responsible close the underlying stream.- Parameters:
access
- hint indicating how the underlying data should be accessed- Returns:
- a new input stream that can be used to read the underlying data.
- Throws:
IOException
- if the stream cannot be opened
-
getSubsection
RandomAccessData getSubsection(long offset, long length)
Returns a newRandomAccessData
for a specific subsection of this data.- Parameters:
offset
- the offset of the subsectionlength
- the length of the subsection- Returns:
- the subsection data
-
getSize
long getSize()
Returns the size of the data.- Returns:
- the size
-
-