List of usage examples for java.util List iterator
Iterator<E> iterator();
From source file:es.pode.soporte.auditoria.registrar.Interceptor.java
/** * Se convierte una lista en un Iterador * /* ww w . ja v a 2 s . co m*/ * @param elementList Lista a transformar * @return it Se retorna el iterador de la lista */ public static Iterator checkList(List elementList) { Iterator it = null; if (elementList != null) it = elementList.iterator(); return it; }
From source file:com.projity.grouping.core.model.NodeModelUtil.java
public static void cacheWbs(NodeModel nodeModel, Node parentNode) { Object parentImpl = parentNode.getImpl(); List children = nodeModel.getChildren(parentNode); if (parentImpl instanceof Task && children != null && children.size() > 0) { Task parent = (Task) parentImpl; parent.setWbsChildrenNodes(children); // cached values Node child;/* w ww . j a v a 2 s. c o m*/ for (Iterator i = children.iterator(); i.hasNext();) { child = (Node) i.next(); Object impl = child.getImpl(); if (impl instanceof Task) { ((Task) impl).setWbsParent(parent); // set cached wbs parent // too cacheWbs(nodeModel, child); } } } }
From source file:com.sapienter.jbilling.server.user.validator.RepeatedPasswordValidator.java
/** * Queries the event_log table to check whether the user has already used * in the past the password he's trying to set now. * @param userId Id of the user whose password is being changed. * @return An array of <code>java.lang.String</code> containing the passwords * recently used by this user./*from w ww . j a v a2 s.c o m*/ */ private static String[] getPasswords(Integer userId) throws SQLException, NamingException { String[] passw = null; CachedRowSet cachedResults = new CachedRowSet(); JNDILookup jndi = JNDILookup.getFactory(); Connection conn = jndi.lookUpDataSource().getConnection(); cachedResults.setCommand(UserSQL.findUsedPasswords); GregorianCalendar date = new GregorianCalendar(); date.add(GregorianCalendar.YEAR, -2); cachedResults.setDate(1, new Date(date.getTimeInMillis())); cachedResults.setInt(2, userId); cachedResults.execute(conn); List<String> result = new ArrayList<String>(); while (cachedResults.next()) { result.add(cachedResults.getString(1)); } if (!result.isEmpty()) { passw = new String[result.size()]; int index = 0; for (Iterator i = result.iterator(); i.hasNext();) { passw[index] = (String) i.next(); index++; } } conn.close(); return passw; }
From source file:com.krawler.spring.crm.productModule.crmProductHandler.java
/** * * @param ll/*w w w.j a v a2 s. co m*/ * @param request * @param export * @param totalSize * @param crmManagerDAOObj * @return JSONObject */ public static JSONObject getProductReportJson(List<CrmProduct> ll, HttpServletRequest request, boolean export, int totalSize, crmManagerDAO crmManagerDAOObj, crmCommonDAO crmCommonDAOObj, DateFormat dateFormat) { JSONArray jarr = new JSONArray(); JSONObject jobjTemp = new JSONObject(); JSONObject commData = new JSONObject(); JSONArray jarrColumns = new JSONArray(); JSONArray jarrRecords = new JSONArray(); JSONObject jMeta = new JSONObject(); try { // Iterator ite = ll.iterator(); String currencyid = sessionHandlerImpl.getCurrencyID(request); String currencySymbol = crmManagerDAOObj.currencySymbol(currencyid); String companyid = sessionHandlerImpl.getCompanyid(request); for (CrmProduct crmProduct : ll) { JSONObject tmpObj = new JSONObject(); tmpObj.put("productid", crmProduct.getProductid()); tmpObj.put("name", crmProduct.getProductname()); tmpObj.put("ownerid", crmProduct.getUsersByUserid().getUserID()); tmpObj.put("owner", crmProduct.getUsersByUserid().getFirstName() + " " + crmProduct.getUsersByUserid().getLastName()); tmpObj.put("code", crmProduct.getCode()); tmpObj.put("commisionrate", crmProduct.getCommisionrate()); tmpObj.put("createdon", crmProduct.getCreatedOn() != null ? crmProduct.getCreatedOn() : ""); tmpObj.put("updatedon", crmProduct.getUpdatedOn() != null ? crmProduct.getUpdatedOn() : ""); tmpObj.put("currencyid", crmProduct.getCurrencyid()); tmpObj.put("description", crmProduct.getDescription()); tmpObj.put("productname", crmProduct.getProductname()); tmpObj.put("quantityindemand", crmProduct.getQuantityindemand()); tmpObj.put("quantitylevel", crmProduct.getQuantitylevel()); tmpObj.put("stockquantity", crmProduct.getStockquantity()); tmpObj.put("taxincurred", crmProduct.getTaxincurred()); tmpObj.put("threshold", crmProduct.getThreshold()); tmpObj.put("unitprice", crmProduct.getUnitprice() != null && !crmProduct.getUnitprice().equals("") ? crmManagerDAOObj.currencyRender(crmProduct.getUnitprice(), currencyid) : ""); tmpObj.put("categoryid", crmManagerCommon.comboNull(crmProduct.getCrmCombodataByCategoryid())); tmpObj.put("category", (crmProduct.getCrmCombodataByCategoryid() != null ? crmProduct.getCrmCombodataByCategoryid().getValue() : "")); tmpObj.put("vendornameid", crmProduct.getVendornamee()); tmpObj.put("validflag", crmProduct.getValidflag()); jarr.put(tmpObj); } commData.put("coldata", jarr); if (export) { List ll2 = crmManagerCommon.getHeaderName(crmCommonDAOObj, "Product"); Iterator ite2 = ll2.iterator(); while (ite2.hasNext()) { DefaultHeader obj1 = (DefaultHeader) ite2.next(); String newHeader2 = crmManagerCommon.getNewColumnHeader(crmCommonDAOObj, obj1.getDefaultHeader(), "Product", companyid); if (StringUtil.equal(Header.PRODUCTNAMEHEADER, obj1.getDefaultHeader())) { jobjTemp = new JSONObject(); jobjTemp.put("header", StringUtil.isNullOrEmpty(newHeader2) ? "Product Name" : newHeader2); jobjTemp.put("tip", StringUtil.isNullOrEmpty(newHeader2) ? "Product Name" : newHeader2); jobjTemp.put("pdfwidth", 60); jobjTemp.put("dataIndex", "name"); jobjTemp.put("xtype", "textfield"); jarrColumns.put(jobjTemp); } if (StringUtil.equal(Header.PRODUCTOWNERHEADER, obj1.getDefaultHeader())) { jobjTemp = new JSONObject(); jobjTemp.put("header", StringUtil.isNullOrEmpty(newHeader2) ? "Product Owner" : newHeader2); jobjTemp.put("tip", StringUtil.isNullOrEmpty(newHeader2) ? "Product Owner" : newHeader2); jobjTemp.put("pdfwidth", 60); jobjTemp.put("xtype", "textfield"); jobjTemp.put("dataIndex", "owner"); jarrColumns.put(jobjTemp); } else if (StringUtil.equal(Header.PRODUCTUNITPRICEHEADER, obj1.getDefaultHeader())) { jobjTemp = new JSONObject(); jobjTemp.put("header", StringUtil.isNullOrEmpty(newHeader2) ? "Unit Price" + "(" + currencySymbol + ")" : newHeader2 + "(" + currencySymbol + ")"); jobjTemp.put("tip", StringUtil.isNullOrEmpty(newHeader2) ? "Unit Price" + "(" + currencySymbol + ")" : newHeader2 + "(" + currencySymbol + ")"); jobjTemp.put("pdfwidth", 60); jobjTemp.put("xtype", "numberfield"); jobjTemp.put("dataIndex", "unitprice"); jobjTemp.put("align", "right"); jarrColumns.put(jobjTemp); } else if (StringUtil.equal(Header.PRODUCTCATEGORYHEADER, obj1.getDefaultHeader())) { jobjTemp = new JSONObject(); jobjTemp.put("header", StringUtil.isNullOrEmpty(newHeader2) ? Header.PRODUCTCATEGORYHEADER : newHeader2); jobjTemp.put("tip", StringUtil.isNullOrEmpty(newHeader2) ? Header.PRODUCTCATEGORYHEADER : newHeader2); jobjTemp.put("pdfwidth", 60); jobjTemp.put("xtype", "combo"); jobjTemp.put("dataIndex", "category"); jarrColumns.put(jobjTemp); } else if (StringUtil.equal(Header.PRODUCTVENDORNAMEHEADER, obj1.getDefaultHeader())) { jobjTemp = new JSONObject(); jobjTemp.put("header", StringUtil.isNullOrEmpty(newHeader2) ? Header.PRODUCTVENDORNAMEHEADER : newHeader2); jobjTemp.put("tip", StringUtil.isNullOrEmpty(newHeader2) ? Header.PRODUCTVENDORNAMEHEADER : newHeader2); jobjTemp.put("pdfwidth", 60); jobjTemp.put("xtype", "textfield"); jobjTemp.put("dataIndex", "vendornameid"); jarrColumns.put(jobjTemp); } else if (StringUtil.equal(Header.PRODUCTCREATIONDATEHEADER, obj1.getDefaultHeader())) { jobjTemp = new JSONObject(); jobjTemp.put("header", StringUtil.isNullOrEmpty(newHeader2) ? Header.PRODUCTCREATIONDATEHEADER : newHeader2); jobjTemp.put("tip", StringUtil.isNullOrEmpty(newHeader2) ? Header.PRODUCTCREATIONDATEHEADER : newHeader2); jobjTemp.put("title", "createdon"); jobjTemp.put("pdfwidth", 60); jobjTemp.put("align", "center"); jobjTemp.put("xtype", "datefield"); jobjTemp.put("dataIndex", "createdon"); jobjTemp.put("editor", "new Wtf.form.DateField({format:WtfGlobal.getOnlyDateFormat()})"); jobjTemp.put("renderer", "WtfGlobal.onlyDateRendererTZ"); jarrColumns.put(jobjTemp); } } jobjTemp = new JSONObject(); jobjTemp.put("name", "owner"); jarrRecords.put(jobjTemp); jobjTemp = new JSONObject(); jobjTemp.put("name", "name"); jarrRecords.put(jobjTemp); jobjTemp = new JSONObject(); jobjTemp.put("name", "unitprice"); jarrRecords.put(jobjTemp); jobjTemp = new JSONObject(); jobjTemp.put("name", "category"); jarrRecords.put(jobjTemp); jobjTemp = new JSONObject(); jobjTemp.put("name", "vendornameid"); jarrRecords.put(jobjTemp); jobjTemp = new JSONObject(); jobjTemp.put("name", "createdon"); jobjTemp.put("dateFormat", "time"); jobjTemp.put("type", "date"); jarrRecords.put(jobjTemp); commData.put("columns", jarrColumns); jMeta.put("totalProperty", "totalCount"); jMeta.put("root", "coldata"); jMeta.put("fields", jarrRecords); commData.put("metaData", jMeta); } commData.put("success", true); commData.put("totalCount", totalSize); } catch (Exception e) { logger.warn(e.getMessage(), e); } return commData; }
From source file:edu.ucsd.library.xdre.web.StatsCollectionsReportController.java
public static List<String> getValues(Document doc, String xPath) { List<String> values = new ArrayList<String>(); List<Node> nodes = doc.selectNodes(xPath); for (Iterator<Node> it = nodes.iterator(); it.hasNext();) values.add(it.next().getText()); return values; }
From source file:ch.cyberduck.core.aquaticprime.LicenseFactory.java
public static License find(final LicenseVerifierCallback callback) { try {// w w w. j a va 2 s .c o m final String clazz = preferences.getProperty("factory.licensefactory.class"); try { final Class<LicenseFactory> name = (Class<LicenseFactory>) Class.forName(clazz); final List<License> list = new ArrayList<License>(name.newInstance().open()); list.removeIf(key -> !key.verify(callback)); if (list.isEmpty()) { return LicenseFactory.EMPTY_LICENSE; } return list.iterator().next(); } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) { throw new FactoryException(e.getMessage(), e); } } catch (AccessDeniedException e) { log.warn(String.format("Failure finding receipt %s", e.getMessage())); } return LicenseFactory.EMPTY_LICENSE; }
From source file:com.kylinolap.query.routing.QueryRouter.java
private static CubeInstance getCheapestCube(List<CubeInstance> candidates) { sortByCost(candidates);/* www.ja v a 2s . c om*/ CubeInstance bestCube = null; if (!candidates.isEmpty()) { bestCube = candidates.iterator().next(); } return bestCube; }
From source file:ExifUtils.ExifReadWrite.java
public static meta exifToMeta(File fileMeta) { ArrayList<String> files = new ArrayList<>(); files.add(fileMeta.getName());/*from w w w .j a va 2 s .c o m*/ List<meta> exifToMeta = exifToMeta(files, fileMeta.getParentFile()); Iterator<meta> iterator = exifToMeta.iterator(); if (iterator.hasNext()) { return iterator.next(); } return null; }
From source file:com.amalto.workbench.utils.XmlUtil.java
public static List findLinks(Document document) throws DocumentException { List<String> urls = new ArrayList(); List list = document.selectNodes("//a/@href");//$NON-NLS-1$ for (Iterator iter = list.iterator(); iter.hasNext();) { Attribute attribute = (Attribute) iter.next(); String url = attribute.getValue(); urls.add(url);/*from w w w. j a va 2 s. c om*/ } return urls; }
From source file:com.krawler.esp.handlers.fileUploader.java
public static void parseRequest(HttpServletRequest request, HashMap<String, String> arrParam, ArrayList<FileItem> fi, boolean fileUpload, HashMap<Integer, String> filemap) throws ServiceException { DiskFileUpload fu = new DiskFileUpload(); FileItem fi1 = null;/*from ww w.j a v a 2 s .co m*/ List fileItems = null; int i = 0; try { fileItems = fu.parseRequest(request); } catch (FileUploadException e) { throw ServiceException.FAILURE("Admin.createUser", e); } for (Iterator k = fileItems.iterator(); k.hasNext();) { fi1 = (FileItem) k.next(); try { if (fi1.isFormField()) { arrParam.put(fi1.getFieldName(), fi1.getString("UTF-8")); } else { String fileName = new String(fi1.getName().getBytes(), "UTF8"); if (fi1.getSize() != 0) { fi.add(fi1); filemap.put(i, fi1.getFieldName()); i++; fileUpload = true; } } } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } } }