/** * Used for text output * * @param rList */ public static void updateColumnWidth(ResultList rList) { if (rList == null || rList.getColumnDescriptor() == null || rList.getRows().size() == 0) return; List<ColumnInfo> cols = rList.getColumnDescriptor().getColumns(); for (ColumnInfo col : cols) { col.setMaxLength(col.getName().length()); } for (ResultRow row : rList.getRows()) { List<String> l = row.getColumns(); for (int i = 0; i < l.size(); i++) { String s = l.get(i); if (s != null && s.length() > cols.get(i).getMaxLength()) cols.get(i).setMaxLength(s.length()); } } }
public static ResultList paserBindList(ResultList rList) { if (rList != null && rList.getRows().size() > 0) { logger.fine("BindController returns " + rList.getRows().size()); ResultList newList = new ResultList(); ColumnDescriptor desc = new ColumnDescriptor(); for (ColumnInfo col : rList.getColumnDescriptor().getColumns()) { if ("binds_xml".equalsIgnoreCase(col.getName())) continue; desc.addColumn(col.getName(), col.isNumberType(), desc.getColumns().size()); } desc.addColumn("NAME", false, desc.getColumns().size()); desc.addColumn("POS", false, desc.getColumns().size()); desc.addColumn("DTYSTR", false, desc.getColumns().size()); desc.addColumn("MAXLEN", false, desc.getColumns().size()); desc.addColumn("LEN", false, desc.getColumns().size()); desc.addColumn("VALUE", false, desc.getColumns().size()); newList.setColumnDescriptor(desc); int idx = rList.getColumnDescriptor().getColumnIndex("BINDS_XML"); XMLInputFactory inputFactory = XMLInputFactory.newInstance(); for (ResultRow row : rList.getRows()) { // logger.info("binds_xml.idx="+idx+", "+ row.getColumns().size()); List<BindVariable> binds = null; try { String bindXml = row.getColumns().get(idx); binds = parseBinds(bindXml, inputFactory); } catch (Exception iex) { } if (binds == null || binds.size() == 0) { ResultRow newRow = new ResultRow(); newRow.setColumnDescriptor(desc); List<String> cols = new java.util.ArrayList<String>(row.getColumns().size() + 5); for (int i = 0; i < row.getColumns().size(); i++) { if (i == idx) continue; cols.add(row.getColumns().get(i)); } cols.add(null); cols.add(null); cols.add(null); cols.add(null); cols.add(null); cols.add(null); newRow.setColumns(cols); newList.addRow(newRow); } else { for (BindVariable var : binds) { ResultRow newRow = new ResultRow(); newRow.setColumnDescriptor(desc); List<String> cols = new java.util.ArrayList<String>(row.getColumns().size() + 5); for (int i = 0; i < row.getColumns().size(); i++) { if (i == idx) continue; cols.add(row.getColumns().get(i)); } cols.add(var.name); cols.add(var.pos); cols.add(var.dtystr); cols.add(var.maxLen); cols.add(var.len); cols.add(var.value); newRow.setColumns(cols); newList.addRow(newRow); } } } return newList; } return null; }