- java.lang.Object
-
- com.aoapps.persistence.AbstractPersistentBuffer
-
- All Implemented Interfaces:
PersistentBuffer
,Closeable
,AutoCloseable
- Direct Known Subclasses:
LargeMappedPersistentBuffer
,MappedPersistentBuffer
,RandomAccessFileBuffer
,TwoCopyBarrierBuffer
public abstract class AbstractPersistentBuffer extends Object implements PersistentBuffer
Provides a base implementation ofPersistentBuffer
in terms of basic read/write methods. This class is not thread safe.- Author:
- AO Industries, Inc.
-
-
Field Summary
Fields Modifier and Type Field Description protected ProtectionLevel
protectionLevel
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPersistentBuffer(ProtectionLevel protectionLevel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
get(long position)
Implemented as call toget(long, byte[], int, int)
.void
get(long position, byte[] buff, int off, int len)
Implemented as calls toPersistentBuffer.getSome(long, byte[], int, int)
.boolean
getBoolean(long position)
Implemented as call toget(long)
.InputStream
getInputStream(long position, long length)
Implemented as calls toget(long)
andPersistentBuffer.getSome(long, byte[], int, int)
.int
getInt(long position)
Implemented as call toget(long, byte[], int, int)
.long
getLong(long position)
Implemented as call toget(long, byte[], int, int)
.OutputStream
getOutputStream(long position, long length)
Implemented as calls toput(long, byte)
andPersistentBuffer.put(long, byte[], int, int)
.ProtectionLevel
getProtectionLevel()
Gets the protection level currently enforced by the buffer.void
put(long position, byte value)
Implemented as call toPersistentBuffer.put(long, byte[], int, int)
.void
putInt(long position, int value)
Implemented as call toPersistentBuffer.put(long, byte[], int, int)
.void
putLong(long position, long value)
Implemented as call toPersistentBuffer.put(long, byte[], int, int)
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.aoapps.persistence.PersistentBuffer
barrier, capacity, close, ensureZeros, getSome, isClosed, put, setCapacity
-
-
-
-
Field Detail
-
protectionLevel
protected final ProtectionLevel protectionLevel
-
-
Constructor Detail
-
AbstractPersistentBuffer
protected AbstractPersistentBuffer(ProtectionLevel protectionLevel)
-
-
Method Detail
-
getProtectionLevel
public ProtectionLevel getProtectionLevel()
Description copied from interface:PersistentBuffer
Gets the protection level currently enforced by the buffer.- Specified by:
getProtectionLevel
in interfacePersistentBuffer
- See Also:
PersistentBuffer.barrier(boolean)
-
get
public void get(long position, byte[] buff, int off, int len) throws IOException
Implemented as calls toPersistentBuffer.getSome(long, byte[], int, int)
.- Specified by:
get
in interfacePersistentBuffer
- Throws:
IOException
- See Also:
PersistentBuffer.getSome(long, byte[], int, int)
-
getBoolean
public boolean getBoolean(long position) throws IOException
Implemented as call toget(long)
.- Specified by:
getBoolean
in interfacePersistentBuffer
- Throws:
IOException
- See Also:
get(long)
-
get
public byte get(long position) throws IOException
Implemented as call toget(long, byte[], int, int)
. For performance reasons, it is strongly recommended to provide a more efficient implementation of this method.- Specified by:
get
in interfacePersistentBuffer
- Throws:
IOException
- See Also:
get(long, byte[], int, int)
-
getInt
public int getInt(long position) throws IOException
Implemented as call toget(long, byte[], int, int)
.- Specified by:
getInt
in interfacePersistentBuffer
- Throws:
IOException
- See Also:
get(long, byte[], int, int)
-
getLong
public long getLong(long position) throws IOException
Implemented as call toget(long, byte[], int, int)
.- Specified by:
getLong
in interfacePersistentBuffer
- Throws:
IOException
- See Also:
get(long, byte[], int, int)
-
put
public void put(long position, byte value) throws IOException
Implemented as call toPersistentBuffer.put(long, byte[], int, int)
. For performance reasons, it is strongly recommended to provide a more efficient implementation of this method.- Specified by:
put
in interfacePersistentBuffer
- Throws:
IOException
- See Also:
PersistentBuffer.put(long, byte[], int, int)
-
putInt
public void putInt(long position, int value) throws IOException
Implemented as call toPersistentBuffer.put(long, byte[], int, int)
.- Specified by:
putInt
in interfacePersistentBuffer
- Throws:
IOException
- See Also:
PersistentBuffer.put(long, byte[], int, int)
-
putLong
public void putLong(long position, long value) throws IOException
Implemented as call toPersistentBuffer.put(long, byte[], int, int)
.- Specified by:
putLong
in interfacePersistentBuffer
- Throws:
IOException
- See Also:
PersistentBuffer.put(long, byte[], int, int)
-
getInputStream
public InputStream getInputStream(long position, long length) throws IOException, BufferUnderflowException
Implemented as calls toget(long)
andPersistentBuffer.getSome(long, byte[], int, int)
.- Specified by:
getInputStream
in interfacePersistentBuffer
- Throws:
BufferUnderflowException
- on end of fileIOException
- See Also:
get(long)
,PersistentBuffer.getSome(long, byte[], int, int)
-
getOutputStream
public OutputStream getOutputStream(long position, long length) throws IOException, BufferOverflowException
Implemented as calls toput(long, byte)
andPersistentBuffer.put(long, byte[], int, int)
.- Specified by:
getOutputStream
in interfacePersistentBuffer
- Throws:
IOException
BufferOverflowException
- See Also:
put(long, byte)
,PersistentBuffer.put(long, byte[], int, int)
-
-