SK.gnome.dwarf.mail.mime
Class FileSource

java.lang.Object
  extended bySK.gnome.dwarf.mail.mime.FileSource
All Implemented Interfaces:
SharedInputStreamSource

public class FileSource
extends java.lang.Object
implements SharedInputStreamSource

Provides file-based shared input stream source.


Constructor Summary
FileSource(java.io.File file, int preloadLimit)
          Creates a new FileSource from the given file.
FileSource(java.lang.String filename, int preloadLimit)
          Creates a new FileSource from the given file.
 
Method Summary
 int getSize()
          Returns the size of the base stream.
 java.io.InputStream newStream(int offset, int length)
          Creates a new stream from the underlying source stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSource

public FileSource(java.lang.String filename,
                  int preloadLimit)
           throws java.io.IOException
Creates a new FileSource from the given file.

This constructor creates a java.io.File object from the given filename argument and passes it to the FileSource(File, int) constructor.

Parameters:
filename - the name of the source file
preloadLimit - maximum message size limit for preloading byte content
Throws:
java.io.IOException - if an error occurs

FileSource

public FileSource(java.io.File file,
                  int preloadLimit)
           throws java.io.IOException
Creates a new FileSource from the given file.

If the preloadLimit argument is greater than zero and the actual file size is less or equal than it, the file content will be preloaded first into a byte buffer and the subsequent streams returned from newStream(int, int) method will be always backed by the buffered data. Zero value means that the subsequent streams will be always created from a new file input stream instances.

Parameters:
file - the source file
preloadLimit - maximum message size limit for preloading byte content
Throws:
java.io.IOException - if an error occurs
Method Detail

newStream

public java.io.InputStream newStream(int offset,
                                     int length)
                              throws java.io.IOException,
                                     MimeException
Description copied from interface: SharedInputStreamSource
Creates a new stream from the underlying source stream.

The new stream begins at the offset position of the original source stream and its total length is limited to length octets.

The returned input stream may be buffered for a better efficiency.

Specified by:
newStream in interface SharedInputStreamSource
Parameters:
offset - the offset
length - the length
Returns:
the new input stream
Throws:
java.io.IOException - if an error occurs
MimeException

getSize

public int getSize()
Description copied from interface: SharedInputStreamSource
Returns the size of the base stream.

Specified by:
getSize in interface SharedInputStreamSource
Returns:
the size of the base stream


Copyright (c) 2004-2005, Gnome Ltd. All rights reserved.