public class MemoryAsset extends java.lang.Object implements Asset, java.nio.channels.SeekableByteChannel
Modifier and Type | Field and Description |
---|---|
private SeekableInMemoryByteChannel |
delegate |
Constructor and Description |
---|
MemoryAsset()
Creates a new instance with internal memory buffer initially sized at 0 and at position 0, capable of holding a
maximum of
Integer.MAX_VALUE bytes. |
MemoryAsset(SeekableInMemoryByteChannel delegate)
Creates a new instance with internal memory buffer delegate using the specified (required)
SeekableInMemoryByteChannel |
Modifier and Type | Method and Description |
---|---|
void |
close() |
boolean |
isOpen() |
java.io.InputStream |
openStream()
Get a input stream for the resource content.
|
long |
position() |
java.nio.channels.SeekableByteChannel |
position(long newPosition) |
int |
read(java.nio.ByteBuffer dst) |
long |
size() |
java.nio.channels.SeekableByteChannel |
truncate(long size) |
int |
write(java.nio.ByteBuffer src) |
private final SeekableInMemoryByteChannel delegate
public MemoryAsset()
Integer.MAX_VALUE
bytes.MemoryAsset(SeekableInMemoryByteChannel delegate) throws java.lang.IllegalArgumentException
SeekableInMemoryByteChannel
delegate
- java.lang.IllegalArgumentException
public boolean isOpen()
isOpen
in interface java.nio.channels.Channel
Channel.isOpen()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface java.nio.channels.Channel
java.io.IOException
Channel.close()
public int read(java.nio.ByteBuffer dst) throws java.io.IOException
read
in interface java.nio.channels.ReadableByteChannel
read
in interface java.nio.channels.SeekableByteChannel
dst
- java.io.IOException
SeekableByteChannel.read(java.nio.ByteBuffer)
public int write(java.nio.ByteBuffer src) throws java.io.IOException
write
in interface java.nio.channels.SeekableByteChannel
write
in interface java.nio.channels.WritableByteChannel
src
- java.io.IOException
SeekableByteChannel.write(java.nio.ByteBuffer)
public long position() throws java.io.IOException
position
in interface java.nio.channels.SeekableByteChannel
java.io.IOException
SeekableByteChannel.position()
public java.nio.channels.SeekableByteChannel position(long newPosition) throws java.io.IOException
position
in interface java.nio.channels.SeekableByteChannel
newPosition
- java.io.IOException
SeekableByteChannel.position(long)
public long size() throws java.io.IOException
size
in interface java.nio.channels.SeekableByteChannel
java.io.IOException
SeekableByteChannel.size()
public java.nio.channels.SeekableByteChannel truncate(long size) throws java.io.IOException
truncate
in interface java.nio.channels.SeekableByteChannel
size
- java.io.IOException
SeekableByteChannel.truncate(long)
public java.io.InputStream openStream()
openStream
in interface Asset
InputStream
for each callAsset.openStream()