Converts first row of query output into Bean

@param outputList Query output
@return Bean converted from first row of query output
@throws org.midao.jdbc.core.exception.MjdbcException
484060
public T handle(List<QueryParameters> outputList) throws MjdbcException {
        return (T) this.outputProcessor.toBean(outputList, this.type);
    }
353502
public static <T> List<T> queryForList(String sql, Class<T> clz, Object... args) {
		List<T> result = new ArrayList<T>();
		Connection con = null;
		PreparedStatement ps = null;
		ResultSet rs = null;
		try {
			con = getconnnection();
			ps = con.prepareStatement(sql);
			if (args != null) {
				for (int i = 0; i < args.length; i++) {
					ps.setObject((i + 1), args[i]);
				}
			}
			rs = ps.executeQuery();
			ResultSetMetaData rsmd = rs.getMetaData();
			int columnCount = rsmd.getColumnCount();
			while (rs.next()) {
				T obj = clz.newInstance();
				for (int i = 1; i <= columnCount; i++) {
					String columnName = rsmd.getColumnName(i);
					String methodName = "set" + columnName.substring(0, 1).toUpperCase()
							+ columnName.substring(1, columnName.length());
					Method method[] = clz.getMethods();
					for (Method meth : method) {
						if (methodName.equals(meth.getName())) {
							meth.invoke(obj, rs.getObject(i));
						}
					}
				}
				result.add(obj);
			}
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} finally {
			close(rs, ps, con);
		}
		return result;
	}
708604
public static <E, T extends Collection<E>> T handleRsToBeanList(ResultSet rs, T collection, Class<E> elementBeanType) throws SQLException {
		final ResultSetMetaData meta = rs.getMetaData();
		final int columnCount = meta.getColumnCount();

		while (rs.next()) {
			collection.add(handleRow(columnCount, meta, rs, elementBeanType));
		}

		return collection;
	}
1358951
@Override
    public <T,R> List<R> queryLogs(QueryWhere queryData, Class<T> queryClass, Class<R> resultClass ) {
        List<T> results = doQuery(queryData, queryClass);
        return convertListToInterfaceList(results, resultClass);
    }
299458
public <T> List<T> read(int headerRowIndex, int startRowIndex, Class<T> beanType) {
		return read(headerRowIndex, startRowIndex, Integer.MAX_VALUE, beanType);
	}
129620
public static <T> int writeListTo(OutputStream out, List<T> messages, Schema<T> schema,
            LinkedBuffer buffer) throws IOException
    {
        if (buffer.start != buffer.offset)
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");

        final ProtobufOutput output = new ProtobufOutput(buffer);
        int totalSize = 0;
        for (T m : messages)
        {
            schema.writeTo(output, m);
            final int size = output.getSize();
            ProtobufOutput.writeRawVarInt32Bytes(out, size);
            final int msgSize = LinkedBuffer.writeTo(out, buffer);

            assert size == msgSize;

            totalSize += size;
            output.clear();
        }
        return totalSize;
    }
677771
@SuppressWarnings("unchecked")
	public <T> List<T> read(int headerRowIndex, int startRowIndex, int endRowIndex, Class<T> beanType) {
		checkNotClosed();
		final List<Map<String, Object>> mapList = read(headerRowIndex, startRowIndex, endRowIndex);
		if (Map.class.isAssignableFrom(beanType)) {
			return (List<T>) mapList;
		}

		final List<T> beanList = new ArrayList<>(mapList.size());
		for (Map<String, Object> map : mapList) {
			beanList.add(BeanUtil.mapToBean(map, beanType, false));
		}
		return beanList;
	}
164464
@SuppressWarnings({"rawtypes", "unchecked"})
    public static Collection convertListToCollection(final List list, final Class<Collection> toClass,
            final BeanFactory<Class<?>, Object> beanFactory) {

        if(list.getClass().equals(toClass)) {
            return list;
        }

        if(toClass.isInterface()) {
            if(List.class.isAssignableFrom(toClass)) {
                // 変換先がListの実態の場合はそのまま。
                return list;

            } else if(Set.class.isAssignableFrom(toClass)) {

                Collection value = (Collection) beanFactory.create(LinkedHashSet.class);
                value.addAll(list);
                return value;

            } else if(Queue.class.isAssignableFrom(toClass)) {

                Collection value = (Collection) beanFactory.create(LinkedList.class);
                value.addAll(list);
                return value;

            } else if(Collection.class.isAssignableFrom(toClass)) {
                Collection value = (Collection) beanFactory.create(ArrayList.class);
                value.addAll(list);
                return value;

            } else {
                throw new IllegalArgumentException("not support class type:" + toClass.getName());
            }

        }

        Collection value = (Collection) beanFactory.create(toClass);
        value.addAll(list);

        return value;

    }
1084896
@Override
    public List<?> getResultList()
    {
        if (log.isDebugEnabled())
            log.info("On getResultList() executing query: " + getJPAQuery());

        // as per JPA post event should happen before fetching data from
        // database.
        List results = null;

        if (getEntityMetadata() == null)
        {
            // Scalar Query
            if (kunderaQuery.isDeleteUpdate())
            {
                executeUpdate();
            }
            else
            {
                Client client = persistenceDelegeator.getClient(kunderaQuery.getPersistenceUnit());
                results = populateEntities(null, client);
            }
        }
        else
        {
            handlePostEvent();

            if (kunderaQuery.isDeleteUpdate())
            {
                executeUpdate();
            }
            else
            {
                results = fetch();
                assignReferenceToProxy(results);
            }
        }
        return results != null ? results : new ArrayList();
    }
519051
public List<T> handle(List<QueryParameters> outputList) throws MjdbcException {
        List<T> result = new ArrayList<T>();
        String parameterName = null;
        Object parameterValue = null;

        for (int i = 1; i < outputList.size(); i++) {
            if (this.columnName == null) {
                parameterName = outputList.get(i).getNameByPosition(this.columnIndex);
                parameterValue = outputList.get(i).getValue(parameterName);

                result.add((T) parameterValue);
            } else {
                parameterValue = outputList.get(i).getValue(this.columnName);

                result.add((T) parameterValue);
            }

        }

        return result;
    }
1137396
public static <T> String toMMCIF(List<T> list, Class<T> klass) {
		if (list.isEmpty()) throw new IllegalArgumentException("List of beans is empty!");

		Field[] fields = getFields(klass);
		int[] sizes = getFieldSizes(list,fields);

		StringBuilder sb = new StringBuilder();

		for (T o:list) {
			sb.append(toSingleLoopLineMmCifString(o, fields, sizes));
		}

		sb.append(SimpleMMcifParser.COMMENT_CHAR+newline);

		return sb.toString();
	}
1158913
@Override
    public <E> List<E> getColumnsById(String schemaName, String joinTableName, String joinColumnName,
            String inverseJoinColumnName, Object parentId, Class columnJavaType)
    {
        StringBuffer sqlQuery = new StringBuffer();
        sqlQuery.append("SELECT ").append(inverseJoinColumnName).append(" FROM ")
                .append(getFromClause(schemaName, joinTableName)).append(" WHERE ").append(joinColumnName).append("='")
                .append(parentId).append("'");

        Session s = getSession();

        SQLQuery query = s.createSQLQuery(sqlQuery.toString());

        List<E> foreignKeys = new ArrayList<E>();

        foreignKeys = query.list();

        return foreignKeys;
    }
183249
public static List<HistoryDTO> transformToDto(List<History> list) {
        if (list == null) {
            throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
        }

        List<HistoryDTO> result = new ArrayList<HistoryDTO>();

        for (History history : list) {
            result.add(transformToDto(history));
        }
        return result;
    }
144164
public List<ProcessInstance> executeList(CommandContext commandContext, Map<String, Object> parameterMap, int firstResult, int maxResults) {
    return commandContext.getExecutionEntityManager().findProcessInstanceByNativeQuery(parameterMap, firstResult, maxResults);
  }
697024
@Override
    protected <T> void buildColumnMappingList(final BeanMapping<T> beanMapping, final Class<T> beanType, final Class<?>[] groups) {
        
        final List<ColumnMapping> columnMappingList = new ArrayList<>();
        for(Field field : beanType.getDeclaredFields()) {
            
            final CsvColumn columnAnno = field.getAnnotation(CsvColumn.class);
            if(columnAnno != null) {
                columnMappingList.add(createColumnMapping(field, columnAnno, groups));
            }
            
        }
        
        beanMapping.addAllColumns(columnMappingList);
        
    }
1083334
public static <T> void writeListTo(OutputStream out, List<T> messages, Schema<T> schema)
            throws IOException
    {
        writeListTo(out, messages, schema, DEFAULT_OUTPUT_FACTORY);
    }
125735
@NotNull
    public List<T> queryList() throws SQLException {
        List<T> res = new ArrayList<>();
        try (ResultSet r = statement.executeQuery()) {
            while (r.next()) {
                res.add(resultMapper.map(r));
            }
        }
        return res;
    }