Class MemoryAsset
java.lang.Object
org.jboss.shrinkwrap.api.nio.file.MemoryAsset
- All Implemented Interfaces:
Closeable, AutoCloseable, ByteChannel, Channel, ReadableByteChannel, SeekableByteChannel, WritableByteChannel, Asset
- Direct Known Subclasses:
MemoryNamedAsset
An
Asset implementation backed by an internal memory representation; able to be directly added to an
Archive, and supports all operations designated by the NIO.2 SeekableByteChannel API. Thread-safe.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with internal memory buffer initially sized at 0 and at position 0, capable of holding a maximum ofInteger.MAX_VALUEbytes.MemoryAsset(SeekableInMemoryByteChannel delegate) Creates a new instance with internal memory buffer delegate using the specified (required)SeekableInMemoryByteChannel -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanisOpen()Get a input stream for the resource content.longposition()position(long newPosition) intread(ByteBuffer dst) longsize()truncate(long size) intwrite(ByteBuffer src)
-
Field Details
-
delegate
-
-
Constructor Details
-
MemoryAsset
public MemoryAsset()Creates a new instance with internal memory buffer initially sized at 0 and at position 0, capable of holding a maximum ofInteger.MAX_VALUEbytes. -
MemoryAsset
MemoryAsset(SeekableInMemoryByteChannel delegate) throws IllegalArgumentException Creates a new instance with internal memory buffer delegate using the specified (required)SeekableInMemoryByteChannel- Parameters:
delegate-- Throws:
IllegalArgumentException
-
-
Method Details
-
isOpen
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException- See Also:
-
read
- Specified by:
readin interfaceReadableByteChannel- Specified by:
readin interfaceSeekableByteChannel- Parameters:
dst-- Returns:
- Throws:
IOException- See Also:
-
write
- Specified by:
writein interfaceSeekableByteChannel- Specified by:
writein interfaceWritableByteChannel- Parameters:
src-- Returns:
- Throws:
IOException- See Also:
-
position
- Specified by:
positionin interfaceSeekableByteChannel- Returns:
- Throws:
IOException- See Also:
-
position
- Specified by:
positionin interfaceSeekableByteChannel- Parameters:
newPosition-- Returns:
- Throws:
IOException- See Also:
-
size
- Specified by:
sizein interfaceSeekableByteChannel- Returns:
- Throws:
IOException- See Also:
-
truncate
- Specified by:
truncatein interfaceSeekableByteChannel- Parameters:
size-- Returns:
- Throws:
IOException- See Also:
-
openStream
Get a input stream for the resource content. The caller is responsible for closing the stream.- Specified by:
openStreamin interfaceAsset- Returns:
- A new open
InputStreamfor each call - See Also:
-