List of usage examples for java.util List iterator
Iterator<E> iterator();
From source file:de.unidue.inf.is.ezdl.dlcore.utils.StringUtils.java
/** * Creates a single {@link String} with a seperator between all strings. * /* w w w .java 2s.co m*/ * @param list * list of string values * @param separator * a seperator string * @return a single {@link String} with a seperator between all strings */ public static String join(List<String> list, String separator) { StringBuilder sb = new StringBuilder(); Iterator<String> it = list.iterator(); while (it.hasNext()) { sb.append(it.next()); if (it.hasNext()) { sb.append(separator); } } return sb.toString(); }
From source file:com.aurel.track.persist.TNotifyTriggerPeer.java
/** * Converts a list of TNotificationTrigger torque objects to a list of TNotificationTriggerBean objects * @param torqueList//from w w w. jav a 2s . c om * @return */ private static List<TNotifyTriggerBean> convertTorqueListToBeanList(List<TNotifyTrigger> torqueList) { List<TNotifyTriggerBean> beanList = new ArrayList<TNotifyTriggerBean>(); if (torqueList != null) { Iterator<TNotifyTrigger> itrTorqueList = torqueList.iterator(); while (itrTorqueList.hasNext()) { TNotifyTrigger notifyTrigger = itrTorqueList.next(); beanList.add(notifyTrigger.getBean()); } } return beanList; }
From source file:Main.java
/** * sort Map by key desc/*from w w w . ja v a2 s .c om*/ * * @param unsortMap * @return */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static Map sortByComparator(Map unsortMap) { List list = new LinkedList(unsortMap.entrySet()); // sort list based on comparator Collections.sort(list, new Comparator() { public int compare(Object o1, Object o2) { return ((Comparable) ((Map.Entry) (o1)).getKey()).compareTo(((Map.Entry) (o2)).getKey()); } }); // put sorted list into map again Map sortedMap = new LinkedHashMap(); for (Iterator it = list.iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); sortedMap.put(entry.getKey(), entry.getValue()); } return sortedMap; }
From source file:com.thyn.backend.gcm.GcmSender.java
public static boolean listAllDevicesFromDeviceGroups() { List l = DatastoreHelpers.tryGetAllEntitiesOfAClass(Device.class); if (l == null) return false; Iterator<Device> i = l.iterator(); while (i.hasNext()) { Device d = i.next();/*from w w w . j a va 2 s .c o m*/ System.out.println("Notification key" + d.getNotification_key() + ", Notification key name: " + d.getNotification_key_name() + ", Registration token: " + d.getRegistration_token()); } return true; }
From source file:com.salesmanager.core.util.PaymentUtil.java
public static Map<String, PaymentMethod> getPaymentMethods(int merchantId, Locale locale) throws Exception { Map payments = new HashMap(); ResourceBundle bundle = ResourceBundle.getBundle("modules", locale); if (bundle == null) { log.error("Cannot load ResourceBundle checkout.properties"); }/*from w ww . j a va2 s.com*/ ReferenceService rservice = (ReferenceService) ServiceFactory.getService(ServiceFactory.ReferenceService); CountryDescription countryDescription = CountryUtil.getCountryByIsoCode(locale.getCountry(), locale); Map modules = new HashMap(); if (countryDescription != null) { modules = rservice.getPaymentMethodsMap(countryDescription.getId().getCountryId()); } ConfigurationRequest requestvo = new ConfigurationRequest(merchantId, true, PaymentConstants.MODULE_PAYMENT); MerchantService mservice = (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService); ConfigurationResponse responsevo = mservice.getConfiguration(requestvo); List config = responsevo.getMerchantConfigurationList(); if (config != null) { Iterator it = config.iterator(); while (it.hasNext()) { MerchantConfiguration m = (MerchantConfiguration) it.next(); String key = m.getConfigurationKey(); if (key.equals(PaymentConstants.MODULE_PAYMENT_INDICATOR_NAME)) {// module // configured // if(m.getConfigurationValue().equals("true")) { PaymentMethod method = null; // try to retreive the module first if (payments.containsKey(m.getConfigurationValue1())) { method = (PaymentMethod) payments.get(m.getConfigurationValue1()); } else { method = new PaymentMethod(); } if (m.getConfigurationValue() != null && m.getConfigurationValue().equals("true")) { //payments.remove(m // .getConfigurationValue1()); //continue; method.setEnabled(true); } CoreModuleService cms = (CoreModuleService) modules.get(m.getConfigurationValue1()); if (cms != null) { method.setPaymentImage(cms.getCoreModuleServiceLogoPath()); } method.setPaymentModuleName(m.getConfigurationValue1()); if (bundle != null) { try { String label = bundle.getString("module." + m.getConfigurationValue1()); if (StringUtils.isBlank(label)) { label = ""; } method.setPaymentMethodName(label); String text = bundle.getString("module.paymenttext." + m.getConfigurationValue1()); method.setPaymentModuleText(text); } catch (Exception e) { } } if (m.getConfigurationValue() != null && m.getConfigurationValue().equals("true")) { method.setEnabled(true); } payments.put(m.getConfigurationValue1(), method); continue; } if (key.contains(PaymentConstants.MODULE_PAYMENT_GATEWAY)) {// gateway // module PaymentMethod method = null; // try to retreive the module first if (payments.containsKey(m.getConfigurationModule())) { method = (PaymentMethod) payments.get(m.getConfigurationModule()); } else { method = new PaymentMethod(); } IntegrationProperties props = null; /** ASSUMING PROPERTIES ARE IN CONFIGURATION_VALUE 2 **/ if (!StringUtils.isBlank(m.getConfigurationValue2())) { props = MerchantConfigurationUtil.getIntegrationProperties(m.getConfigurationValue2(), ";"); } if (props != null && props.getProperties3() != null && props.getProperties3().equals("2")) {// use // cvv method.addConfig("CVV", "true"); } // core_modules_services subtype method.setType(1); payments.put(m.getConfigurationModule(), method); continue; } if (key.contains(PaymentConstants.MODULE_PAYMENT)) {// single // payment // module PaymentMethod method = null; // try to retreive the module first if (payments.containsKey(m.getConfigurationModule())) { method = (PaymentMethod) payments.get(m.getConfigurationModule()); } else { method = new PaymentMethod(); } // core_modules_services subtype method.setType(0); method.addConfig("key", m.getConfigurationValue()); method.addConfig("key1", m.getConfigurationValue1()); method.addConfig("key2", m.getConfigurationValue2()); payments.put(m.getConfigurationModule(), method); continue; } } } Set entries = payments.keySet(); Map paymentMethods = new HashMap(); for (Object o : entries) { String key = (String) o; PaymentMethod pm = (PaymentMethod) payments.get(key); if (pm.isEnabled()) { paymentMethods.put(pm.getPaymentModuleName(), pm); } } return paymentMethods; }
From source file:de.jwi.ftp.FTPUploader.java
private static String uploadFiles(FTPClient ftp, String ftpServerPath, List files) throws IOException { boolean rc = false; String rcs = "error"; List l = null;/*from w ww . jav a2s . c o m*/ rc = ftp.makeDirectory(ftpServerPath); boolean rc1 = ftp.changeWorkingDirectory(ftpServerPath); System.out.println("cd: " + ftpServerPath); if (rc1) { Iterator it = files.iterator(); while (it.hasNext()) { File f = (File) it.next(); if (f.isDirectory()) { String name = f.getName(); String newPath = ftpServerPath + "/" + name; l = Arrays.asList(f.listFiles()); rcs = uploadFiles(ftp, newPath, l); rc1 = ftp.changeWorkingDirectory(ftpServerPath); if (!rc1) { return "failed to chdir to " + ftpServerPath; } } else { rcs = uploadFile(ftp, ftpServerPath, f); } } } else { rcs = "failed to chdir to " + ftpServerPath; } return rcs; }
From source file:it.eng.spagobi.engines.worksheet.bo.WorkSheetDefinition.java
public static Map<String, List<String>> mergeDomainValuesFilters(List<Attribute> globalFilters, List<Attribute> sheetFilters) throws WrongConfigurationForFiltersOnDomainValuesException { Iterator<Attribute> globalFiltersIt = globalFilters.iterator(); Map<String, List<String>> toReturn = new HashMap<String, List<String>>(); while (globalFiltersIt.hasNext()) { Attribute aGlobalFilter = globalFiltersIt.next(); if (sheetFilters.contains(aGlobalFilter)) { // the filter is defined globally and also on sheets // wins the more restrictive filter int index = sheetFilters.indexOf(aGlobalFilter); Attribute sheetsFilter = sheetFilters.get(index); List<String> aGlobalFilterValues = aGlobalFilter.getValuesAsList(); List<String> sheetsFilterValues = sheetsFilter.getValuesAsList(); if (aGlobalFilterValues.containsAll(sheetsFilterValues)) { // the sheets filters are less or equal to the global filters (this should always happen) toReturn.put(aGlobalFilter.getEntityId(), sheetsFilterValues); } else { logger.error("The global filter on field " + aGlobalFilter.getAlias() + " is overridden by the sheet."); throw new WrongConfigurationForFiltersOnDomainValuesException( "The global filter on field " + aGlobalFilter.getAlias() + " is overridden by the sheet. Please expand the global filter's values."); }/*from ww w. j av a 2 s . c o m*/ } else { toReturn.put(aGlobalFilter.getEntityId(), aGlobalFilter.getValuesAsList()); } } Iterator<Attribute> sheetFiltersIt = sheetFilters.iterator(); while (sheetFiltersIt.hasNext()) { Attribute aSheetsFilter = sheetFiltersIt.next(); if (toReturn.containsKey(aSheetsFilter.getEntityId())) { // conflict already solved continue; } toReturn.put(aSheetsFilter.getEntityId(), aSheetsFilter.getValuesAsList()); } return toReturn; }
From source file:com.thyn.backend.gcm.GcmSender.java
public static boolean deleteAllDevicesFromDeviceGroups() { List l = DatastoreHelpers.tryGetAllEntitiesOfAClass(Device.class); if (l == null) return false; Iterator<Device> i = l.iterator(); while (i.hasNext()) { Device d = i.next();/*w ww .j ava 2 s . c o m*/ System.out.println("Notification key" + d.getNotification_key()); System.out.println("Notification key name" + d.getNotification_key_name()); System.out.println("registration token" + d.getRegistration_token()); System.out.println("Request to remove the above device from Device group"); removeDeviceFromDeviceGroup(d.getNotification_key_name(), d.getNotification_key(), d.getRegistration_token()); } return true; }
From source file:com.aurel.track.util.StringArrayParameterUtils.java
/** * Creates a comma separated string of integer values from a list of Integer * @param lst with Integer values/*from w w w .ja va 2s .c o m*/ * @return a comma separated String with integers */ public static String createStringFromIntegerList(List<Integer> lst) { StringBuffer buf = new StringBuffer(); if (lst != null && !lst.isEmpty()) { Iterator<Integer> it = lst.iterator(); while (it.hasNext()) { Integer day = it.next(); buf.append(day.toString()); if (it.hasNext()) { buf.append(","); } } } return buf.toString(); }
From source file:com.projity.pm.graphic.spreadsheet.common.transfer.NodeListTransferable.java
public static void nodeToString(Node node, StringBuffer sb, SpreadSheet spreadsheet, List fields) { CommonSpreadSheetModel model = (CommonSpreadSheetModel) spreadsheet.getModel(); Object value;/*from w w w . ja va 2s.c o m*/ Field field; Iterator fieldsIterator = fields.iterator(); boolean first = true; //String s=null; while (fieldsIterator.hasNext()) { field = (Field) fieldsIterator.next(); value = field.getValue(node, model.getCache().getWalkersModel(), model.getFieldContext()); if (first) first = false; else sb.append('\t'); sb.append((value == null) ? "" : value.toString()); //s=sb.toString(); //System.out.println("s="+s); } sb.append('\n'); for (Iterator i = node.childrenIterator(); i.hasNext();) nodeToString((Node) i.next(), sb, spreadsheet, fields); }