All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cyclopsgroup.caff.format.CSVFormat Maven / Gradle / Ivy

There is a newer version: 0.4.2
Show newest version
package org.cyclopsgroup.caff.format;

import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

import org.cyclopsgroup.caff.CharIterator;

/**
 * Format implementation based on CSV syntax
 *
 * @author Jiaqi Guo
 * @param  Type of bean to format or parse
 */
public class CSVFormat
    extends Format
{
    private final CSVImpl impl;

    /**
     * @param beanType Type of bean to format or parse
     */
    public CSVFormat( Class beanType )
    {
        super( beanType );
        impl = new CSVImpl( beanType );
    }

    /**
     * @inheritDoc
     */
    @Override
    public T parse( CharSequence content ) throws IOException
    {
        T bean = createBean();
        impl.populate( bean, CharIterator.instanceOf( content ) );
        return bean;
    }

    /**
     * @inheritDoc
     */
    @Override
    public void populate( T bean, Reader reader )
        throws IOException
    {
        impl.populate( bean, CharIterator.instanceOf( reader ) );
    }

    /**
     * @inheritDoc
     */
    @Override
    public void print( T object, Writer output )
        throws IOException
    {
        impl.print( object, output );
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy