public abstract class AbstractDiskHttpData extends AbstractHttpData
InterfaceHttpData.HttpDataType| Modifier and Type | Field and Description |
|---|---|
private java.io.File |
file |
private java.nio.channels.FileChannel |
fileChannel |
private boolean |
isRenamed |
private static InternalLogger |
logger |
definedSize, size| Modifier | Constructor and Description |
|---|---|
protected |
AbstractDiskHttpData(java.lang.String name,
java.nio.charset.Charset charset,
long size) |
| Modifier and Type | Method and Description |
|---|---|
void |
addContent(ByteBuf buffer,
boolean last)
Add the content from the ChannelBuffer
|
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 java.lang.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 java.lang.String |
getDiskFilename() |
java.io.File |
getFile() |
protected abstract java.lang.String |
getPostfix() |
protected abstract java.lang.String |
getPrefix() |
java.lang.String |
getString()
Returns the contents of the file item as a String, using the default
character encoding.
|
java.lang.String |
getString(java.nio.charset.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.
|
private static byte[] |
readFrom(java.io.File src)
Utility function
|
boolean |
renameTo(java.io.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)
|
void |
setContent(java.io.File file)
Set the content from the file (erase any previous data)
|
void |
setContent(java.io.InputStream inputStream)
Set the content from the inputStream (erase any previous data)
|
private java.io.File |
tempFile() |
HttpData |
touch()
Records the current access location of this object for debugging purposes.
|
HttpData |
touch(java.lang.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, setMaxSizerefCnt, release, release, setRefCntclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcopy, duplicate, replace, retainedDuplicategetHttpDataTyperefCnt, release, releaseprivate static final InternalLogger logger
private java.io.File file
private boolean isRenamed
private java.nio.channels.FileChannel fileChannel
protected AbstractDiskHttpData(java.lang.String name,
java.nio.charset.Charset charset,
long size)
protected abstract java.lang.String getDiskFilename()
protected abstract java.lang.String getPrefix()
protected abstract java.lang.String getBaseDirectory()
protected abstract java.lang.String getPostfix()
protected abstract boolean deleteOnExit()
private java.io.File tempFile()
throws java.io.IOException
java.io.IOExceptionpublic void setContent(ByteBuf buffer) throws java.io.IOException
HttpDatabuffer - must be not nulljava.io.IOExceptionpublic void addContent(ByteBuf buffer, boolean last) throws java.io.IOException
HttpDatabuffer - must be not null except if last is set to Falselast - True of the buffer is the last onejava.io.IOExceptionpublic void setContent(java.io.File file)
throws java.io.IOException
HttpDatafile - must be not nulljava.io.IOExceptionpublic void setContent(java.io.InputStream inputStream)
throws java.io.IOException
HttpDatainputStream - must be not nulljava.io.IOExceptionpublic void delete()
HttpDatapublic byte[] get()
throws java.io.IOException
HttpDatajava.io.IOExceptionpublic ByteBuf getByteBuf() throws java.io.IOException
HttpDatajava.io.IOExceptionpublic ByteBuf getChunk(int length) throws java.io.IOException
HttpDatajava.io.IOExceptionpublic java.lang.String getString()
throws java.io.IOException
HttpDatajava.io.IOExceptionpublic java.lang.String getString(java.nio.charset.Charset encoding)
throws java.io.IOException
HttpDataencoding - the charset to usejava.io.IOExceptionpublic boolean isInMemory()
HttpDatapublic boolean renameTo(java.io.File dest)
throws java.io.IOException
HttpDatadest - destination file - must be not nulljava.io.IOExceptionprivate static byte[] readFrom(java.io.File src)
throws java.io.IOException
java.io.IOExceptionpublic java.io.File getFile()
throws java.io.IOException
java.io.IOException - if this data is not represented by a filepublic HttpData touch()
ReferenceCountedResourceLeakDetector. This method is a shortcut to touch(null).touch in interface ByteBufHoldertouch in interface HttpDatatouch in interface InterfaceHttpDatatouch in interface ReferenceCountedtouch in class AbstractHttpDatapublic HttpData touch(java.lang.Object hint)
ReferenceCountedResourceLeakDetector.touch in interface ByteBufHoldertouch in interface HttpDatatouch in interface InterfaceHttpDatatouch in interface ReferenceCountedtouch in class AbstractHttpData