Examples of CsvRecord


Examples of org.apache.camel.dataformat.bindy.annotation.CsvRecord

     */
    private void initCsvRecordParameters() {
        if (separator == null) {
            for (Class<?> cl : models) {
                // Get annotation @CsvRecord from the class
                CsvRecord record = cl.getAnnotation(CsvRecord.class);

                if (record != null) {

                    // Get skipFirstLine parameter
                    skipFirstLine = record.skipFirstLine();
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Skip First Line parameter of the CSV : " + skipFirstLine);
                    }

                    // Get Separator parameter
                    ObjectHelper.notNull(record.separator(),
                        "No separator has been defined in the @Record annotation !");
                    separator = record.separator();
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Separator defined for the CSV : " + separator);
                    }
                   
                    // Get carriage return parameter
                    crlf = record.crlf();
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Carriage return defined for the CSV : " + crlf);
                    }
                }
            }
View Full Code Here

Examples of org.apache.camel.dataformat.bindy.annotation.CsvRecord

    private void initCsvRecordParameters() {
        if (separator == null) {
            for (Class<?> cl : models) {

                // Get annotation @CsvRecord from the class
                CsvRecord record = cl.getAnnotation(CsvRecord.class);

                // Get annotation @Section from the class
                Section section = cl.getAnnotation(Section.class);

                if (record != null) {
                    LOG.debug("Csv record: {}", record);

                    // Get skipFirstLine parameter
                    skipFirstLine = record.skipFirstLine();
                    LOG.debug("Skip First Line parameter of the CSV: {}" + skipFirstLine);

                    // Get generateHeaderColumnNames parameter
                    generateHeaderColumnNames = record.generateHeaderColumns();
                    LOG.debug("Generate header column names parameter of the CSV: {}", generateHeaderColumnNames);

                    // Get Separator parameter
                    ObjectHelper.notNull(record.separator(), "No separator has been defined in the @Record annotation");
                    separator = record.separator();
                    LOG.debug("Separator defined for the CSV: {}", separator);

                    // Get carriage return parameter
                    crlf = record.crlf();
                    LOG.debug("Carriage return defined for the CSV: {}", crlf);

                    // Get isOrdered parameter
                    messageOrdered = record.isOrdered();
                    LOG.debug("Must CSV record be ordered: {}", messageOrdered);

                    if (ObjectHelper.isNotEmpty(record.quote())) {
                        quote = record.quote();
                        LOG.debug("Quoting columns with: {}", quote);
                    }

                    quoting = record.quoting();
                    LOG.debug("CSV will be quoted: {}", messageOrdered);
                }

                if (section != null) {
                    // Test if section number is not null
View Full Code Here

Examples of org.apache.camel.dataformat.bindy.annotation.CsvRecord

    private void initCsvRecordParameters() {
        if (separator == null) {
            for (Class<?> cl : models) {

                // Get annotation @CsvRecord from the class
                CsvRecord record = cl.getAnnotation(CsvRecord.class);

                // Get annotation @Section from the class
                Section section = cl.getAnnotation(Section.class);

                if (record != null) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Csv record : " + record.toString());
                    }

                    // Get skipFirstLine parameter
                    skipFirstLine = record.skipFirstLine();
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Skip First Line parameter of the CSV : " + skipFirstLine);
                    }

                    // Get generateHeaderColumnNames parameter
                    generateHeaderColumnNames = record.generateHeaderColumns();
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Generate header column names parameter of the CSV : " + generateHeaderColumnNames);
                    }

                    // Get Separator parameter
                    ObjectHelper.notNull(record.separator(), "No separator has been defined in the @Record annotation !");
                    separator = record.separator();
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Separator defined for the CSV : " + separator);
                    }

                    // Get carriage return parameter
                    crlf = record.crlf();
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Carriage return defined for the CSV : " + crlf);
                    }

                    // Get isOrdered parameter
                    messageOrdered = record.isOrdered();
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Must CSV record be ordered ? " + messageOrdered);
                    }

                }
View Full Code Here

Examples of org.apache.commons.csv.CSVRecord

public class CsvToKeyValueMapperTest {

    @Test
    public void testCsvLineParser() throws IOException {
        CsvToKeyValueMapper.CsvLineParser lineParser = new CsvToKeyValueMapper.CsvLineParser(';');
        CSVRecord parsed = lineParser.parse("one;two");

        assertEquals("one", parsed.get(0));
        assertEquals("two", parsed.get(1));
        assertTrue(parsed.isConsistent());
        assertEquals(1, parsed.getRecordNumber());
    }
View Full Code Here

Examples of org.apache.commons.csv.CSVRecord

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        ImmutableBytesWritable outputKey = new ImmutableBytesWritable();
        try {
            CSVRecord csvRecord = null;
            try {
                csvRecord = csvLineParser.parse(value.toString());
            } catch (IOException e) {
                context.getCounter(COUNTER_GROUP_NAME, "CSV Parser errors").increment(1L);
            }
View Full Code Here

Examples of org.apache.commons.csv.CSVRecord

        verifyNoMoreInteractions(preparedStatement);
    }

    @Test
    public void testExecute_TooFewFields() throws Exception {
        CSVRecord csvRecordWithTooFewFields = createCsvRecord("123,NameValue");
        upsertExecutor.execute(csvRecordWithTooFewFields);

        verify(upsertListener).errorOnRecord(eq(csvRecordWithTooFewFields), anyString());
        verifyNoMoreInteractions(upsertListener);
    }
View Full Code Here

Examples of org.apache.commons.csv.CSVRecord

        verifyNoMoreInteractions(upsertListener);
    }

    @Test
    public void testExecute_TooManyFields() throws Exception {
        CSVRecord csvRecordWithTooManyFields = createCsvRecord("123,NameValue,42,1:2:3,Garbage");
        upsertExecutor.execute(csvRecordWithTooManyFields);

        verify(upsertListener).upsertDone(1L);
        verifyNoMoreInteractions(upsertListener);
View Full Code Here

Examples of org.apache.commons.csv.CSVRecord

        verifyNoMoreInteractions(preparedStatement);
    }

    @Test
    public void testExecute_InvalidType() throws Exception {
        CSVRecord csvRecordWithInvalidType = createCsvRecord("123,NameValue,ThisIsNotANumber,1:2:3");
        upsertExecutor.execute(csvRecordWithInvalidType);

        verify(upsertListener).errorOnRecord(eq(csvRecordWithInvalidType), anyString());
        verifyNoMoreInteractions(upsertListener);
    }
View Full Code Here

Examples of org.apache.commons.csv.CSVRecord

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        ImmutableBytesWritable outputKey = new ImmutableBytesWritable();
        try {
            CSVRecord csvRecord = null;
            try {
                csvRecord = csvLineParser.parse(value.toString());
            } catch (IOException e) {
                context.getCounter(COUNTER_GROUP_NAME, "CSV Parser errors").increment(1L);
            }
View Full Code Here

Examples of org.apache.commons.csv.CSVRecord

    @SuppressWarnings("deprecation")
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        ImmutableBytesWritable outputKey = new ImmutableBytesWritable();
        try {
            CSVRecord csvRecord = null;
            try {
                csvRecord = csvLineParser.parse(value.toString());
            } catch (IOException e) {
                context.getCounter(COUNTER_GROUP_NAME, "CSV Parser errors").increment(1L);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.