SMILA 1.0 API documentation

org.eclipse.smila.importing.crawler.file
Class FileToRecordConverter

java.lang.Object
  extended by org.eclipse.smila.importing.crawler.file.FileToRecordConverter

public final class FileToRecordConverter
extends java.lang.Object

Utility class to create records from File objects.

Author:
stuc07

Field Summary
static java.lang.String ATTACHMENT_FILE_CONTENT
           
static java.lang.String PROPERTY_FILE_EXTENSION
           
static java.lang.String PROPERTY_FILE_FOLDER
           
static java.lang.String PROPERTY_FILE_LAST_MODIFIED
           
static java.lang.String PROPERTY_FILE_NAME
           
static java.lang.String PROPERTY_FILE_PATH
           
static java.lang.String PROPERTY_FILE_SIZE
           
 
Constructor Summary
FileToRecordConverter(DataFactory factory)
           
 
Method Summary
 void addAttachment(Record record)
          Add the content attachment to the given record.
 Record dirToRecord(java.io.File directory, java.lang.String dataSource)
          Create a Record for the given directory and dataSource and fill it with ImportingConstants.ROOT_FOLDER_ATTRIBUTE.
 Record fileToRecord(java.io.File file, java.lang.String dataSource, boolean withContent)
          Create a Record for the given file and dataSource and fill it with all file properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_FILE_NAME

public static final java.lang.String PROPERTY_FILE_NAME
See Also:
Constant Field Values

PROPERTY_FILE_PATH

public static final java.lang.String PROPERTY_FILE_PATH
See Also:
Constant Field Values

PROPERTY_FILE_FOLDER

public static final java.lang.String PROPERTY_FILE_FOLDER
See Also:
Constant Field Values

PROPERTY_FILE_SIZE

public static final java.lang.String PROPERTY_FILE_SIZE
See Also:
Constant Field Values

PROPERTY_FILE_LAST_MODIFIED

public static final java.lang.String PROPERTY_FILE_LAST_MODIFIED
See Also:
Constant Field Values

PROPERTY_FILE_EXTENSION

public static final java.lang.String PROPERTY_FILE_EXTENSION
See Also:
Constant Field Values

ATTACHMENT_FILE_CONTENT

public static final java.lang.String ATTACHMENT_FILE_CONTENT
See Also:
Constant Field Values
Constructor Detail

FileToRecordConverter

public FileToRecordConverter(DataFactory factory)
Method Detail

fileToRecord

public Record fileToRecord(java.io.File file,
                           java.lang.String dataSource,
                           boolean withContent)
                    throws java.io.IOException
Create a Record for the given file and dataSource and fill it with all file properties. Optionally also fill with content attachment.

Parameters:
file -
dataSource -
withContent - if true fill also content attachment, otherwise not
Returns:
a Record
Throws:
java.io.IOException

dirToRecord

public Record dirToRecord(java.io.File directory,
                          java.lang.String dataSource)
Create a Record for the given directory and dataSource and fill it with ImportingConstants.ROOT_FOLDER_ATTRIBUTE.

Parameters:
directory -
dataSource -
Returns:
a record

addAttachment

public void addAttachment(Record record)
                   throws java.io.IOException
Add the content attachment to the given record. The file content is expected to be referenced by PROPERTY_FILE_PATH in the record.

Parameters:
record -
Throws:
java.io.IOException

SMILA 1.0 API documentation