de.grogra.pf.io
Class FileSource

java.lang.Object
  extended by de.grogra.pf.io.FilterSourceBase
      extended by de.grogra.pf.io.FileSource
All Implemented Interfaces:
FileReaderSource, FilterSource, InputStreamSource, ReaderSource, VirtualFileReaderSource, RegistryContext, CountingInputStream.Monitor

public class FileSource
extends FilterSourceBase
implements InputStreamSource, ReaderSource, FileReaderSource, VirtualFileReaderSource, CountingInputStream.Monitor


Nested Class Summary
 
Nested classes/interfaces inherited from interface de.grogra.pf.io.FilterSource
FilterSource.MetaDataKey<V>
 
Field Summary
 
Fields inherited from interface de.grogra.pf.io.FilterSource
AUTO_PROGRESS, DESTINATION_FILE, DESTINATION_URL
 
Constructor Summary
FileSource(java.io.File file, MimeType mimeType, Registry reg, ModifiableMap metaData)
           
FileSource(FileSystem fs, java.lang.Object file, RegistryContext reg, ModifiableMap metaData)
           
FileSource(FileSystem fs, java.lang.Object file, java.lang.String systemId, MimeType mimeType, Registry reg, ModifiableMap metaData)
           
 
Method Summary
 void bytesRead(long bytes)
           
static FileSource createFileSource(java.lang.String systemId, MimeType mimeType, RegistryContext ctx, ModifiableMap metaData)
           
 java.lang.Object getFile()
          Returns the file from which the data can be obtained.
 FileSystem getFileSystem()
          Returns the file system in which the file is contained.
 java.io.File getInputFile()
          Returns the file from which the data can be obtained.
 java.io.InputStream getInputStream()
          Returns a stream to obtain the data as a stream of bytes.
 java.io.OutputStream getOutputStream(boolean append)
           
 java.io.Reader getReader()
          Returns a reader to obtain the data as a stream of characters.
 java.lang.String getSystemId()
          Returns a system id which identifies this source.
 java.io.Writer getWriter(boolean append)
           
 boolean isReadOnly()
           
 long length()
          Returns the total number of bytes of this stream.
 java.lang.StringBuffer readContent()
           
 void streamClosed()
           
 java.net.URL toURL()
           
 
Methods inherited from class de.grogra.pf.io.FilterSourceBase
getFilter, getFlavor, getMetaData, getRegistry, initProgressMonitor, setMetaData, setProgress, setProgress0, setProgressImpl, toString, useAutoProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.grogra.pf.io.FilterSource
getFilter, getFlavor, getMetaData, initProgressMonitor, setMetaData, setProgress
 
Methods inherited from interface de.grogra.pf.registry.RegistryContext
getRegistry
 

Constructor Detail

FileSource

public FileSource(java.io.File file,
                  MimeType mimeType,
                  Registry reg,
                  ModifiableMap metaData)

FileSource

public FileSource(FileSystem fs,
                  java.lang.Object file,
                  RegistryContext reg,
                  ModifiableMap metaData)

FileSource

public FileSource(FileSystem fs,
                  java.lang.Object file,
                  java.lang.String systemId,
                  MimeType mimeType,
                  Registry reg,
                  ModifiableMap metaData)
Method Detail

bytesRead

public void bytesRead(long bytes)
Specified by:
bytesRead in interface CountingInputStream.Monitor

createFileSource

public static FileSource createFileSource(java.lang.String systemId,
                                          MimeType mimeType,
                                          RegistryContext ctx,
                                          ModifiableMap metaData)

getFile

public java.lang.Object getFile()
Description copied from interface: VirtualFileReaderSource
Returns the file from which the data can be obtained.

Specified by:
getFile in interface VirtualFileReaderSource
Returns:
file representing the data

getFileSystem

public FileSystem getFileSystem()
Description copied from interface: VirtualFileReaderSource
Returns the file system in which the file is contained.

Specified by:
getFileSystem in interface VirtualFileReaderSource
Returns:
file system

getInputFile

public java.io.File getInputFile()
Description copied from interface: FileReaderSource
Returns the file from which the data can be obtained.

Specified by:
getInputFile in interface FileReaderSource
Returns:
file representing the data

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Description copied from interface: InputStreamSource
Returns a stream to obtain the data as a stream of bytes.

Specified by:
getInputStream in interface InputStreamSource
Returns:
an input stream for the data
Throws:
java.io.IOException

getOutputStream

public java.io.OutputStream getOutputStream(boolean append)
                                     throws java.io.IOException
Throws:
java.io.IOException

getReader

public java.io.Reader getReader()
                         throws java.io.IOException
Description copied from interface: ReaderSource
Returns a reader to obtain the data as a stream of characters.

Specified by:
getReader in interface ReaderSource
Returns:
a reader for the data
Throws:
java.io.IOException

getSystemId

public java.lang.String getSystemId()
Description copied from interface: FilterSource
Returns a system id which identifies this source.

Specified by:
getSystemId in interface FilterSource
Returns:
system id

getWriter

public java.io.Writer getWriter(boolean append)
                         throws java.io.IOException
Throws:
java.io.IOException

isReadOnly

public boolean isReadOnly()

length

public long length()
Description copied from interface: InputStreamSource
Returns the total number of bytes of this stream. A negative values indicates that this number is unknown.

Specified by:
length in interface InputStreamSource
Returns:
number of bytes

readContent

public java.lang.StringBuffer readContent()
                                   throws java.io.IOException
Throws:
java.io.IOException

streamClosed

public void streamClosed()
Specified by:
streamClosed in interface CountingInputStream.Monitor

toURL

public java.net.URL toURL()