public final class RandomAccessSourceFactory
extends java.lang.Object
RandomAccessSource
objects based on various types of sourcesConstructor and Description |
---|
RandomAccessSourceFactory()
Creates a factory that will give preference to accessing the underling data source using memory mapped files
|
Modifier and Type | Method and Description |
---|---|
RandomAccessSource |
createBestSource(java.lang.String filename)
Creates a
RandomAccessSource based on a filename string. |
RandomAccessSource |
createRanged(RandomAccessSource source,
long[] ranges) |
RandomAccessSource |
createSource(byte[] data)
Creates a
RandomAccessSource based on a byte array |
RandomAccessSource |
createSource(java.io.InputStream is)
Creates a
RandomAccessSource based on an InputStream . |
RandomAccessSource |
createSource(java.io.RandomAccessFile raf) |
RandomAccessSource |
createSource(java.net.URL url)
Creates a
RandomAccessSource based on a URL. |
RandomAccessSourceFactory |
setExclusivelyLockFile(boolean exclusivelyLockFile) |
RandomAccessSourceFactory |
setForceRead(boolean forceRead)
Determines whether the full content of the source will be read into memory
|
RandomAccessSourceFactory |
setUsePlainRandomAccess(boolean usePlainRandomAccess)
Determines whether
RandomAccessFile should be used as the primary data access mechanism |
public RandomAccessSourceFactory()
public RandomAccessSourceFactory setForceRead(boolean forceRead)
forceRead
- true if the full content will be read, false otherwisepublic RandomAccessSourceFactory setUsePlainRandomAccess(boolean usePlainRandomAccess)
RandomAccessFile
should be used as the primary data access mechanismusePlainRandomAccess
- whether RandomAccessFile
should be used as the primary data access mechanismpublic RandomAccessSourceFactory setExclusivelyLockFile(boolean exclusivelyLockFile)
public RandomAccessSource createSource(byte[] data)
RandomAccessSource
based on a byte arraydata
- the byte arrayRandomAccessSource
public RandomAccessSource createSource(java.io.RandomAccessFile raf) throws java.io.IOException
java.io.IOException
public RandomAccessSource createSource(java.net.URL url) throws java.io.IOException
RandomAccessSource
based on a URL. The data available at the URL is read into memory and used
as the source for the RandomAccessSource
url
- the url to read fromRandomAccessSource
java.io.IOException
public RandomAccessSource createSource(java.io.InputStream is) throws java.io.IOException
RandomAccessSource
based on an InputStream
. The full content of the InputStream is read into memory and used
as the source for the RandomAccessSource
is
- the stream to read fromRandomAccessSource
java.io.IOException
public RandomAccessSource createBestSource(java.lang.String filename) throws java.io.IOException
RandomAccessSource
based on a filename string.
If the filename describes a URL, a URL based source is created
If the filename describes a file on disk, the contents may be read into memory (if forceRead is true), opened using memory mapped file channel (if usePlainRandomAccess is false), or opened using RandomAccessFile
access (if usePlainRandomAccess is true)
This call will automatically failover to using RandomAccessFile
if the memory map operation failsfilename
- the name of the file or resource to create the RandomAccessSource
forRandomAccessSource
java.io.IOException
public RandomAccessSource createRanged(RandomAccessSource source, long[] ranges) throws java.io.IOException
java.io.IOException
Copyright © 2013. All Rights Reserved.