public abstract class AbstractDiskHttpData extends AbstractHttpData
InterfaceHttpData.HttpDataType
definedSize, size
Modifier | Constructor and Description |
---|---|
protected |
AbstractDiskHttpData(String name,
Charset charset,
long size) |
Modifier and Type | Method and Description |
---|---|
void |
addContent(ByteBuf buffer,
boolean last)
Add the content from the ChannelBuffer
ReferenceCounted.release() ownership of buffer is transferred to this HttpData . |
void |
delete()
Deletes the underlying storage for a file item, including deleting any
associated temporary disk file.
|
protected abstract boolean |
deleteOnExit() |
byte[] |
get()
Returns the contents of the file item as an array of bytes.
|
protected abstract String |
getBaseDirectory() |
ByteBuf |
getByteBuf()
Returns the content of the file item as a ByteBuf.
|
ByteBuf |
getChunk(int length)
Returns a ChannelBuffer for the content from the current position with at
most length read bytes, increasing the current position of the Bytes
read.
|
protected abstract String |
getDiskFilename() |
File |
getFile() |
protected abstract String |
getPostfix() |
protected abstract String |
getPrefix() |
String |
getString()
Returns the contents of the file item as a String, using the default
character encoding.
|
String |
getString(Charset encoding)
Returns the contents of the file item as a String, using the specified
charset.
|
boolean |
isInMemory()
Provides a hint as to whether or not the file contents will be read from
memory.
|
boolean |
renameTo(File dest)
A convenience getMethod to write an uploaded item to disk.
|
void |
setContent(ByteBuf buffer)
Set the content from the ChannelBuffer (erase any previous data)
ReferenceCounted.release() ownership of buffer is transferred to this HttpData . |
void |
setContent(File file)
Set the content from the file (erase any previous data)
|
void |
setContent(InputStream inputStream)
Set the content from the inputStream (erase any previous data)
|
HttpData |
touch()
Records the current access location of this object for debugging purposes.
|
HttpData |
touch(Object hint)
Records the current access location of this object with an additional arbitrary information for debugging
purposes.
|
checkSize, content, deallocate, definedLength, getCharset, getMaxSize, getName, isCompleted, length, retain, retain, setCharset, setCompleted, setCompleted, setMaxSize
refCnt, release, release, setRefCnt
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
copy, duplicate, replace, retainedDuplicate
getHttpDataType
compareTo
refCnt, release, release
protected abstract String getDiskFilename()
protected abstract String getPrefix()
protected abstract String getBaseDirectory()
protected abstract String getPostfix()
protected abstract boolean deleteOnExit()
public void setContent(ByteBuf buffer) throws IOException
HttpData
ReferenceCounted.release()
ownership of buffer
is transferred to this HttpData
.
buffer
- must be not nullIOException
public void addContent(ByteBuf buffer, boolean last) throws IOException
HttpData
ReferenceCounted.release()
ownership of buffer
is transferred to this HttpData
.
buffer
- must be not null except if last is set to Falselast
- True of the buffer is the last oneIOException
public void setContent(File file) throws IOException
HttpData
file
- must be not nullIOException
public void setContent(InputStream inputStream) throws IOException
HttpData
inputStream
- must be not nullIOException
public void delete()
HttpData
public byte[] get() throws IOException
HttpData
IOException
public ByteBuf getByteBuf() throws IOException
HttpData
IOException
public ByteBuf getChunk(int length) throws IOException
HttpData
IOException
public String getString() throws IOException
HttpData
IOException
public String getString(Charset encoding) throws IOException
HttpData
encoding
- the charset to useIOException
public boolean isInMemory()
HttpData
public boolean renameTo(File dest) throws IOException
HttpData
dest
- destination file - must be not nullIOException
public File getFile() throws IOException
IOException
- if this data is not represented by a filepublic HttpData touch()
ReferenceCounted
ResourceLeakDetector
. This method is a shortcut to touch(null)
.touch
in interface ByteBufHolder
touch
in interface HttpData
touch
in interface InterfaceHttpData
touch
in interface ReferenceCounted
touch
in class AbstractHttpData
public HttpData touch(Object hint)
ReferenceCounted
ResourceLeakDetector
.touch
in interface ByteBufHolder
touch
in interface HttpData
touch
in interface InterfaceHttpData
touch
in interface ReferenceCounted
touch
in class AbstractHttpData
Copyright © 2008–2024 The Netty Project. All rights reserved.