org.apache.solr.handler.dataimport
Class FileDataSource

java.lang.Object
  extended by org.apache.solr.handler.dataimport.DataSource<Reader>
      extended by org.apache.solr.handler.dataimport.FileDataSource

public class FileDataSource
extends DataSource<Reader>

A DataSource which reads from local files

The file is read with the default platform encoding. It can be overriden by specifying the encoding in solrconfig.xml

Refer to http://wiki.apache.org/solr/DataImportHandler for more details.

This API is experimental and may change in the future.

Since:
solr 1.3
Version:
$Id: FileDataSource.java 681182 2008-07-30 19:35:58Z shalin $

Field Summary
static String BASE_PATH
           
 
Constructor Summary
FileDataSource()
           
 
Method Summary
 void close()
          Cleans up resources of this DataSource after use.
 Reader getData(String query)
           Returns a reader for the given file.
 void init(Context context, Properties initProps)
          Initializes the DataSource with the Context and initialization properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_PATH

public static final String BASE_PATH
See Also:
Constant Field Values
Constructor Detail

FileDataSource

public FileDataSource()
Method Detail

init

public void init(Context context,
                 Properties initProps)
Description copied from class: DataSource
Initializes the DataSource with the Context and initialization properties.

This is invoked by the DataImporter after creating an instance of this class.

Specified by:
init in class DataSource<Reader>

getData

public Reader getData(String query)

Returns a reader for the given file.

If the given file is not absolute, we try to construct an absolute path using basePath configuration. If that fails, then the relative path is tried. If file is not found a RuntimeException is thrown.

It is the responsibility of the calling method to properly close the returned Reader

Specified by:
getData in class DataSource<Reader>
Parameters:
query - The query string. It can be a SQL for JdbcDataSource or a URL for HttpDataSource or a file location for FileDataSource or a custom format for your own custom DataSource.
Returns:
Depends on the implementation. For instance JdbcDataSource returns an Iterator>

close

public void close()
Description copied from class: DataSource
Cleans up resources of this DataSource after use.

Specified by:
close in class DataSource<Reader>


Copyright © 2008 Apache Software Foundation. All Rights Reserved.