Package net.jextra.fauxjo
Class BeanBuilder<T>
- java.lang.Object
-
- net.jextra.fauxjo.BeanBuilder<T>
-
- All Implemented Interfaces:
ResultSetIterator.Builder<T>
public class BeanBuilder<T> extends Object implements ResultSetIterator.Builder<T>
Converts a ResultSet intoFauxjobeans.
-
-
Constructor Summary
Constructors Constructor Description BeanBuilder(Class<T> beanClass)BeanBuilder(Class<T> beanClass, boolean autoCloseResultSet)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TbuildBean(ResultSet rs)protected TbuildBean(Map<String,Object> values)voidbuildBeans(Collection<T> beans, ResultSet rs)voidbuildBeans(Collection<T> beans, ResultSet rs, int numRows)booleangetAllowMissingFields()booleangetAutoCloseResultSet()TgetFirst(ResultSet rs)TgetFirst(ResultSet rs, boolean errorIfEmpty)TgetFirst(ResultSet rs, boolean errorIfEmpty, boolean errorIfMoreThanOne)Reads the first item in the given ResultSet and converts it into a fauxjo bean.ResultSetIterator<T>getIterator(ResultSet rs)List<T>getList(ResultSet rs)WARNING: This consumes the passed in ResultSet.List<T>getList(ResultSet rs, int maxNumItems)Reads the first maxNumItems (-1 = all) ResultSet rows and converts them into a list of fauxjo beans.Set<T>getSet(ResultSet rs)WARNING: This consumes the passed in ResultSet.Set<T>getSet(ResultSet rs, int maxNumItems)TgetUnique(ResultSet rs)TgetUnique(ResultSet rs, boolean errorIfEmpty)voidsetAllowMissingFields(boolean allowMissingFields)voidsetAutoCloseResultSet(boolean autoCloseResultSet)protected booleansetBeanValue(T bean, String key, Object value)
-
-
-
Method Detail
-
getAllowMissingFields
public boolean getAllowMissingFields()
-
setAllowMissingFields
public void setAllowMissingFields(boolean allowMissingFields)
-
getAutoCloseResultSet
public boolean getAutoCloseResultSet()
-
setAutoCloseResultSet
public void setAutoCloseResultSet(boolean autoCloseResultSet)
-
getFirst
public T getFirst(ResultSet rs) throws SQLException
- Throws:
SQLException
-
getFirst
public T getFirst(ResultSet rs, boolean errorIfEmpty) throws SQLException
- Throws:
SQLException
-
getUnique
public T getUnique(ResultSet rs) throws SQLException
- Throws:
SQLException
-
getUnique
public T getUnique(ResultSet rs, boolean errorIfEmpty) throws SQLException
- Throws:
SQLException
-
getFirst
public T getFirst(ResultSet rs, boolean errorIfEmpty, boolean errorIfMoreThanOne) throws SQLException
Reads the first item in the given ResultSet and converts it into a fauxjo bean.- Throws:
SQLException
-
getList
public List<T> getList(ResultSet rs) throws SQLException
WARNING: This consumes the passed in ResultSet.- Throws:
SQLException
-
getList
public List<T> getList(ResultSet rs, int maxNumItems) throws SQLException
Reads the first maxNumItems (-1 = all) ResultSet rows and converts them into a list of fauxjo beans.- Throws:
SQLException
-
getSet
public Set<T> getSet(ResultSet rs) throws SQLException
WARNING: This consumes the passed in ResultSet.- Throws:
SQLException
-
getSet
public Set<T> getSet(ResultSet rs, int maxNumItems) throws SQLException
- Throws:
SQLException
-
getIterator
public ResultSetIterator<T> getIterator(ResultSet rs) throws SQLException
- Throws:
SQLException
-
buildBeans
public void buildBeans(Collection<T> beans, ResultSet rs) throws SQLException
- Throws:
SQLException
-
buildBeans
public void buildBeans(Collection<T> beans, ResultSet rs, int numRows) throws SQLException
- Throws:
SQLException
-
buildBean
public T buildBean(ResultSet rs) throws FauxjoException
- Specified by:
buildBeanin interfaceResultSetIterator.Builder<T>- Throws:
FauxjoException
-
buildBean
protected T buildBean(Map<String,Object> values) throws FauxjoException
- Throws:
FauxjoException
-
setBeanValue
protected boolean setBeanValue(T bean, String key, Object value) throws FauxjoException
- Throws:
FauxjoException
-
-