|
Copyright © 2008-2011 Ralph Schuster. All Rights Reserved. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcsv.util.BeanWriter
public class BeanWriter
Writes beans to an underlying table writer. The attributes written are either determined by inspection of first bean to be written or by explicitely setting them through special methods.
| Constructor Summary | |
|---|---|
BeanWriter(TableWriter writer,
boolean writeHeaderRow)
Constructor. |
|
| Method Summary | |
|---|---|
protected void |
addGetter(java.lang.Class<?> clazz,
java.lang.String attribute)
Adds a getter method to the methods being used for retrieveing column values. |
protected void |
addGetter(java.lang.String attributeName,
java.lang.reflect.Method method)
Adds a getter method to the methods being used for retrieveing column values. |
void |
close()
Closes the underlying writer. |
java.lang.Object[] |
convertToColumns(java.lang.Object bean)
Converts the given bean to an object array. |
protected void |
createAttributeList(java.lang.Class<?> clazz)
Creates the attribute list by introspection. |
protected void |
createAttributeList(java.lang.Class<?> clazz,
java.util.List<java.lang.String> attributes)
Creates the attribute list from given list. |
protected void |
createAttributeList(java.lang.Class<?> clazz,
java.lang.String[] attributes)
Creates the attribute list from given list. |
protected java.lang.Object |
getAttribute(int index,
java.lang.Object bean)
Returns the value for given bean at given column index. |
protected java.lang.Object |
getAttribute(java.lang.reflect.Method method,
java.lang.Object bean)
Returns the attribute value for given bean. |
protected java.lang.Object |
getAttribute(java.lang.String attribute,
java.lang.Object bean)
Returns the attribute value for given bean. |
protected java.lang.String |
getAttributeName(java.lang.reflect.Method m)
Returns the attribute name derived from method name |
TableWriter |
getWriter()
Returns the current writer. |
protected boolean |
isValidGetterMethod(java.lang.reflect.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(java.lang.Object bean)
Writes the bean to the underlying table writer. |
int |
writeBeans(java.util.Collection<? extends java.lang.Object> collection)
Copies the beans from the collection to this bean writer. |
int |
writeBeans(java.util.Iterator<? extends java.lang.Object> i)
Copies the beans from the collection to this bean writer. |
int |
writeBeans(java.lang.Object[] arr)
Copies the beans from the collection to this bean writer. |
protected void |
writeHeaderRow()
Writes the header row to the underlying table writer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BeanWriter(TableWriter writer,
boolean writeHeaderRow)
writer - the underlying writerwriteHeaderRow - whether a header row with attribute names shall be written| Method Detail |
|---|
public boolean isWriteHeaderRow()
protected void setWriteHeaderRow(boolean writeHeaderRow)
writeHeaderRow - true if header row shall be written.
public void writeBean(java.lang.Object bean)
throws java.io.IOException
bean - the bean to be written
java.io.IOException - if bean cannot be writtenTableWriter.printRow(Object[]),
convertToColumns(Object)public void close()
public TableWriter getWriter()
protected void setWriter(TableWriter writer)
writer - the writerpublic java.lang.Object[] convertToColumns(java.lang.Object bean)
bean - bean to be converted
protected java.lang.Object getAttribute(int index,
java.lang.Object bean)
index - column indexbean - bean object
protected java.lang.Object getAttribute(java.lang.String attribute,
java.lang.Object bean)
attribute - name of attributebean - bean object
protected java.lang.Object getAttribute(java.lang.reflect.Method method,
java.lang.Object bean)
method - method that will deliver the valuebean - bean object
protected void createAttributeList(java.lang.Class<?> clazz,
java.util.List<java.lang.String> attributes)
clazz - Class to introspectattributes - list of attributes
protected void createAttributeList(java.lang.Class<?> clazz,
java.lang.String[] attributes)
clazz - Class to introspectattributes - list of attributesprotected void createAttributeList(java.lang.Class<?> clazz)
clazz - Class to introspect
protected void addGetter(java.lang.Class<?> clazz,
java.lang.String attribute)
clazz - Class to introspectattribute - name of attributeprotected boolean isValidGetterMethod(java.lang.reflect.Method method)
method - method
protected void addGetter(java.lang.String attributeName,
java.lang.reflect.Method method)
attributeName - name of attributemethod - method name.protected void writeHeaderRow()
protected java.lang.String getAttributeName(java.lang.reflect.Method m)
m - method
public int writeBeans(java.util.Collection<? extends java.lang.Object> collection)
throws java.io.IOException
collection - collection that contains JavaBeans
java.io.IOException - when there is a problem with the writer.
public int writeBeans(java.util.Iterator<? extends java.lang.Object> i)
throws java.io.IOException
i - iterator that delivers JavaBeans
java.io.IOException - when there is a problem with the writer.
public int writeBeans(java.lang.Object[] arr)
throws java.io.IOException
arr - array with beans
java.io.IOException - when there is a problem with the writer.
|
Copyright © 2008-2011 Ralph Schuster. All Rights Reserved. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||