org.midao.jdbc.core.processor
Class BasicQueryOutputProcessor

java.lang.Object
  extended by org.midao.jdbc.core.processor.BasicQueryOutputProcessor
All Implemented Interfaces:
QueryOutputProcessor

public class BasicQueryOutputProcessor
extends java.lang.Object
implements QueryOutputProcessor

Default output processor used by OutputHandlers


Field Summary
protected static int PROPERTY_NOT_FOUND
          If no corresponding bean property was found - this value is assigned.
 
Constructor Summary
BasicQueryOutputProcessor()
          Creates new BasicQueryOutputProcessor instance
BasicQueryOutputProcessor(java.util.Map<java.lang.String,java.lang.String> columnToPropertyOverrides)
          Creates new BasicQueryOutputProcessor instance
 
Method Summary
protected  int[] mapColumnsToProperties(QueryParameters params, java.beans.PropertyDescriptor[] props)
          Columns from @params are mapped to class fields @props (by name).
 java.lang.Object processValue(QueryParameters params, java.lang.Integer position, java.beans.PropertyDescriptor prop)
          Reads value from @params (by @position) and converts it into value according to type specified in @prop This function is not used outside OutputProcessor.
 java.lang.Object[] toArray(java.util.List<QueryParameters> paramsList)
          Converts query output (first line) into array of values
 java.util.List<java.lang.Object[]> toArrayList(java.util.List<QueryParameters> paramsList)
          Converts query output into list.
<T> T
toBean(java.util.List<QueryParameters> paramsList, java.lang.Class<T> type)
          Converts query output(first line) into Java Object.
<T> T
toBean(QueryParameters params, java.lang.Class<T> type)
          Converts query parameters into Java Object.
<T> java.util.List<T>
toBeanList(java.util.List<QueryParameters> paramsList, java.lang.Class<T> type)
          Converts query output into Java Object.
 java.util.Map<java.lang.String,java.lang.Object> toMap(java.util.List<QueryParameters> paramsList)
          Converts query output(first line) into Map.
 java.util.Map<java.lang.String,java.lang.Object> toMap(QueryParameters params)
          Converts query parameters into Map.
 java.util.List<java.util.Map<java.lang.String,java.lang.Object>> toMapList(java.util.List<QueryParameters> paramsList)
          Converts query output into Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_NOT_FOUND

protected static final int PROPERTY_NOT_FOUND
If no corresponding bean property was found - this value is assigned. Used in mapColumnsToProperties.

See Also:
Constant Field Values
Constructor Detail

BasicQueryOutputProcessor

public BasicQueryOutputProcessor()
Creates new BasicQueryOutputProcessor instance


BasicQueryOutputProcessor

public BasicQueryOutputProcessor(java.util.Map<java.lang.String,java.lang.String> columnToPropertyOverrides)
Creates new BasicQueryOutputProcessor instance

Parameters:
columnToPropertyOverrides - by default columns from SQL query are put into Map/Bean according to it's name. By specifying overrides - processor would use them to map fields accordingly.
Method Detail

toArray

public java.lang.Object[] toArray(java.util.List<QueryParameters> paramsList)
Converts query output (first line) into array of values

Specified by:
toArray in interface QueryOutputProcessor
Parameters:
paramsList - query output(1st line is avoided).
Returns:
array of values

toArrayList

public java.util.List<java.lang.Object[]> toArrayList(java.util.List<QueryParameters> paramsList)
Converts query output into list. Every query output line is converted into array and put into List

Specified by:
toArrayList in interface QueryOutputProcessor
Parameters:
paramsList - query output(1st line is avoided).
Returns:
array of values

toBean

public <T> T toBean(java.util.List<QueryParameters> paramsList,
                    java.lang.Class<T> type)
         throws MidaoException
Converts query output(first line) into Java Object.

Specified by:
toBean in interface QueryOutputProcessor
Parameters:
paramsList - query output(1st line is avoided)
type - Java Class definition from which Object would be created
Returns:
filled object
Throws:
MidaoException

toBean

public <T> T toBean(QueryParameters params,
                    java.lang.Class<T> type)
         throws MidaoException
Converts query parameters into Java Object.

Specified by:
toBean in interface QueryOutputProcessor
Parameters:
params - query parameters from which Object would be filled
type - Java Class definition from which Object would be created
Returns:
filled object
Throws:
MidaoException

toBeanList

public <T> java.util.List<T> toBeanList(java.util.List<QueryParameters> paramsList,
                                        java.lang.Class<T> type)
                             throws MidaoException
Converts query output into Java Object. Every line would be converted into Java Object and added into List

Specified by:
toBeanList in interface QueryOutputProcessor
Parameters:
paramsList - query output(1st line is avoided)
type - Java Class definition from which Object would be created
Returns:
List of Map's
Throws:
MidaoException

toMap

public java.util.Map<java.lang.String,java.lang.Object> toMap(java.util.List<QueryParameters> paramsList)
Converts query output(first line) into Map.

Specified by:
toMap in interface QueryOutputProcessor
Parameters:
paramsList - query output(1st line is avoided)
Returns:
filled object

toMap

public java.util.Map<java.lang.String,java.lang.Object> toMap(QueryParameters params)
Converts query parameters into Map.

Specified by:
toMap in interface QueryOutputProcessor
Parameters:
params - query parameters from which Object would be filled
Returns:
filled object

toMapList

public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> toMapList(java.util.List<QueryParameters> paramsList)
Converts query output into Map. Every line would be converted into Map and added into List

Specified by:
toMapList in interface QueryOutputProcessor
Parameters:
paramsList - query output(1st line is avoided)
Returns:
List of Map's

processValue

public java.lang.Object processValue(QueryParameters params,
                                     java.lang.Integer position,
                                     java.beans.PropertyDescriptor prop)
                              throws MidaoException
Reads value from @params (by @position) and converts it into value according to type specified in @prop This function is not used outside OutputProcessor. Might be removed in future

Specified by:
processValue in interface QueryOutputProcessor
Parameters:
params - Query Parameters
position - position which would be read
prop - PropertyDescriptor according to which value would be converted
Returns:
converted value
Throws:
MidaoException

mapColumnsToProperties

protected int[] mapColumnsToProperties(QueryParameters params,
                                       java.beans.PropertyDescriptor[] props)
Columns from @params are mapped to class fields @props (by name). During processing @columnToPropertyOverrides is used to check overrides

Parameters:
params - Query output columns of which would be mapped to @props
props - Java class property descriptor
Returns:
array for every element from @params corresponding element in @props


Copyright © 2013. All Rights Reserved.