List of usage examples for java.util Set iterator
Iterator<E> iterator();
From source file:it.geosolutions.imageio.plugins.nitronitf.NITFImageWriter.java
/** * Setup all the header fields taking them from the wrapper * // w w w .j a v a 2s. c o m * @param record * @param headerWrapper * @throws NITFException */ private static void initFileHeader(Record record, HeaderWrapper headerWrapper) throws NITFException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Populating file header"); } final FileHeader header = record.getHeader(); NITFUtilities.setField("FHDR", header.getFileHeader(), NITFUtilities.Consts.DEFAULT_FILE_HEADER); NITFUtilities.setField("FVER", header.getFileVersion(), NITFUtilities.Consts.DEFAULT_FILE_VERSION); NITFUtilities.setField("STYPE", header.getSystemType(), NITFUtilities.Consts.DEFAULT_SYSTEM_TYPE); if (headerWrapper != null) { NITFUtilities.setField("OSTAID", header.getOriginStationID(), headerWrapper.getOriginStationId()); NITFUtilities.setField("FDT", header.getFileDateTime(), headerWrapper.getDateTime()); NITFUtilities.setField("FTITLE", header.getFileTitle(), headerWrapper.getTitle()); NITFUtilities.setField("FSCLSY", header.getSecurityGroup().getClassificationSystem(), headerWrapper.getSecurityClassificationSystem()); NITFUtilities.setField("ENCRYP", header.getEncrypted(), Integer.toString(headerWrapper.getEncrypted())); header.getClassification().setData(headerWrapper.getSecurityClassificationSystem()); NITFUtilities.setField("FBKGC", header.getBackgroundColor(), headerWrapper.getBackgroundColor()); NITFUtilities.setField("ONAME", header.getOriginatorName(), headerWrapper.getOriginatorName()); NITFUtilities.setField("OPHONE", header.getOriginatorPhone(), headerWrapper.getOriginatorPhone()); } if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "file header has been setup"); } // Setting main header TREs if any Map<String, Map<String, String>> tresMap = headerWrapper.getTres(); if (tresMap != null && !tresMap.isEmpty()) { Extensions extendedSection = header.getExtendedSection(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Populating Main Header TREs"); } Set<String> keys = tresMap.keySet(); Iterator<String> it = keys.iterator(); while (it.hasNext()) { String treName = it.next(); Map<String, String> fieldsMapping = tresMap.get(treName); TRE tre = setTRE(treName, fieldsMapping); extendedSection.appendTRE(tre); } } }
From source file:com.xtc.controller.ParkexpenseController.java
@SuppressWarnings("rawtypes") public static String createSign(Map<String, String> parameters) { StringBuffer sb = new StringBuffer(); Set es = parameters.entrySet(); //accsii Iterator it = es.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String k = (String) entry.getKey(); Object v = entry.getValue(); if (null != v && !"".equals(v) && !"sign".equals(k) && !"key".equals(k)) { sb.append(k + "=" + v + "&"); }/* ww w.j a va 2 s. c om*/ } sb.append("key=" + WeixinConfig.APP_KEY); String sign = MD5Util.MD5Encode(sb.toString(), "UTF-8").toUpperCase(); return sign; }
From source file:com.doculibre.constellio.services.SkosServicesImpl.java
private static SkosConcept getFirstBroaderConcept(SkosConcept skosConcept) { SkosConcept firstBroaderConcept;/*from w w w. ja va2 s . co m*/ Set<SkosConcept> broader = skosConcept.getBroader(); if (!broader.isEmpty()) { firstBroaderConcept = broader.iterator().next(); } else { firstBroaderConcept = null; } return firstBroaderConcept; }
From source file:io.prestosql.execution.resourceGroups.TestResourceGroups.java
private static int completeGroupQueries(Set<MockQueryExecution> groupQueries) { int groupRan = 0; for (Iterator<MockQueryExecution> iterator = groupQueries.iterator(); iterator.hasNext();) { MockQueryExecution query = iterator.next(); if (query.getState() == RUNNING) { query.complete();//from w w w. j a va 2 s .co m iterator.remove(); groupRan++; } } return groupRan; }
From source file:com.seer.datacruncher.utils.generic.CommonUtils.java
/** * Method took the XPATH set ,XML and returns the List of value for all matching element of Jaxb object. * There's also a method with the same signature except Set -> String * * @param xml/*from ww w . j a va 2 s. c o m*/ * @param xpathXpressionsSet * @param jaxbObject * @return * @throws Exception * @throws SAXException * @throws IOException * @throws XPathExpressionException */ public static Map<String, String> parseXMLandInvokeDoSomething(ByteArrayInputStream xml, Set<String> xpathXpressionsSet, Object jaxbObject) throws Exception, SAXException, IOException, XPathExpressionException { Map<String, String> map = new HashMap<String, String>(); Iterator<String> itr = xpathXpressionsSet.iterator(); while (itr.hasNext()) { String strXPath = itr.next(); List<String> xPath = breakXPathInList(strXPath); if (jaxbObject == null) return map; if (jaxbObject.getClass().isAnnotationPresent(XmlRootElement.class)) { XmlRootElement rootAnnotation = jaxbObject.getClass().getAnnotation(XmlRootElement.class); if (rootAnnotation.name().equals(xPath.get(0))) { recursiveIterateObjectWithXPath(jaxbObject, strXPath, xPath, 1, map); } } else { return map; } } return map; }
From source file:com.ai.runner.center.pay.web.business.payment.util.third.unionpay.sdk.SDKUtil.java
/** * ??HTTP POST?<br>//from w ww .j a va 2 s . c o m * @param action ????<br> * @param hiddens MAP??<br> * @param encoding ?encoding<br> * @return HTTP POST?<br> */ public static String createAutoFormHtml(String action, Map<String, String> hiddens, String encoding) { StringBuffer sf = new StringBuffer(); sf.append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + encoding + "\"/></head><body>"); sf.append("<form id = \"pay_form\" action=\"" + action + "\" method=\"post\">"); if (null != hiddens && 0 != hiddens.size()) { Set<Entry<String, String>> set = hiddens.entrySet(); Iterator<Entry<String, String>> it = set.iterator(); while (it.hasNext()) { Entry<String, String> ey = it.next(); String key = ey.getKey(); String value = ey.getValue(); sf.append( "<input type=\"hidden\" name=\"" + key + "\" id=\"" + key + "\" value=\"" + value + "\"/>"); } } sf.append("</form>"); sf.append("</body>"); sf.append("<script type=\"text/javascript\">"); sf.append("document.all.pay_form.submit();"); sf.append("</script>"); sf.append("</html>"); return sf.toString(); }
From source file:com.salesmanager.core.util.CheckoutUtil.java
/** * Creates an order product (OrderProduct) from a Product entity. An * OrderProduct is the entity used during checkout and persisted with the * order/*from w w w. j a v a 2s . c om*/ * * @param productId * @param locale * @param currency * @return * @throws Exception */ public static OrderProduct createOrderProduct(long productId, Locale locale, String currency) throws Exception { CatalogService cservice = (CatalogService) ServiceFactory.getService(ServiceFactory.CatalogService); Product p = cservice.getProduct(productId); OrderProduct scp = new OrderProduct(); if (p != null) { scp.setMerchantId(p.getMerchantId()); // check if attributes exist Collection attrs = cservice.getProductAttributes(p.getProductId(), locale.getLanguage()); boolean hasPricedAttributes = false; if (attrs != null && attrs.size() > 0) { Iterator i = attrs.iterator(); while (i.hasNext()) { ProductAttribute pa = (ProductAttribute) i.next(); if (!pa.isAttributeDisplayOnly()) { hasPricedAttributes = true; } } } if (hasPricedAttributes) { scp.setAttributes(true); } scp.setProductName(""); // name Set descriptions = p.getDescriptions(); if (descriptions != null) { Iterator i = descriptions.iterator(); while (i.hasNext()) { ProductDescription pd = (ProductDescription) i.next(); if (pd.getId().getLanguageId() == LanguageUtil.getLanguageNumberCode(locale.getLanguage())) { scp.setProductName(pd.getProductName()); scp.setProductDescription(pd.getProductDescription()); break; } } } scp.setProductId(p.getProductId()); scp.setTaxClassId(p.getProductTaxClassId()); // get download ProductAttributeDownload download = cservice.getProductDownload(p.getProductId()); if (download != null) { OrderProductDownload opd = new OrderProductDownload(); opd.setDownloadCount(0); opd.setDownloadMaxdays(download.getProductAttributeMaxdays()); opd.setDownloadMaxdays(download.getProductAttributeMaxdays()); opd.setOrderProductFilename(download.getProductAttributeFilename()); opd.setFileId(download.getProductAttributeId()); Set downloads = new HashSet(); downloads.add(opd); scp.setDownloads(downloads); } // now determine price BigDecimal price = ProductUtil.determinePriceNoDiscount(p, locale, currency); scp.setFinalPrice(price); scp.setProductPrice(price); scp.setCurrency(currency); scp.setProductQuantityOrderMax(p.getProductQuantityOrderMax()); if (p.getSpecial() != null) { scp.setProductSpecialNewPrice(p.getSpecial().getSpecialNewProductPrice()); scp.setProductSpecialDateAvailable(p.getSpecial().getSpecialDateAvailable()); scp.setProductSpecialDateExpire(p.getSpecial().getExpiresDate()); } scp.setPriceText(CurrencyUtil.displayFormatedAmountNoCurrency(price, currency)); scp.setPriceFormated(CurrencyUtil.displayFormatedAmountWithCurrency(price, currency)); // original price scp.setOriginalProductPrice(price); scp.setProductImage(p.getProductImage()); scp.setProductType(p.getProductType()); scp.setProductVirtual(p.isProductVirtual()); scp.setProductWidth(p.getProductWidth()); scp.setProductWeight(p.getProductWeight()); scp.setProductHeight(p.getProductHeight()); scp.setProductLength(p.getProductLength()); scp.setProductId(p.getProductId()); Set pricesSet = p.getPrices(); if (pricesSet != null) { Set productSet = new HashSet(); Iterator i = pricesSet.iterator(); while (i.hasNext()) { ProductPrice pp = (ProductPrice) i.next(); ProductPriceSpecial pps = pp.getSpecial(); if (pps != null) { pps.setOriginalPriceAmount(pp.getProductPriceAmount()); } OrderProductPrice opp = new OrderProductPrice(); opp.setDefaultPrice(pp.isDefaultPrice()); opp.setProductPriceAmount(pp.getProductPriceAmount()); opp.setProductPriceModuleName(pp.getProductPriceModuleName()); opp.setProductPriceTypeId(pp.getProductPriceTypeId()); opp.setSpecial(pps); Set priceDescriptions = pp.getPriceDescriptions(); if (priceDescriptions != null && priceDescriptions.size() > 0) { String priceDescription = ""; for (Object o : priceDescriptions) { ProductPriceDescription ppd = (ProductPriceDescription) o; if (ppd.getId().getLanguageId() == LanguageUtil .getLanguageNumberCode(locale.getLanguage())) { priceDescription = ppd.getProductPriceName(); break; } } opp.setProductPriceName(priceDescription); } productSet.add(opp); } scp.setPrices(productSet); } if (cservice.isProductSubscribtion(p)) { scp.setProductSubscribtion(true); } if (!p.isProductVirtual()) { scp.setShipping(true); } } return scp; }
From source file:com.salesmanager.core.util.ProductUtil.java
public static BigDecimal determinePriceNoDiscount(Product product, Locale locale, String currency) { BigDecimal price = product.getProductPrice(); // all other prices Set prices = product.getPrices(); if (prices != null) { Iterator pit = prices.iterator(); while (pit.hasNext()) { ProductPrice pprice = (ProductPrice) pit.next(); pprice.setLocale(locale);//from ww w . j a v a 2s . co m if (pprice.isDefaultPrice()) {// overwrites default price price = pprice.getProductPriceAmount(); } } } return price; }
From source file:com.aurel.track.util.GeneralUtils.java
/** * Creates a list from a set// ww w .j a v a 2 s. c o m * @param set * @return */ public static List createListFromSet(Set set) { List list = new ArrayList(); if (set != null) { Iterator iterator = set.iterator(); while (iterator.hasNext()) { list.add(iterator.next()); } } return list; }
From source file:net.sf.morph.util.TransformerUtils.java
private static Class[] getClassIntersection(Transformer[] transformers, ClassStrategy strategy) { Set s = ContainerUtils.createOrderedSet(); s.addAll(Arrays.asList(strategy.get(transformers[0]))); for (int i = 1; i < transformers.length; i++) { Set survivors = ContainerUtils.createOrderedSet(); Class[] c = strategy.get(transformers[i]); for (int j = 0; j < c.length; j++) { if (s.contains(c[j])) { survivors.add(c[j]);//from w w w. j a v a 2 s . com break; } if (c[j] == null) { break; } for (Iterator it = s.iterator(); it.hasNext();) { Class next = (Class) it.next(); if (next != null && next.isAssignableFrom(c[j])) { survivors.add(c[j]); break; } } } if (!survivors.containsAll(s)) { for (Iterator it = s.iterator(); it.hasNext();) { Class next = (Class) it.next(); if (survivors.contains(next) || next == null) { break; } for (int j = 0; j < c.length; j++) { if (c[j] != null && c[j].isAssignableFrom(next)) { survivors.add(next); break; } } } } s = survivors; } return s.isEmpty() ? CLASS_NONE : (Class[]) s.toArray(new Class[s.size()]); }