olg.csv.base
Class IgnoreNullWriter

Package class diagram package IgnoreNullWriter
java.lang.Object
  extended by olg.csv.base.IgnoreNullWriter
All Implemented Interfaces:
Closeable, IWriter

public class IgnoreNullWriter
extends Object
implements IWriter

A "Proxy" writer which Provides a mecanism to skip empty row.


Field Summary
private static org.slf4j.Logger LOGGER
          the class logger.
private  int nextRowNum
          num of the next row to write.
private  IWriter writer
          the original writer.
 
Constructor Summary
IgnoreNullWriter(IWriter writer)
           
 
Method Summary
 void addLine(String[] values)
          Write a row only if not empty.
 void addRow(Row row)
          writes a row only if not empty.
 void close()
          Close the original writer.
private  boolean isValid(Row row)
          Check if a row is not null and not empty.
private  boolean isValid(String[] values)
          Check if a row is not null and not empty.
 boolean isWithHeaders()
          Indicates if the file has a headers line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final org.slf4j.Logger LOGGER
the class logger.


writer

private final IWriter writer
the original writer.


nextRowNum

private int nextRowNum
num of the next row to write.

Constructor Detail

IgnoreNullWriter

public IgnoreNullWriter(IWriter writer)
Parameters:
writer - a concret reader
Method Detail

close

public void close()
Close the original writer.

Specified by:
close in interface Closeable

addRow

public void addRow(Row row)
writes a row only if not empty.

Specified by:
addRow in interface IWriter
Parameters:
row - the row.

addLine

public void addLine(String[] values)
Write a row only if not empty.

Specified by:
addLine in interface IWriter
Parameters:
values - the row.

isWithHeaders

public boolean isWithHeaders()
Description copied from interface: IWriter
Indicates if the file has a headers line.

Specified by:
isWithHeaders in interface IWriter
Returns:
the original withHeaders attribute.

isValid

private boolean isValid(Row row)
Check if a row is not null and not empty.

Parameters:
row - the row
Returns:
true if the row is not null and not empty.

isValid

private boolean isValid(String[] values)
Check if a row is not null and not empty.

Parameters:
values - the row
Returns:
true if the row is not null and not empty.


Copyright © 2014. All Rights Reserved.