Top Description Fields Constructors Methods
io.netty.handler.codec.http.multipart

public abstract Class AbstractMemoryHttpData

extends AbstractHttpData
Class Inheritance
Known Direct Subclasses
io.netty.handler.codec.http.multipart.MemoryAttribute, io.netty.handler.codec.http.multipart.MemoryFileUpload
Imports
io.netty.buffer.ByteBuf, .CompositeByteBuf, io.netty.handler.codec.http.HttpConstants, io.netty.util.internal.ObjectUtil, java.io.File, .IOException, .InputStream, .RandomAccessFile, java.nio.ByteBuffer, java.nio.channels.FileChannel, java.nio.charset.Charset

Abstract Memory HttpData implementation

Field Summary

Modifier and TypeField and Description
private ByteBuf
private int
Inherited from io.netty.handler.codec.http.multipart.AbstractHttpData:
definedSizesize

Constructor Summary

AccessConstructor and Description
protected
AbstractMemoryHttpData(String name, Charset charset, long size)

Method Summary

Modifier and TypeMethod and Description
public void
addContent(ByteBuf
must be not null except if last is set to False
buffer
,
boolean
True of the buffer is the last one
last
)

Implements io.netty.handler.codec.http.multipart.HttpData.addContent.

Add the content from the ChannelBuffer

ByteBuf#release() ownership of buffer is transferred to this HttpData.

public void
delete()

Implements io.netty.handler.codec.http.multipart.HttpData.delete.

Deletes the underlying storage for a file item, including deleting any associated temporary disk file.
public byte[]
get()

Implements io.netty.handler.codec.http.multipart.HttpData.get.

Returns the contents of the file item as an array of bytes.
public ByteBuf

Returns:

the attached ByteBuf containing the actual bytes
getByteBuf
()

Implements io.netty.handler.codec.http.multipart.HttpData.getByteBuf.

Utility to go from a In Memory FileUpload to a Disk (or another implementation) FileUpload
public ByteBuf
getChunk(int length)

Implements io.netty.handler.codec.http.multipart.HttpData.getChunk.

Returns a ChannelBuffer for the content from the current position with at most length read bytes, increasing the current position of the Bytes read.
public File
public String
getString()

Implements io.netty.handler.codec.http.multipart.HttpData.getString.

Returns the contents of the file item as a String, using the default character encoding.
public String
getString(Charset
the charset to use
encoding
)

Implements io.netty.handler.codec.http.multipart.HttpData.getString.

Returns the contents of the file item as a String, using the specified charset.
public boolean
isInMemory()

Implements io.netty.handler.codec.http.multipart.HttpData.isInMemory.

Provides a hint as to whether or not the file contents will be read from memory.
public boolean
renameTo(File
destination file - must be not null
dest
)

Implements io.netty.handler.codec.http.multipart.HttpData.renameTo.

A convenience getMethod to write an uploaded item to disk.
public void
setContent(ByteBuf
must be not null
buffer
)

Implements io.netty.handler.codec.http.multipart.HttpData.setContent.

Set the content from the ChannelBuffer (erase any previous data)

ByteBuf#release() ownership of buffer is transferred to this HttpData.

public void
setContent(InputStream
must be not null
inputStream
)

Implements io.netty.handler.codec.http.multipart.HttpData.setContent.

Set the content from the inputStream (erase any previous data)
public void
setContent(File
must be not null
file
)

Implements io.netty.handler.codec.http.multipart.HttpData.setContent.

Set the content from the file (erase any previous data)
public HttpData
touch()

Implements abstract io.netty.handler.codec.http.multipart.AbstractHttpData.touch.

Implements io.netty.handler.codec.http.multipart.HttpData.touch, io.netty.util.ReferenceCounted.touch.

Records the current access location of this object for debugging purposes.
public HttpData
touch(Object hint)

Implements abstract io.netty.handler.codec.http.multipart.AbstractHttpData.touch.

Implements io.netty.handler.codec.http.multipart.HttpData.touch, io.netty.util.ReferenceCounted.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes.
Inherited from io.netty.handler.codec.http.multipart.AbstractHttpData:
checkSizecontentdeallocatedefinedLengthgetCharsetgetMaxSizegetNameisCompletedlengthretainretainsetCharsetsetCompletedsetCompletedsetMaxSize

Field Detail

byteBufback to summary
private ByteBuf byteBuf
chunkPositionback to summary
private int chunkPosition

Constructor Detail

AbstractMemoryHttpDataback to summary
protected AbstractMemoryHttpData(String name, Charset charset, long size)

Method Detail

addContentback to summary
public void addContent(ByteBuf buffer, boolean last) throws IOException

Implements io.netty.handler.codec.http.multipart.HttpData.addContent.

Doc from io.netty.handler.codec.http.multipart.HttpData.addContent.

Add the content from the ChannelBuffer

ByteBuf#release() ownership of buffer is transferred to this HttpData.

Parameters
buffer:ByteBuf

must be not null except if last is set to False

last:boolean

True of the buffer is the last one

Annotations
@Override
deleteback to summary
public void delete()

Implements io.netty.handler.codec.http.multipart.HttpData.delete.

Doc from io.netty.handler.codec.http.multipart.HttpData.delete.

Deletes the underlying storage for a file item, including deleting any associated temporary disk file.

Annotations
@Override
getback to summary
public byte[] get()

Implements io.netty.handler.codec.http.multipart.HttpData.get.

Doc from io.netty.handler.codec.http.multipart.HttpData.get.

Returns the contents of the file item as an array of bytes.

Note

this method will allocate a lot of memory, if the data is currently stored on the file system.

Returns:byte[]

the contents of the file item as an array of bytes.

Annotations
@Override
getByteBufback to summary
public ByteBuf getByteBuf()

Implements io.netty.handler.codec.http.multipart.HttpData.getByteBuf.

Utility to go from a In Memory FileUpload to a Disk (or another implementation) FileUpload

Returns:ByteBuf

the attached ByteBuf containing the actual bytes

Annotations
@Override
getChunkback to summary
public ByteBuf getChunk(int length) throws IOException

Implements io.netty.handler.codec.http.multipart.HttpData.getChunk.

Doc from io.netty.handler.codec.http.multipart.HttpData.getChunk.

Returns a ChannelBuffer for the content from the current position with at most length read bytes, increasing the current position of the Bytes read. Once it arrives at the end, it returns an EMPTY_BUFFER and it resets the current position to 0.

Returns:ByteBuf

a ChannelBuffer for the content from the current position or an EMPTY_BUFFER if there is no more data to return

Annotations
@Override
getFileback to summary
public File getFile() throws IOException

Implements io.netty.handler.codec.http.multipart.HttpData.getFile.

Returns:File

Doc from io.netty.handler.codec.http.multipart.HttpData.getFile.

the associated File if this data is represented in a file

Annotations
@Override
Exceptions
IOException:

Doc from io.netty.handler.codec.http.multipart.HttpData.getFile.

if this data is not represented by a file

getStringback to summary
public String getString()

Implements io.netty.handler.codec.http.multipart.HttpData.getString.

Doc from io.netty.handler.codec.http.multipart.HttpData.getString.

Returns the contents of the file item as a String, using the default character encoding.

Returns:String

the contents of the file item as a String, using the default character encoding.

Annotations
@Override
getStringback to summary
public String getString(Charset encoding)

Implements io.netty.handler.codec.http.multipart.HttpData.getString.

Doc from io.netty.handler.codec.http.multipart.HttpData.getString.

Returns the contents of the file item as a String, using the specified charset.

Parameters
encoding:Charset

the charset to use

Returns:String

the contents of the file item as a String, using the specified charset.

Annotations
@Override
isInMemoryback to summary
public boolean isInMemory()

Implements io.netty.handler.codec.http.multipart.HttpData.isInMemory.

Doc from io.netty.handler.codec.http.multipart.HttpData.isInMemory.

Provides a hint as to whether or not the file contents will be read from memory.

Returns:boolean

True if the file contents is in memory.

Annotations
@Override
renameToback to summary
public boolean renameTo(File dest) throws IOException

Implements io.netty.handler.codec.http.multipart.HttpData.renameTo.

Doc from io.netty.handler.codec.http.multipart.HttpData.renameTo.

A convenience getMethod to write an uploaded item to disk. If a previous one exists, it will be deleted. Once this getMethod is called, if successful, the new file will be out of the cleaner of the factory that creates the original InterfaceHttpData object.

Parameters
dest:File

destination file - must be not null

Returns:boolean

True if the write is successful

Annotations
@Override
setContentback to summary
public void setContent(ByteBuf buffer) throws IOException

Implements io.netty.handler.codec.http.multipart.HttpData.setContent.

Doc from io.netty.handler.codec.http.multipart.HttpData.setContent.

Set the content from the ChannelBuffer (erase any previous data)

ByteBuf#release() ownership of buffer is transferred to this HttpData.

Parameters
buffer:ByteBuf

must be not null

Annotations
@Override
setContentback to summary
public void setContent(InputStream inputStream) throws IOException

Implements io.netty.handler.codec.http.multipart.HttpData.setContent.

Doc from io.netty.handler.codec.http.multipart.HttpData.setContent.

Set the content from the inputStream (erase any previous data)

Parameters
inputStream:InputStream

must be not null

Annotations
@Override
setContentback to summary
public void setContent(File file) throws IOException

Implements io.netty.handler.codec.http.multipart.HttpData.setContent.

Doc from io.netty.handler.codec.http.multipart.HttpData.setContent.

Set the content from the file (erase any previous data)

Parameters
file:File

must be not null

Annotations
@Override
touchback to summary
public HttpData touch()

Implements abstract io.netty.handler.codec.http.multipart.AbstractHttpData.touch.

Implements io.netty.handler.codec.http.multipart.HttpData.touch, io.netty.util.ReferenceCounted.touch.

Doc from io.netty.util.ReferenceCounted.touch.

Records the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector. This method is a shortcut to touch(null).

Annotations
@Override
touchback to summary
public HttpData touch(Object hint)

Implements abstract io.netty.handler.codec.http.multipart.AbstractHttpData.touch.

Implements io.netty.handler.codec.http.multipart.HttpData.touch, io.netty.util.ReferenceCounted.touch.

Doc from io.netty.util.ReferenceCounted.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector.

Annotations
@Override