FileResourceSource (RabbIT/4)
Date: 2009-10-13

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rabbit.httpio
Class FileResourceSource

    java.lang.Object
      rabbit.httpio.FileResourceSource

All Implemented Interfaces:
  ResourceSource, Transferable

Direct Known Subclasses:
  CacheResourceSource

    public class FileResourceSource

extends Object
implements ResourceSource

A resource that comes from a file.

Author:
  Robert Olofsson

Field Summary
`protected BufferHandle` | `bufHandle`
`protected FileChannel` | `fc`

Constructor Summary
`FileResourceSource(File f, NioHandler nioHandler, BufferHandler bufHandler)`
`FileResourceSource(String filename, NioHandler nioHandler, BufferHandler bufHandler)`

Method Summary
`void` | `addBlockListener(BlockListener listener)` Generally we do not come into this method, but it can happen..
`long` | `length()` Get the length of the resource in bytes.
`void` | `release()` Release any held resources.
`boolean` | `supportsTransfer()` FileChannels can be used, will always return true.
`long` | `transferTo(long position, long count, WritableByteChannel target)` Transfers bytes from this channel's file to the given writable byte channel.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### fc

    protected FileChannel fc

### bufHandle

    protected BufferHandle bufHandle

Constructor Detail

### FileResourceSource

    public FileResourceSource(String filename,
                              NioHandler nioHandler,
                              BufferHandler bufHandler)
                       throws IOException

Throws:
  `IOException`

### FileResourceSource

    public FileResourceSource(File f,
                              NioHandler nioHandler,
                              BufferHandler bufHandler)
                       throws IOException

Throws:
  `IOException`

Method Detail

### supportsTransfer

    public boolean supportsTransfer()

  FileChannels can be used, will always return true.

  Specified by:
    `supportsTransfer` in interface `ResourceSource`
  Returns:
    true

### length

    public long length()

  Description copied from interface: `Transferable`
  Get the length of the resource in bytes.

  Specified by:
    `length` in interface `Transferable`
  Returns:
    the size of the resource or -1 if unknown.

### transferTo

    public long transferTo(long position,
                           long count,
                           WritableByteChannel target)
                    throws IOException

  Description copied from interface: `Transferable`
  Transfers bytes from this channel's file to the given writable byte channel.

  Specified by:
    `transferTo` in interface `Transferable`
  Parameters:
    `position` - The position within the file at which the transfer is to begin; must be non-negative
    `count` - The maximum number of bytes to be transferred; must be non-negative
    `target` - The target channel
  Returns:
    The number of bytes, possibly zero, that were actually transferred
  Throws:
    `IOException`
  See Also:
    `transferTo`

### addBlockListener

    public void addBlockListener(BlockListener listener)

  Generally we do not come into this method, but it can happen..

  Specified by:
    `addBlockListener` in interface `ResourceSource`

### release

    public void release()

  Description copied from interface: `ResourceSource`
  Release any held resources.

  Specified by:
    `release` in interface `ResourceSource`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD