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_VALUE
bytes.MemoryAsset
(SeekableInMemoryByteChannel delegate) Creates a new instance with internal memory buffer delegate using the specified (required)SeekableInMemoryByteChannel
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
boolean
isOpen()
Get a input stream for the resource content.long
position()
position
(long newPosition) int
read
(ByteBuffer dst) long
size()
truncate
(long size) int
write
(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_VALUE
bytes. -
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
public boolean isOpen() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- See Also:
-
read
- Specified by:
read
in interfaceReadableByteChannel
- Specified by:
read
in interfaceSeekableByteChannel
- Parameters:
dst
-- Returns:
- Throws:
IOException
- See Also:
-
write
- Specified by:
write
in interfaceSeekableByteChannel
- Specified by:
write
in interfaceWritableByteChannel
- Parameters:
src
-- Returns:
- Throws:
IOException
- See Also:
-
position
- Specified by:
position
in interfaceSeekableByteChannel
- Returns:
- Throws:
IOException
- See Also:
-
position
- Specified by:
position
in interfaceSeekableByteChannel
- Parameters:
newPosition
-- Returns:
- Throws:
IOException
- See Also:
-
size
- Specified by:
size
in interfaceSeekableByteChannel
- Returns:
- Throws:
IOException
- See Also:
-
truncate
- Specified by:
truncate
in 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:
openStream
in interfaceAsset
- Returns:
- A new open
InputStream
for each call - See Also:
-