public class BufferFacadeFactory extends Object
BufferFacade
instances to wrap variety of buffer-like objects.
In addition to simple wrappers, this class will also create "offset" wrappers:
all requested locations are offset a fixed distance from the start of the
underlying buffer.
There are two factory methods (which are overloaded by buffer type and whether the facade is offset):
create()
creates a facade for single-threaded access
createThreadsafe
creates a facade that will support concurrent
access
If you don't like the factory method, the implementation classes are exposed.
Modifier and Type | Class and Description |
---|---|
static class |
BufferFacadeFactory.ByteBufferFacade
A facade for a standard Java
ByteBuffer . |
static class |
BufferFacadeFactory.ByteBufferTLFacade
A facade for a standard Java
ByteBuffer that uses a
thread-local to allow concurrent access. |
static class |
BufferFacadeFactory.MappedFileBufferTLFacade
A facade for a
MappedFileBuffer that uses a thread-local to
allow concurrent access. |
Constructor and Description |
---|
BufferFacadeFactory() |
Modifier and Type | Method and Description |
---|---|
static BufferFacade |
create(ByteBuffer buf)
Creates an instance that accesses a standard
ByteBuffer . |
static BufferFacade |
create(ByteBuffer buf,
long base)
Creates an instance that accesses a standard
ByteBuffer ,
with offsets relative to the specified base value. |
static BufferFacade |
create(MappedFileBuffer buf)
Creates an instance that accesses a
MappedFileBuffer . |
static BufferFacade |
create(MappedFileBuffer buf,
long base)
Creates an instance that accesses a
MappedFileBuffer , with
with offsets relative to the specified base value. |
static BufferFacade |
createThreadsafe(ByteBuffer buf)
Creates a thread-safe instance that accesses a standard
ByteBuffer . |
static BufferFacade |
createThreadsafe(ByteBuffer buf,
long base)
Creates a thread-safe instance that accesses a standard
ByteBuffer ,
with offsets relative to the specified base value. |
static BufferFacade |
createThreadsafe(MappedFileBuffer buf)
Creates a thread-safe instance that accesses a
MappedFileBuffer . |
static BufferFacade |
createThreadsafe(MappedFileBuffer buf,
long base)
Creates a thread-safe instance that accesses a
MappedFileBuffer ,
with offsets relative to the specified base value. |
public static BufferFacade create(ByteBuffer buf)
ByteBuffer
.
All indexes are limited to Integer.MAX_VALUE
.public static BufferFacade create(ByteBuffer buf, long base)
ByteBuffer
,
with offsets relative to the specified base value. Although the base
value is specified as a long
(for consistency with other
methods), it is limited to Integer.MAX_VALUE
and all
indexes are limited to Integer.MAX_VALUE - base
.public static BufferFacade createThreadsafe(ByteBuffer buf)
ByteBuffer
.
All indexes are limited to Integer.MAX_VALUE
.
See ByteBufferThreadLocal
for important caveats.
public static BufferFacade createThreadsafe(ByteBuffer buf, long base)
ByteBuffer
,
with offsets relative to the specified base value. Although the base value is
specified as a long
(for consistency with other methods), it is
limited to Integer.MAX_VALUE
and all indexes are limited to
Integer.MAX_VALUE - base
.
Because this method will create independent buffers for each thread, the
limit()
method may return different values. Setting a limit on
the underlying buffer will not affect buffers that have already been created.
public static BufferFacade create(MappedFileBuffer buf)
MappedFileBuffer
.public static BufferFacade create(MappedFileBuffer buf, long base)
MappedFileBuffer
, with
with offsets relative to the specified base value.public static BufferFacade createThreadsafe(MappedFileBuffer buf)
MappedFileBuffer
.public static BufferFacade createThreadsafe(MappedFileBuffer buf, long base)
MappedFileBuffer
,
with offsets relative to the specified base value.