Skip to content

Commit

Permalink
Issue #42 pave the way for CSV writing. Rename Bean/Row reader instru…
Browse files Browse the repository at this point in the history
…ctions to just instructions
  • Loading branch information
robert-bor committed May 5, 2014
1 parent 3215499 commit 1279c74
Show file tree
Hide file tree
Showing 17 changed files with 180 additions and 180 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/csveed/annotations/CsvCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import java.lang.annotation.Target;

/**
* Various settings for a BeanReaderInstructionsImpl translating to a CSV cell. By default every field in a BeanReaderInstructionsImpl is expected to be
* a CsvCell, even if not so marked. Use @CsvIgnore to prevent a BeanReaderInstructionsImpl field from being taken into account for
* Various settings for a BeanInstructionsImpl translating to a CSV cell. By default every field in a BeanInstructionsImpl is expected to be
* a CsvCell, even if not so marked. Use @CsvIgnore to prevent a BeanInstructionsImpl field from being taken into account for
* both serialization and deserialization.
* @author Robert Bor
*/
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/csveed/api/CsvReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* <ul>
* <li>Point it to class. The {@link org.csveed.annotations} in the class are read, as is the order
* of the properties within the class.</li>
* <li>Roll your own. Pass a {@link org.csveed.bean.BeanReaderInstructions} implementation with your
* <li>Roll your own. Pass a {@link org.csveed.bean.BeanInstructions} implementation with your
* own configuration settings</li>
* </ul>
*
Expand Down Expand Up @@ -72,7 +72,7 @@ public interface CsvReader<T> {
* Makes sure that the first readable line is interpreted as the header line. That line will not be read
* as content. This method is called whenever {@link org.csveed.annotations.CsvFile#useHeader()}
* is used. The default value for this setting is true. This call is a facade for
* {@link org.csveed.row.RowReaderInstructions#setUseHeader(boolean)}.
* {@link org.csveed.row.RowInstructions#setUseHeader(boolean)}.
* @param useHeader true if the header is interpreted and used
* @return convenience for chaining
*/
Expand All @@ -82,7 +82,7 @@ public interface CsvReader<T> {
* Sets the start row of the CSV file. If {@link #setUseHeader(boolean)} == true, this will be the header
* row and the next ones are all content rows. This method is called whenever
* {@link org.csveed.annotations.CsvFile#startRow()} is used. The default value for this
* setting is 1. This call is a facade for {@link org.csveed.row.RowReaderInstructions#setStartRow(int)}.
* setting is 1. This call is a facade for {@link org.csveed.row.RowInstructions#setStartRow(int)}.
* @param startRow the first row to start reading, including the header row
* @return convenience for chaining
*/
Expand All @@ -92,7 +92,7 @@ public interface CsvReader<T> {
* Sets the character that will be interpreted as an escape symbol while within a quoted field. This
* method is called whenever {@link org.csveed.annotations.CsvFile#escape()} is used. The
* default value for this setting is a double quote (") symbol. This call is a facade for
* {@link org.csveed.row.RowReaderInstructions#setEscape(char)}.
* {@link org.csveed.row.RowInstructions#setEscape(char)}.
* @param symbol the symbol to use for escaping characters within a quoted field
* @return convenience for chaining
*/
Expand All @@ -102,7 +102,7 @@ public interface CsvReader<T> {
* Sets the character that will be interpreted as a quote symbol, signifying either the start or the
* end of a quoted field. This method is called whenever {@link org.csveed.annotations.CsvFile#quote()}
* is used. The default value for this setting is a double quote (") symbol. This call is a facade for
* {@link org.csveed.row.RowReaderInstructions#setQuote(char)}.
* {@link org.csveed.row.RowInstructions#setQuote(char)}.
* @param symbol the symbol to use for indicating start/end of a quoted field
* @return convenience for chaining
*/
Expand All @@ -111,7 +111,7 @@ public interface CsvReader<T> {
/**
* Sets the character that will be interpreted as a separator between cells. This method is called whenever
* {@link org.csveed.annotations.CsvFile#separator()} is used. The default value for this
* setting is a semi-colon (;). This call is a facade for {@link org.csveed.row.RowReaderInstructions#setSeparator(char)}.
* setting is a semi-colon (;). This call is a facade for {@link org.csveed.row.RowInstructions#setSeparator(char)}.
* @param symbol the symbol to use as a separator between cells
* @return convenience for chaining
*/
Expand All @@ -130,7 +130,7 @@ public interface CsvReader<T> {
* Sets the characters (plural) that will be interpreted as end-of-line markers (unless within a quoted
* field). This method is called whenever {@link org.csveed.annotations.CsvFile#endOfLine()}
* is used. The default values for this setting are \r and \n. This call is a facade for
* {@link org.csveed.row.RowReaderInstructions#setEndOfLine(char[])}.
* {@link org.csveed.row.RowInstructions#setEndOfLine(char[])}.
* @param symbols the symbol to interpret as end-of-line markers (unless within a quoted field)
* @return convenience for chaining
*/
Expand Down
46 changes: 23 additions & 23 deletions src/main/java/org/csveed/api/CsvReaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public CsvReaderImpl(Reader reader, Class<T> beanClass) {
this(reader, new BeanParser().getBeanInstructions(beanClass));
}

public CsvReaderImpl(Reader reader, BeanReaderInstructions beanReaderInstructions) {
this.beanReader = new BeanReaderImpl<T>(reader, beanReaderInstructions);
public CsvReaderImpl(Reader reader, BeanInstructions beanInstructions) {
this.beanReader = new BeanReaderImpl<T>(reader, beanInstructions);
this.rowReader = (RowReaderImpl)getBeanReader().getRowReader();
}

Expand Down Expand Up @@ -71,128 +71,128 @@ public boolean isFinished() {

@Override
public CsvReader<T> setUseHeader(boolean useHeader) {
getRowReader().getRowReaderInstructions().setUseHeader(useHeader);
getRowReader().getRowInstructions().setUseHeader(useHeader);
return this;
}

@Override
public CsvReader<T> setStartRow(int startRow) {
getRowReader().getRowReaderInstructions().setStartRow(startRow);
getRowReader().getRowInstructions().setStartRow(startRow);
return this;
}

@Override
public CsvReader<T> setEscape(char symbol) {
getRowReader().getRowReaderInstructions().setEscape(symbol);
getRowReader().getRowInstructions().setEscape(symbol);
return this;
}

@Override
public CsvReader<T> setQuote(char symbol) {
getRowReader().getRowReaderInstructions().setQuote(symbol);
getRowReader().getRowInstructions().setQuote(symbol);
return this;
}

@Override
public CsvReader<T> setSeparator(char symbol) {
getRowReader().getRowReaderInstructions().setSeparator(symbol);
getRowReader().getRowInstructions().setSeparator(symbol);
return this;
}

@Override
public CsvReader<T> setComment(char symbol) {
getRowReader().getRowReaderInstructions().setComment(symbol);
getRowReader().getRowInstructions().setComment(symbol);
return this;
}

@Override
public CsvReader<T> setEndOfLine(char[] symbols) {
getRowReader().getRowReaderInstructions().setEndOfLine(symbols);
getRowReader().getRowInstructions().setEndOfLine(symbols);
return this;
}

@Override
public CsvReader<T> skipEmptyLines(boolean skip) {
getRowReader().getRowReaderInstructions().skipEmptyLines(skip);
getRowReader().getRowInstructions().skipEmptyLines(skip);
return this;
}

@Override
public CsvReader<T> skipCommentLines(boolean skip) {
getRowReader().getRowReaderInstructions().skipCommentLines(skip);
getRowReader().getRowInstructions().skipCommentLines(skip);
return this;
}

@Override
public CsvReader<T> setMapper(Class<? extends AbstractMapper> mapper) {
getBeanReader().getBeanReaderInstructions().setMapper(mapper);
getBeanReader().getBeanInstructions().setMapper(mapper);
return this;
}

@Override
public CsvReader<T> setDate(String propertyName, String dateFormat) {
getBeanReader().getBeanReaderInstructions().setDate(propertyName, dateFormat);
getBeanReader().getBeanInstructions().setDate(propertyName, dateFormat);
return this;
}

@Override
public CsvReader<T> setLocalizedNumber(String propertyName, Locale locale) {
getBeanReader().getBeanReaderInstructions().setLocalizedNumber(propertyName, locale);
getBeanReader().getBeanInstructions().setLocalizedNumber(propertyName, locale);
return this;
}

@Override
public CsvReader<T> setRequired(String propertyName, boolean required) {
getBeanReader().getBeanReaderInstructions().setRequired(propertyName, required);
getBeanReader().getBeanInstructions().setRequired(propertyName, required);
return this;
}

@Override
public CsvReader<T> setConverter(String propertyName, Converter converter) {
getBeanReader().getBeanReaderInstructions().setConverter(propertyName, converter);
getBeanReader().getBeanInstructions().setConverter(propertyName, converter);
return this;
}

@Override
public CsvReader<T> ignoreProperty(String propertyName) {
getBeanReader().getBeanReaderInstructions().ignoreProperty(propertyName);
getBeanReader().getBeanInstructions().ignoreProperty(propertyName);
return this;
}

@Override
public CsvReader<T> mapColumnIndexToProperty(int columnIndex, String propertyName) {
getBeanReader().getBeanReaderInstructions().mapColumnIndexToProperty(columnIndex, propertyName);
getBeanReader().getBeanInstructions().mapColumnIndexToProperty(columnIndex, propertyName);
return this;
}

@Override
public CsvReader<T> mapColumnNameToProperty(String columnName, String propertyName) {
getBeanReader().getBeanReaderInstructions().mapColumnNameToProperty(columnName, propertyName);
getBeanReader().getBeanInstructions().mapColumnNameToProperty(columnName, propertyName);
return this;
}

@Override
public CsvReader<T> setStartIndexDynamicColumns(int startIndex) {
getBeanReader().getBeanReaderInstructions().setStartIndexDynamicColumns(startIndex);
getBeanReader().getBeanInstructions().setStartIndexDynamicColumns(startIndex);
return this;
}

@Override
public CsvReader<T> setHeaderNameToProperty(String propertyName) {
getBeanReader().getBeanReaderInstructions().setHeaderNameToProperty(propertyName);
getBeanReader().getBeanInstructions().setHeaderNameToProperty(propertyName);
return this;
}

@Override
public CsvReader<T> setHeaderValueToProperty(String propertyName) {
getBeanReader().getBeanReaderInstructions().setHeaderValueToProperty(propertyName);
getBeanReader().getBeanInstructions().setHeaderValueToProperty(propertyName);
return this;
}

private BeanReaderImpl<T> getBeanReader() {
if (this.beanReader == null) {
throw new CsvException(new GeneralError(
"BeanReader has not been initialized. Make sure to pass BeanReaderInstructions or the bean class to CsvReader."
"BeanReader has not been initialized. Make sure to pass BeanInstructions or the bean class to CsvReader."
));
}
return this.beanReader;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/csveed/bean/AbstractMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public abstract class AbstractMapper<T> {

protected BeanReaderInstructionsImpl beanReaderInstructions;
protected BeanInstructionsImpl beanReaderInstructions;

private boolean verified = false;

Expand Down Expand Up @@ -91,7 +91,7 @@ private void setBeanProperty(Row row, int lineNumber, BeanWrapper beanWrapper, C
}
}

public void setBeanReaderInstructions(BeanReaderInstructionsImpl beanReaderInstructions) {
public void setBeanReaderInstructions(BeanInstructionsImpl beanReaderInstructions) {
this.beanReaderInstructions = beanReaderInstructions;
}

Expand Down
Loading

0 comments on commit 1279c74

Please sign in to comment.