|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object olg.csv.bean.RowBean<T>
T
- the bean to manage.public final class RowBean<T>
Main class to manage bean writing/reading based on Annotations setted on bean class.
Field Summary | |
---|---|
private Class<T> |
clazz
The class this RowBean instance deals with. |
private static org.slf4j.Logger |
LOGGER
class logger. |
private RowBeanProcessor<T> |
rowBeanProcessor
the processor to load RowProcessor/BeanProcessor/file reader settings/file writer settings. |
Constructor Summary | |
---|---|
RowBean(Class<T> clazz)
Constructor. |
Method Summary | |
---|---|
List<T> |
fromFile(File in)
Extracts a list from a file. |
List<T> |
fromFile(File in,
CSVSettings csvSettings)
Extracts a list from a CSV file opened with some CSV settings. |
List<T> |
fromFile(File in,
ODSSettings odsSettings)
Extracts a list from an ODS file opened with some ODS settings. |
private List<T> |
fromReader(IReader fileReader,
File in)
Extracts a list from a reader. |
private IBeanProcessor<T> |
getBeanProcessor()
Provides the Bean processor built from the annoted T class. |
IReader |
getReader(File in)
Returns a ODS or CSV reader with settings read from RowBean Annotation setted on T class. throws IllegalArgumentException if file is null or or it's not possible to define a reader. |
private IRowProcessor<T> |
getRowProcessor()
Provides the row processor built from the annoted T class. |
IWriter |
getWriter(File out)
Returns a ODS or CSV writer with settings read from RowBean Annotation setted on T class. |
private static boolean |
isCSVFile(File file)
check if a file extension matchs text file extension(.csv,.txt,.dat). |
private static boolean |
isODSFile(File file)
check if a file extension matchs ODS file extension. |
void |
toFile(List<T> beans,
File out)
Copy in a new file a list of T. |
void |
toFile(List<T> beans,
File out,
CSVSettings csvSettings)
Copy in a CSV file a list of T. |
void |
toFile(List<T> beans,
File out,
ODSSettings odsSettings)
Copy in an ODS file a list of T. |
private void |
toWriter(List<T> beans,
IWriter fileWriter,
File out)
Copy a list of T on a writer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.slf4j.Logger LOGGER
private Class<T> clazz
private RowBeanProcessor<T> rowBeanProcessor
Constructor Detail |
---|
public RowBean(Class<T> clazz)
clazz
- the class RowBean instance supports and deals with.Method Detail |
---|
public IReader getReader(File in) throws IOException, AnnotationProcessorException
in
- the file. Must be an ODS or CSV file. ODS files must have .ods or.ODS extension. CSV files must have
.csv,.CSV,.txt, .TXT, .dat or.DAT.
IOException
- if an error occurs during the file opening.
AnnotationProcessorException
- an error occurs on settings annotation reading at the rowBean annotation setted on the T class.public IWriter getWriter(File out) throws AnnotationProcessorException, IOException
out
- the file. Must be an ODS or CSV file. ODS files must have .ods or.ODS extension. CSV files must have
.csv,.CSV,.txt, .TXT, .dat or.DAT.
AnnotationProcessorException
- error occurs on writing settings RowBean annotation
IOException
- errors occurs on file openingpublic List<T> fromFile(File in, CSVSettings csvSettings) throws AnnotationProcessorException, IOException
in
- the CSV file.csvSettings
- the settings the file will be opened with.
AnnotationProcessorException
- if an error occurs during the annotation reading on T class.
IOException
- if an error occurs during the file opening.public List<T> fromFile(File in, ODSSettings odsSettings) throws AnnotationProcessorException, IOException
in
- the ODS file.odsSettings
- the settings the file will be opened with.
AnnotationProcessorException
- if error occurs during the annotation reading on T class.
IOException
- if an error occurs during the file opening.public List<T> fromFile(File in) throws AnnotationProcessorException, IOException
in
- the file. Must be an ODS or CSV file. ODS files must have .ods or.ODS extension. CSV files must have
.csv,.CSV,.txt, .TXT, .dat or.DAT. Use the reading settings read from RowBean Annotation setted on T
class.
AnnotationProcessorException
- if error occurs during the annotation reading on T class.
IOException
- if an error occurs during the file opening.public void toFile(List<T> beans, File out) throws AnnotationProcessorException, IOException
beans
- the list.out
- the file. Must be an ODS or CSV file. ODS files must have .ods or.ODS extension. CSV files must have
.csv,.CSV,.txt, .TXT, .dat or.DAT. Use writing settings read from RowBean Annotation setted on T
class.
AnnotationProcessorException
- if error occurs during the annotation reading on T class.
IOException
- if the file exists but is a directory rather than a regular file, does not exist but cannot be
created, or cannot be opened for any other reasonpublic void toFile(List<T> beans, File out, CSVSettings csvSettings) throws AnnotationProcessorException, IOException
beans
- the beans to copy.out
- the file.csvSettings
- the settings the file is written with.
AnnotationProcessorException
- if error occurs during the annotation reading on T class.
IOException
- if the file exists but is a directory rather than a regular file, does not exist but cannot be
created, or cannot be opened for any other reasonpublic void toFile(List<T> beans, File out, ODSSettings odsSettings) throws AnnotationProcessorException, IOException
beans
- the T beans to copy.out
- the fileodsSettings
- the settings the file is written with.
AnnotationProcessorException
- if error occurs during the annotation reading on T class.
IOException
- if the file exists but is a directory rather than a regular file, does not exist but cannot be
created, or cannot be opened for any other reasonprivate static boolean isCSVFile(File file)
file
- the file to check
private static boolean isODSFile(File file)
file
- the file to check
private IRowProcessor<T> getRowProcessor() throws AnnotationProcessorException
AnnotationProcessorException
- if an error occurs during processor building.private IBeanProcessor<T> getBeanProcessor() throws AnnotationProcessorException
AnnotationProcessorException
- if error occurs during annotation processing.private List<T> fromReader(IReader fileReader, File in) throws AnnotationProcessorException
fileReader
- the readerin
- the file
AnnotationProcessorException
- if error occurs during the annotation reading on T class.private void toWriter(List<T> beans, IWriter fileWriter, File out) throws AnnotationProcessorException
beans
- the beans to copy.fileWriter
- the writerout
- the opened file.
AnnotationProcessorException
- if error occurs during the annotation reading on T class.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |