Search in sources :

Example 1 with FileBlob

use of com.teradata.jaqy.resultset.FileBlob in project jaqy by Teradata.

the class CSVImporter method getObject.

@Override
public Object getObject(int index, ParameterInfo paramInfo, JaqyInterpreter interpreter) throws Exception {
    try {
        String value = m_record.get(index);
        if (m_naFilter) {
            for (String f : m_naValues) if (value.equals(f))
                return null;
        }
        CSVImportInfo importInfo = m_importInfoMap.get(index);
        if (importInfo != null) {
            if (value.length() == 0)
                return null;
            Path file = m_file.getRelativePath(value);
            if (!file.isFile())
                throw new FileNotFoundException("External file " + file.getPath() + " is not found.");
            if (importInfo.charset == null)
                return new FileBlob(file);
            else
                return new FileClob(file, importInfo.charset);
        }
        if (TypesUtils.isBinary(paramInfo.type))
            return StringUtils.getBytesFromHexString(value);
        return value;
    } catch (ArrayIndexOutOfBoundsException ex) {
        throw new IOException("Column " + (index + 1) + " is not found.");
    }
}
Also used : Path(com.teradata.jaqy.interfaces.Path) FileBlob(com.teradata.jaqy.resultset.FileBlob) FileClob(com.teradata.jaqy.resultset.FileClob) CSVImportInfo(com.teradata.jaqy.utils.CSVImportInfo)

Aggregations

Path (com.teradata.jaqy.interfaces.Path)1 FileBlob (com.teradata.jaqy.resultset.FileBlob)1 FileClob (com.teradata.jaqy.resultset.FileClob)1 CSVImportInfo (com.teradata.jaqy.utils.CSVImportInfo)1