SMILA 1.0 API documentation

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

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

public final class FileToRecordConverter
extends java.lang.Object

Utility class to create records from File objects.

Author:
stuc07

Constructor Summary
FileToRecordConverter(DataFactory factory)
           
 
Method Summary
 void addAttachment(Record record, java.lang.String pathAttribute, java.lang.String attachmentName)
          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
 

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,
                          java.lang.String pathAttribute,
                          java.lang.String attachmentName)
                   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 -
pathAttribute - name of the attribute containing the path to the file
attachmentName - name with which the attachment is stored in the record
Throws:
java.io.IOException

SMILA 1.0 API documentation