public WeblogCategoryData getWeblogCategoryByPath( WebsiteData website, WeblogCategoryData category, String path) throws RollerException { final Iterator cats; final String[] pathArray = Utilities.stringToStringArray(path, "/"); if (category == null && (null == path || "".equals(path.trim()))) { throw new RollerException("Bad arguments."); } if (path.trim().equals("/")) { return getRootWeblogCategory(website); } else if (category == null || path.trim().startsWith("/")) { cats = getRootWeblogCategory(website).getWeblogCategories().iterator(); } else { cats = category.getWeblogCategories().iterator(); } while (cats.hasNext()) { WeblogCategoryData possibleMatch = (WeblogCategoryData) cats.next(); if (possibleMatch.getName().equals(pathArray[0])) { if (pathArray.length == 1) { return possibleMatch; } else { String[] subpath = new String[pathArray.length - 1]; System.arraycopy(pathArray, 1, subpath, 0, subpath.length); String pathString = Utilities.stringArrayToString(subpath, "/"); return getWeblogCategoryByPath(website, possibleMatch, pathString); } } } // The category did not match and neither did any sub-categories return null; }
public void loadCheckboxes(List comments) { ArrayList all = new ArrayList(); ArrayList approvedList = new ArrayList(); ArrayList spamList = new ArrayList(); Iterator it = comments.iterator(); while (it.hasNext()) { CommentData comment = (CommentData) it.next(); all.add(comment.getId()); if (comment.getApproved().booleanValue()) { approvedList.add(comment.getId()); } if (comment.getSpam().booleanValue()) { spamList.add(comment.getId()); } } String[] idArray = (String[]) all.toArray(new String[all.size()]); ids = Utilities.stringArrayToString(idArray, ","); approvedComments = (String[]) approvedList.toArray(new String[approvedList.size()]); spamComments = (String[]) spamList.toArray(new String[spamList.size()]); }