T - Type of bean to be writtenpublic class BeanWriter<T> extends Object
| Constructor | Description |
|---|---|
BeanWriter(TableWriter writer,
boolean writeHeaderRow) |
Constructor.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
addGetter(Class<T> clazz,
String attribute) |
Adds a getter method to the methods being used for retrieveing column values.
|
protected void |
addGetter(String attributeName,
Method method) |
Adds a getter method to the methods being used for retrieveing column values.
|
void |
close() |
Closes the underlying writer.
|
Object[] |
convertToColumns(T bean) |
Converts the given bean to an object array.
|
protected void |
createAttributeList(Class<T> clazz) |
Creates the attribute list by introspection.
|
protected void |
createAttributeList(Class<T> clazz,
String[] attributes) |
Creates the attribute list from given list.
|
protected void |
createAttributeList(Class<T> clazz,
List<String> attributes) |
Creates the attribute list from given list.
|
protected Object |
getAttribute(int index,
T bean) |
Returns the value for given bean at given column index.
|
protected Object |
getAttribute(Method method,
T bean) |
Returns the attribute value for given bean.
|
protected Object |
getAttribute(String attribute,
T bean) |
Returns the attribute value for given bean.
|
protected String |
getAttributeName(Method m) |
Returns the attribute name derived from method name
|
TableWriter |
getWriter() |
Returns the current writer.
|
protected boolean |
isValidGetterMethod(Method method) |
Returns true if method conforms to JavaBean style of a Getter.
|
boolean |
isWriteHeaderRow() |
Returns true when a header row with attribute names shall be written.
|
protected void |
setWriteHeaderRow(boolean writeHeaderRow) |
Sets whether a header row with attribute names shall be written.
|
protected void |
setWriter(TableWriter writer) |
Sets the writer.
|
void |
writeBean(T bean) |
Writes the bean to the underlying table writer.
|
int |
writeBeans(Object[] arr) |
Copies the beans from the collection to this bean writer.
|
int |
writeBeans(Collection<? extends T> collection) |
Copies the beans from the collection to this bean writer.
|
int |
writeBeans(Iterator<? extends T> i) |
Copies the beans from the collection to this bean writer.
|
protected void |
writeHeaderRow() |
Writes the header row to the underlying table writer.
|
public BeanWriter(TableWriter writer, boolean writeHeaderRow)
writer - the underlying writerwriteHeaderRow - whether a header row with attribute names shall be writtenpublic boolean isWriteHeaderRow()
protected void setWriteHeaderRow(boolean writeHeaderRow)
writeHeaderRow - true if header row shall be written.public void writeBean(T bean) throws IOException
bean - the bean to be writtenIOException - if bean cannot be writtenTableWriter.printRow(Object[]),
convertToColumns(Object)public void close()
public TableWriter getWriter()
protected void setWriter(TableWriter writer)
writer - the writerpublic Object[] convertToColumns(T bean)
bean - bean to be convertedprotected Object getAttribute(int index, T bean)
index - column indexbean - bean objectprotected Object getAttribute(String attribute, T bean)
attribute - name of attributebean - bean objectprotected Object getAttribute(Method method, T bean)
method - method that will deliver the valuebean - bean objectprotected void createAttributeList(Class<T> clazz, List<String> attributes)
clazz - Class to introspectattributes - list of attributesprotected void createAttributeList(Class<T> clazz, String[] attributes)
clazz - Class to introspectattributes - list of attributesprotected void createAttributeList(Class<T> clazz)
clazz - Class to introspectprotected void addGetter(Class<T> clazz, String attribute)
clazz - Class to introspectattribute - name of attributeprotected boolean isValidGetterMethod(Method method)
method - methodprotected void addGetter(String attributeName, Method method)
attributeName - name of attributemethod - method name.protected void writeHeaderRow()
protected String getAttributeName(Method m)
m - methodpublic int writeBeans(Collection<? extends T> collection) throws IOException
collection - collection that contains JavaBeansIOException - when there is a problem with the writer.public int writeBeans(Iterator<? extends T> i) throws IOException
i - iterator that delivers JavaBeansIOException - when there is a problem with the writer.public int writeBeans(Object[] arr) throws IOException
arr - array with beansIOException - when there is a problem with the writer.Copyright © 2018. All rights reserved.