public class ManagedMemoryDataSource extends Object implements DataSource
Modifier and Type | Field and Description |
---|---|
protected BufferedOutputStream |
cachediskstream
This is the cached disk stream.
|
protected boolean |
closed
If true the source input stream is now closed.
|
protected String |
contentType
The content type.
|
protected byte[] |
currentMemoryBuf
Hold the last memory buffer.
|
protected int |
currentMemoryBufSz
The number of bytes written to the above buffer.
|
protected boolean |
debugEnabled
Field debugEnabled
|
protected boolean |
deleted
Flag to show if the resources behind this have been deleted.
|
protected File |
diskCacheFile
Field diskCacheFile
|
protected static org.apache.commons.logging.Log |
is_log
Field is_log
|
protected static org.apache.commons.logging.Log |
log
Field log
|
static int |
MAX_MEMORY_DISK_CACHED
Field MAX_MEMORY_DISK_CACHED
|
protected int |
maxCached
Field maxCached
|
protected LinkedList |
memorybuflist
The linked list to hold the in memory buffers.
|
static int |
MIN_MEMORY_DISK_CACHED
Field MIN_MEMORY_DISK_CACHED
|
static int |
READ_CHUNK_SZ
Field READ_CHUNK_SZ
|
protected WeakHashMap |
readers
Field readers
|
protected long |
totalsz
The total size in bytes in this data source.
|
Modifier | Constructor and Description |
---|---|
protected |
ManagedMemoryDataSource()
Constructor ManagedMemoryDataSource.
|
|
ManagedMemoryDataSource(InputStream ss,
int maxCached,
String contentType)
Create a new boundary stream.
|
|
ManagedMemoryDataSource(InputStream ss,
int maxCached,
String contentType,
boolean readall)
Create a new boundary stream.
|
Modifier and Type | Method and Description |
---|---|
protected void |
close()
This method is a low level write.
|
boolean |
delete() |
protected void |
finalize() |
protected void |
flushToDisk()
Routine to flush data to disk if is in memory.
|
String |
getContentType()
This method returns the MIME type of the data in the form of a string.
|
File |
getDiskCacheFile()
get the filename of the content if it is cached to disk.
|
InputStream |
getInputStream()
This method returns an InputStream representing the the data and throws the appropriate exception if it can not do so.
|
String |
getName()
This will flush any memory source to disk and
provide the name of the file if desired.
|
OutputStream |
getOutputStream()
This method returns an OutputStream where the data can be written and
throws the appropriate exception if it can not do so.
|
static void |
main(String[] arg)
Method main
|
protected void |
write(byte[] data)
Write bytes to the stream.
|
protected void |
write(byte[] data,
int length)
This method is a low level write.
|
protected static org.apache.commons.logging.Log log
protected String contentType
application/octet-stream
.public static final int MIN_MEMORY_DISK_CACHED
public static final int MAX_MEMORY_DISK_CACHED
protected int maxCached
protected File diskCacheFile
protected WeakHashMap readers
protected boolean deleted
public static final int READ_CHUNK_SZ
protected boolean debugEnabled
protected LinkedList memorybuflist
protected byte[] currentMemoryBuf
protected int currentMemoryBufSz
protected long totalsz
protected BufferedOutputStream cachediskstream
protected boolean closed
protected static org.apache.commons.logging.Log is_log
protected ManagedMemoryDataSource()
public ManagedMemoryDataSource(InputStream ss, int maxCached, String contentType) throws IOException
ss
- is the source input stream that is used to create this data source.maxCached
- This is the max memory that is to be used to cache the data.contentType
- the mime type for this data stream.
by buffering you can some effiency in searching.IOException
public ManagedMemoryDataSource(InputStream ss, int maxCached, String contentType, boolean readall) throws IOException
ss
- is the source input stream that is used to create this data source.maxCached
- This is the max memory that is to be used to cache the data.contentType
- the mime type for this data stream.
by buffering you can some effiency in searching.readall
- if true will read in the whole source.IOException
public String getContentType()
getContentType
in interface DataSource
public InputStream getInputStream() throws IOException
getInputStream
in interface DataSource
IOException
public String getName()
getName
in interface DataSource
public OutputStream getOutputStream() throws IOException
getOutputStream
in interface DataSource
null
IOException
protected void write(byte[] data) throws IOException
data
- all bytes of this array are written to the streamIOException
- if there was a problem writing the dataprotected void write(byte[] data, int length) throws IOException
data
- length
- IOException
protected void close() throws IOException
IOException
protected void finalize() throws Throwable
protected void flushToDisk() throws IOException, FileNotFoundException
IOException
FileNotFoundException
public boolean delete()
public static void main(String[] arg)
arg
- public File getDiskCacheFile()
Copyright © The Apache Software Foundation. All Rights Reserved.