List of usage examples for java.util AbstractList get
public abstract E get(int index);
From source file:com.oltpbenchmark.util.CollectionUtil.java
/** * Return the last item in an Iterable//from w w w .j a va 2 s . c om * @param <T> * @param items * @return */ public static <T> T last(Iterable<T> items) { T last = null; if (items instanceof AbstractList<?>) { AbstractList<T> list = (AbstractList<T>) items; last = (list.isEmpty() ? null : list.get(list.size() - 1)); } else { for (T t : items) { last = t; } } return (last); }
From source file:com.nec.nsgui.action.statis.STDataRender4NasSwitch.java
public String getCellRender(int rowIndex, String colName) throws Exception { PageContext context = getSortTagInfo().getPageContext(); AbstractList exportsList = ((ListSTModel) getTableModel()).getDataList(); NasSwitchSubItemInfoBean exportObj = (NasSwitchSubItemInfoBean) exportsList.get(rowIndex); String isWhichNode = exportObj.getIsWhichNode(); String checked = ""; List subItemList_checked = (List) NSActionUtil.getSessionAttribute( (HttpServletRequest) context.getRequest(), SESSION_STATIS_NASSWITCH_SUBITEMLIST_CHECKED); if (subItemList_checked != null) { for (int i = 0; i < subItemList_checked.size(); i++) { NasSwitchSubItemInfoBean temp = (NasSwitchSubItemInfoBean) subItemList_checked.get(i); if (exportObj.getSubItem().equals(temp.getSubItem())) { checked = "checked"; break; }/*from ww w .j av a 2s . co m*/ } } if (colName.equals("subItemCheckbox")) { StringBuffer cellStr = new StringBuffer( "<input name=\"subItemCheckbox\" type=\"checkbox\" " + " value=\""); cellStr.append(exportObj.getSequence()); cellStr.append("\" id=\"subItemCheckbox" + rowIndex); cellStr.append("\" " + checked); cellStr.append(" onClick=\"return checkNum("); cellStr.append(");\">"); cellStr.append("<script language=\"javascript\">"); cellStr.append("subItem['" + exportObj.getSequence() + "']='" + exportObj.getInterval() + "';"); cellStr.append("</script>"); if (isWhichNode.equals("both")) { return "<td nowrap align=center rowspan=\"2\">" + cellStr.toString() + "</td>"; } else { return "<td nowrap align=center>" + cellStr.toString() + "</td>"; } } if (colName.equals("subItem")) { String subItem = NSActionUtil .sanitize(NSActionUtil.perl2Page(exportObj.getSubItem(), NSActionConst.ENCODING_EUC_JP)); if (isWhichNode.equals("both")) { return "<td nowrap align=left rowspan=\"2\">" + "<label for=\"subItemCheckbox" + rowIndex + "\">" + subItem + "</label>" + "</td>"; } else { return "<td nowrap align=left>" + "<label for=\"subItemCheckbox" + rowIndex + "\">" + subItem + "</label>" + "</td>"; } } if (colName.equals("node")) { String node_message = ""; String collectionId = (String) NSActionUtil .getSessionAttribute((HttpServletRequest) context.getRequest(), SESSION_COLLECTION_ID); if (collectionId.trim().equals(NSW_NFS_Virtual_Export)) { node_message = TagUtils.getInstance().message(context, null, null, "statis.nasswitch.group"); } if (collectionId.trim().equals(NSW_NFS_Server)) { node_message = TagUtils.getInstance().message(context, null, null, "statis.nasswitch.node"); } if (isWhichNode.equals("both") || isWhichNode.equals("group0")) return "<td nowrap align=left>" + node_message + "0</td>"; if (isWhichNode.equals("both") || isWhichNode.equals("group1")) return "<td nowrap align=left>" + node_message + "1</td>"; } if (colName.equals("access_average") || colName.equals("access_max") || colName.equals("response_average") || colName.equals("response_max") || colName.equals("rover_average") || colName.equals("rover_max")) { NasSwitchMaxAverBean nodeInfo = new NasSwitchMaxAverBean(); if (isWhichNode.equals("both") || isWhichNode.equals("group0")) { nodeInfo = exportObj.getBean4Node0(); } else { nodeInfo = exportObj.getBean4Node1(); } String content = PropertyUtils.getProperty(nodeInfo, colName).toString(); if (content.equals("--")) { return "<td nowrap align=center>" + content + "</td>"; } else { return "<td nowrap align=right>" + content + "</td>"; } } if (colName.equals("stockPeriod")) { String stockPeriod = exportObj.getStockPeriod(); if (!isWhichNode.equals("both") && stockPeriod.trim().equals("--")) { return "<td nowrap align=center>" + stockPeriod + "</td>"; } else if (!isWhichNode.equals("both") && !stockPeriod.trim().equals("--")) { return "<td nowrap align=right>" + stockPeriod + "</td>"; } else if (isWhichNode.equals("both") && stockPeriod.trim().equals("--")) { return "<td nowrap align=center rowspan=\"2\">" + stockPeriod + "</td>"; } else if (isWhichNode.equals("both") && !stockPeriod.trim().equals("--")) { return "<td nowrap align=right rowspan=\"2\">" + stockPeriod + "</td>"; } } if (colName.equals("interval")) { String interval = exportObj.getInterval(); StringBuffer cell = new StringBuffer(); if (!isWhichNode.equals("both") && interval.trim().equals("--")) { return "<td nowrap align=center>" + interval + "</td>"; } else if (!isWhichNode.equals("both") && !interval.trim().equals("--")) { return "<td nowrap align=right>" + Integer.parseInt(interval) / 60 + "</td>"; } else if (isWhichNode.equals("both") && interval.trim().equals("--")) { cell.append("<td nowrap align=center rowspan=\"2\">" + interval + "</td>"); } else if (isWhichNode.equals("both") && !interval.trim().equals("--")) { cell.append("<td nowrap align=right rowspan=\"2\">" + Integer.parseInt(interval) / 60 + "</td>"); } if (isWhichNode.equals("both")) { NasSwitchMaxAverBean node1Info = exportObj.getBean4Node1(); String access_average = node1Info.getAccess_average(); String access_max = node1Info.getAccess_max(); String response_average = node1Info.getResponse_average(); String response_max = node1Info.getResponse_max(); String rover_average = node1Info.getRover_average(); String rover_max = node1Info.getRover_max(); String node_message = ""; String collectionId = (String) NSActionUtil .getSessionAttribute((HttpServletRequest) context.getRequest(), SESSION_COLLECTION_ID); if (collectionId.equals(NSW_NFS_Virtual_Export)) { node_message = TagUtils.getInstance().message(context, null, null, "statis.nasswitch.group"); } if (collectionId.equals(NSW_NFS_Server)) { node_message = TagUtils.getInstance().message(context, null, null, "statis.nasswitch.node"); } cell.append("</tr><tr><td nowrap align=center>"); cell.append(node_message); cell.append("1</td>"); if (access_average.equals("--")) { cell.append("<td nowrap align=center>" + access_average + "</td>"); } else { cell.append("<td nowrap align=right>" + access_average + "</td>"); } if (access_max.equals("--")) { cell.append("<td nowrap align=center>" + access_max + "</td>"); } else { cell.append("<td nowrap align=right>" + access_max + "</td>"); } if (response_average.equals("--")) { cell.append("<td nowrap align=center>" + response_average + "</td>"); } else { cell.append("<td nowrap align=right>" + response_average + "</td>"); } if (response_max.equals("--")) { cell.append("<td nowrap align=center>" + response_max + "</td>"); } else { cell.append("<td nowrap align=right>" + response_max + "</td>"); } if (rover_average.equals("--")) { cell.append("<td nowrap align=center>" + rover_average + "</td>"); } else { cell.append("<td nowrap align=right>" + rover_average + "</td>"); } if (rover_max.equals("--")) { cell.append("<td nowrap align=center>" + rover_max + "</td>"); } else { cell.append("<td nowrap align=right>" + rover_max + "</td>"); } } return cell.toString(); } return ""; }