Example usage for java.util HashMap entrySet

List of usage examples for java.util HashMap entrySet

Introduction

In this page you can find the example usage for java.util HashMap entrySet.

Prototype

Set entrySet

To view the source code for java.util HashMap entrySet.

Click Source Link

Document

Holds cached entrySet().

Usage

From source file:eclserver.threads.EmergencyNotifyPush.java

@Override
//protected String doInBackground() {
protected String doInBackground() {
    //sometimes the initial delay can be long,
    //so let the user know we're working on it.
    //by giving a little progress    
    String pushId = "";
    Date date = new Date();
    System.out.println(dateFormat.format(date));
    String strBESServer = "";
    int responseCode = -99;
    //Get recipients objects from database 
    recipients = recListDao.getListEntries();
    //get Bes List from database;
    besList = besListDao.getListEntries();

    enPanel.printToResults("\nRecipients found:" + recipients.size());
    enPanel.printToResults("\nBES list size: " + besList.size());

    if ((recipients.size() > 0) && (besList.size() > 0)) {
        if (!this.isCancelled()) {

            recipientCheck: for (RecipientObject ro : recipients) {

                try {

                    if (ro.getMatched().matches("Y")) {
                        //   enPanel.printToResults("\n Matched " + ro.getMatched());
                        String[] strMatchedValue = ro.getUserBes().split(":");
                        URL builtURL = getPushURL(strMatchedValue[0], strMatchedValue[1], ro.getRecEmail(),
                                strAppPort);

                        pushId = "pushID:" + _r.nextInt();
                        responseCode = userCallPush(pushId, builtURL);

                        if (responseCode == 200) {

                            enPanel.printToResults(
                                    "\nMATCH:  USER-> " + ro.getRecEmail() + "    BES-> " + ro.getUserBes());
                            recListDao.editRecord(new RecipientObject(ro.getRecEmail(), ro.getUserBes(), "Y",
                                    dateFormat.format(date), ro.getId()));
                            continue recipientCheck;

                        } else {
                            enPanel.printToResults("\nUSER NOT FOUND ON PREVIOUS MATCHED BES: "
                                    + ro.getRecEmail() + "   on BES: " + strBESServer);
                            recListDao.editRecord(
                                    new RecipientObject(ro.getRecEmail(), "ERROR CODE: " + responseCode, "N",
                                            (String) dateFormat.format(date), ro.getId()));
                            ro.setMatched("N");

                        }//from w w w.ja v  a 2s .co  m
                    }
                    if (ro.getMatched().matches("N")) {

                        HashMap<String, URL> urlList = new HashMap();
                        responseCode = -99;

                        for (int b = 0; b < besList.size(); b++) {

                            // WE PUSHING TO BROWSER CACHE ONLY FOR TESTING WHETHER BES KNOWS THE PEEP.
                            URL builtURL = getPushURL(besList.get(b).getServerHost(),
                                    besList.get(b).getServerPort(), ro.getRecEmail(), strAppPort);

                            urlList.put(besList.get(b).getServerHost() + ":" + besList.get(b).getServerPort(),
                                    builtURL);
                        }

                        puahBES: for (Map.Entry<String, URL> entry : urlList.entrySet()) {
                            pushId = "pushID:" + _r.nextInt();

                            strBESServer = "";
                            responseCode = userCallPush(pushId, entry.getValue());
                            strBESServer = entry.getKey();

                            if (responseCode == 200) {

                                enPanel.printToResults(
                                        "\nMATCH:    USER: " + ro.getRecEmail() + "    BES: " + strBESServer);
                                recListDao.editRecord(new RecipientObject(ro.getRecEmail(), strBESServer, "Y",
                                        dateFormat.format(date), ro.getId()));

                                continue recipientCheck;

                            } else {
                                enPanel.printToResults(
                                        "\nUSER NOT FOUND " + ro.getRecEmail() + "   on BES: " + strBESServer);
                                recListDao.editRecord(
                                        new RecipientObject(ro.getRecEmail(), "ERROR CODE: " + responseCode,
                                                "N", (String) dateFormat.format(date), ro.getId()));
                            }
                        } //end for loop
                    }

                } catch (Exception ex) {
                    enPanel.printToResults("\nException during BES Validation: " + ex.getMessage());
                }

            } //end for loop: recipients
        } //check for canceled thread
    } else {
        enPanel.printToResults("\n\nYou must have at least 1 Recipient and 1 BES entered.");
    }

    return pushId;
}

From source file:eclserver.threads.EmergencyCallPush.java

@Override
protected String doInBackground() {
    //sometimes the initial delay can be long,
    //so let the user know we're working on it.
    //by giving a little progress    
    String pushId = "";
    Date date = new Date();
    String strBESServer = "";
    int responseCode = -99;
    //Get recipients objects from database 
    recipients = recListDao.getListEntries();
    //get Bes List from database;
    besList = besListDao.getListEntries();

    ecPanel.printToResults("\nRecipients found:" + recipients.size());
    ecPanel.printToResults("\nBES list size: " + besList.size());

    if ((recipients.size() > 0) && (besList.size() > 0)) {
        if (!this.isCancelled()) {

            recipientCheck: for (RecipientObject ro : recipients) {

                try {

                    if (ro.getMatched().matches("Y")) {
                        // ecPanel.printToResults("\n Matched " + ro.getMatched());
                        String[] strMatchedValue = ro.getUserBes().split(":");
                        URL builtURL = getPushURL(strMatchedValue[0], strMatchedValue[1], ro.getRecEmail(),
                                strAppPort);

                        pushId = "pushID:" + _r.nextInt();
                        responseCode = userCallPush(pushId, builtURL);

                        if (responseCode == 200) {

                            ecPanel.printToResults(
                                    "\nMATCH:  USER-> " + ro.getRecEmail() + "    BES-> " + ro.getUserBes());
                            recListDao.editRecord(new RecipientObject(ro.getRecEmail(), ro.getUserBes(), "Y",
                                    dateFormat.format(date), ro.getId()));
                            continue recipientCheck;

                        } else {
                            ecPanel.printToResults("\nUSER NOT FOUND ON PREVIOUS MATCHED BES: "
                                    + ro.getRecEmail() + "   on BES: " + strBESServer);
                            recListDao.editRecord(
                                    new RecipientObject(ro.getRecEmail(), "ERROR CODE: " + responseCode, "N",
                                            (String) dateFormat.format(date), ro.getId()));
                            ro.setMatched("N");

                        }/*from  www  .  j  a  v  a  2 s . c  om*/
                    }
                    if (ro.getMatched().matches("N")) {

                        HashMap<String, URL> urlList = new HashMap();
                        responseCode = -99;

                        for (int b = 0; b < besList.size(); b++) {

                            // WE PUSHING TO BROWSER CACHE ONLY FOR TESTING WHETHER BES KNOWS THE PEEP.
                            URL builtURL = getPushURL(besList.get(b).getServerHost(),
                                    besList.get(b).getServerPort(), ro.getRecEmail(), strAppPort);

                            urlList.put(besList.get(b).getServerHost() + ":" + besList.get(b).getServerPort(),
                                    builtURL);
                        }

                        puahBES: for (Map.Entry<String, URL> entry : urlList.entrySet()) {
                            pushId = "pushID:" + _r.nextInt();

                            strBESServer = "";
                            responseCode = userCallPush(pushId, entry.getValue());
                            strBESServer = entry.getKey();

                            if (responseCode == 200) {

                                ecPanel.printToResults(
                                        "\nMATCH:    USER: " + ro.getRecEmail() + "    BES: " + strBESServer);
                                recListDao.editRecord(new RecipientObject(ro.getRecEmail(), strBESServer, "Y",
                                        dateFormat.format(date), ro.getId()));

                                continue recipientCheck;

                            } else {
                                ecPanel.printToResults(
                                        "\nUSER NOT FOUND " + ro.getRecEmail() + "   on BES: " + strBESServer);
                                recListDao.editRecord(
                                        new RecipientObject(ro.getRecEmail(), "ERROR CODE: " + responseCode,
                                                "N", (String) dateFormat.format(date), ro.getId()));
                            }
                        } //end for loop
                    }

                } catch (Exception ex) {
                    ecPanel.printToResults("\nException during BES Validation: " + ex.getMessage());
                }

            } //end for loop: recipients
        } //check for canceled thread
    } else {
        ecPanel.printToResults("\n\nYou must have at least 1 Recipient and 1 BES entered.");
    }

    return pushId;
}

From source file:com.jaspersoft.studio.property.section.style.inerithance.StylesListSection.java

/**
 * Print the attributes that belong to a styles
 * //from   w  w w .j  a  v  a  2  s  .  c  om
 * @param parent
 *          composite of the main widget
 * @param element
 *          The selected element
 * @param keyPrefix
 *          the full path of the attribute 
 * @param parentType
 *          identify if the attribute belong to a style or to an element
 */
private void printStyleAttribute(Composite parent, APropertyNode element, String keyPrefix,
        AttributeParent parentType) {
    HashMap<String, Object> properties = element.getStylesDescriptors();
    for (Entry<String, Object> entry : properties.entrySet()) {
        String attributeKey = entry.getKey();
        Object attributeValue = entry.getValue();
        if (attributeValue != null) {
            if (keyPrefix != null) {
                attributeKey = keyPrefix.concat(".").concat(attributeKey);
            }
            printObject(attributeKey, attributeValue, parent, element, parentType);
        }
    }
}

From source file:com.metaparadigm.jsonrpc.JSONRPCBridge.java

private void uniqueMethods(HashSet m, String prefix, HashMap methodMap) {
    Iterator i = methodMap.entrySet().iterator();
    while (i.hasNext()) {
        Map.Entry mentry = (Map.Entry) i.next();
        MethodKey mk = (MethodKey) mentry.getKey();
        m.add(prefix + mk.methodName);//from   w w w.ja v  a2 s.com
    }
}

From source file:eu.planets_project.tb.impl.model.ExperimentExecutableImpl.java

public Collection<Entry<URI, String>> getCharacterisationHttpDataEntries() {
    HashMap<URI, String> hmRet = new HashMap<URI, String>();
    Iterator<Entry<String, String>> itEntries = this.hmInputOutputData.entrySet().iterator();

    while (itEntries.hasNext()) {
        //Entry<localFileRef,characterisation result>
        Entry<String, String> entry = itEntries.next();
        URI uri = this.getInputHttpFileRef(entry.getKey());
        if (uri != null) {
            hmRet.put(uri, entry.getValue());
        }/*from w  ww  .  j  a v  a2s.c o m*/
    }
    return hmRet.entrySet();
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.joinproperty.JoinMapGrid.java

private List<String> getListOfNonMappedFields(HashMap<String, List<String>> inputFieldMap) {
    Iterator<Entry<String, List<String>>> iterator = inputFieldMap.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry portFieldPair = (Map.Entry) iterator.next();
        for (LookupMapProperty lookupMapProperty : joinOutputList) {
            String port = "";
            if (lookupMapProperty.getSource_Field().length() >= 3) {
                port = lookupMapProperty.getSource_Field().substring(0, 3);
            }// w  w  w.j  a  v a2  s . c o  m
            String source_field = lookupMapProperty.getSource_Field()
                    .substring(lookupMapProperty.getSource_Field().lastIndexOf(".") + 1);
            if (portFieldPair.getKey().equals(port)) {
                List<String> value = (ArrayList<String>) portFieldPair.getValue();
                if (!value.isEmpty() && !checkIfSourceFieldExists(value, source_field)) {
                    nonMappedFieldList.add(port + "." + source_field);
                }
            } else {
                nonMappedFieldList.add(source_field);
            }
            if (port.equalsIgnoreCase("")) {
                nonMappedFieldList.add(source_field);
            }
        }
    }
    return nonMappedFieldList;
}

From source file:com.datatorrent.lib.util.AbstractBaseFrequentKey.java

/**
 * Emits the result.// www  .  j  ava  2 s .  co m
 */
@Override
public void endWindow() {
    // Compute least frequent
    K key = null;
    int kval = -1;
    HashMap<K, Object> map = new HashMap<K, Object>();
    for (Map.Entry<K, MutableInt> e : keycount.entrySet()) {
        if ((kval == -1)) {
            key = e.getKey();
            kval = e.getValue().intValue();
            map.put(key, null);
        } else if (compareCount(e.getValue().intValue(), kval)) {
            key = e.getKey();
            kval = e.getValue().intValue();
            map.clear();
            map.put(key, null);
        } else if (e.getValue().intValue() == kval) {
            map.put(e.getKey(), null);
        }
    }

    // Emit least frequent key, emit all least frequent keys list
    // on other ports.
    HashMap<K, Integer> tuple;
    if ((key != null) && (kval > 0)) {
        tuple = new HashMap<K, Integer>(1);
        tuple.put(key, new Integer(kval));
        emitTuple(tuple);
        ArrayList<HashMap<K, Integer>> elist = new ArrayList<HashMap<K, Integer>>();
        for (Map.Entry<K, Object> e : map.entrySet()) {
            tuple = new HashMap<K, Integer>(1);
            tuple.put(e.getKey(), kval);
            elist.add(tuple);
        }
        emitList(elist);
    }
    keycount.clear();
}

From source file:com.intuit.wasabi.api.pagination.filters.PaginationFilterTest.java

@Test
public void testTest() throws Exception {
    TestObjectFilter objectFilter = new TestObjectFilter();

    HashMap<String, Boolean> testCases = new HashMap<>();
    testCases.put("", true);
    testCases.put(null, true);//from   ww  w.j av a 2  s .c  om
    testCases.put("no match, fulltext", false);
    testCases.put("match", true);
    testCases.put("no match fulltext,hash=23", false);
    testCases.put("no match, fulltext,hash=23", false);
    testCases.put("match,hash=no match", false);
    testCases.put(",hash=no match", false);
    testCases.put("23", true);
    testCases.put("hash=34", true);
    testCases.put("hash=no match", false);
    testCases.put("hash=no match,moreKeys=values", false);
    testCases.put("fulltext,hash=no match,moreKeys=values", false);
    testCases.put("fulltext, more fulltext,hash=no match,moreKeys=values", false);

    for (Map.Entry<String, Boolean> testCase : testCases.entrySet()) {
        objectFilter.replaceFilter(testCase.getKey(), "");
        try {
            Assert.assertEquals("Case handled incorrectly: " + testCase.getKey(), testCase.getValue(),
                    objectFilter.test(testObject, TestObjectFilter.Property.class));
        } catch (Exception exception) {
            Assert.fail("Failed due to exception: " + exception.getMessage() + " - Test was: "
                    + testCase.getKey() + " -> " + testCase.getValue());
        }
    }
}

From source file:gsn.webservice.standard.GSNWebServiceSkeleton.java

/**
 * Auto generated method signature//from  w  w  w  .j ava  2 s  .  co m
 *
 * @param getVirtualSensorsDetails
 */

public gsn.webservice.standard.GetVirtualSensorsDetailsResponse getVirtualSensorsDetails(
        gsn.webservice.standard.GetVirtualSensorsDetails getVirtualSensorsDetails) {
    //throw new java.lang.UnsupportedOperationException("Please implement " + this.getClass().getName() + "#getVirtualSensorsDetails");
    //
    User user = getUserForAC(getVirtualSensorsDetails.getAcDetails());
    //
    GetVirtualSensorsDetailsResponse response = new GetVirtualSensorsDetailsResponse();
    //

    //
    HashMap<String, ArrayList<String>> vsAndFields = buildSelection(
            getVirtualSensorsDetails.getFieldSelector());
    for (Map.Entry<String, ArrayList<String>> selection : vsAndFields.entrySet()) {
        if (!Main.getContainerConfig().isAcEnabled()
                || (user != null && (user.hasReadAccessRight(selection.getKey()) || user.isAdmin()))) {
            VSensorConfig config = Mappings.getConfig(selection.getKey());
            if (config != null) {
                GSNWebService_VirtualSensorDetails details = new GSNWebService_VirtualSensorDetails();
                details.setVsname(selection.getKey());
                for (GSNWebService_DetailsType detail : getVirtualSensorsDetails.getDetailsType()) {
                    if ("INFO".equals(detail.getValue())) {
                        GSNWebService_ConfInfo info = new GSNWebService_ConfInfo();
                        info.setDescription(config.getDescription());
                        details.setInfo(info);
                    } else if ("PROCESSOR".equals(detail.getValue())) {
                        GSNWebService_ConfProcessor processor = new GSNWebService_ConfProcessor();
                        processor.setClassName(config.getProcessingClass());
                        for (Map.Entry<String, String> entry : config.getMainClassInitialParams().entrySet()) {
                            GSNWebService_ConfPredicate predicate = new GSNWebService_ConfPredicate();
                            predicate.setName(entry.getKey().toString());
                            predicate.setString(entry.getValue().toString());
                            processor.addInitParams(predicate);
                        }
                        details.setProcessor(processor);
                    } else if ("ADDRESSING".equals(detail.getValue())) {
                        GSNWebService_ConfAddressing addressing = new GSNWebService_ConfAddressing();
                        for (KeyValue kv : config.getAddressing()) {
                            GSNWebService_ConfPredicate predicate = new GSNWebService_ConfPredicate();
                            predicate.setName(kv.getKey().toString());
                            predicate.setString(kv.getValue().toString());
                            addressing.addPredicates(predicate);
                        }
                        details.setAddressing(addressing);
                    } else if ("OUTPUTSTRUCTURE".equals(detail.getValue())) {
                        GSNWebService_ConfOutputStructure outputstructure = new GSNWebService_ConfOutputStructure();
                        for (DataField df : config.getOutputStructure()) {
                            GSNWebService_DataField dataField = new GSNWebService_DataField();
                            if (df.getDescription() != null)
                                dataField.setDescription(df.getDescription());
                            if (df.getName() != null)
                                dataField.setName(df.getName());
                            if (df.getType() != null)
                                dataField.setType(df.getType());
                            dataField.setString("");
                            outputstructure.addFields(dataField);
                        }
                        details.setOutputStructure(outputstructure);
                    } else if ("WRAPPER".equals(detail.getValue())) {
                        GSNWebService_ConfWrapper wrapperConf = new GSNWebService_ConfWrapper();
                        for (gsn.beans.InputStream inputStream : config.getInputStreams()) {
                            for (gsn.beans.StreamSource source : inputStream.getSources()) {
                                AddressBean ab = source.getActiveAddressBean();
                                //
                                GSNWebService_WrapperDetails wd = new GSNWebService_WrapperDetails();
                                //
                                GSNWebService_WrapperURL wrapperURL = new GSNWebService_WrapperURL();
                                wrapperURL.setVirtualSensor(config.getName());
                                wrapperURL.setStream(inputStream.getInputStreamName());
                                wrapperURL.setSource(source.getAlias().toString());
                                wrapperURL.setWrapper(source.getActiveAddressBean().getWrapper());
                                wd.setWrapperURLs(wrapperURL);
                                //
                                for (KeyValue kv : ab.getPredicates()) {
                                    GSNWebService_ConfPredicate predicate = new GSNWebService_ConfPredicate();
                                    predicate.setName(kv.getKey().toString());
                                    predicate.setString(kv.getValue().toString());
                                    wd.addPredicates(predicate);
                                }
                                //
                                for (DataField df : source.getWrapper().getOutputFormat()) {
                                    GSNWebService_DataField dataField = new GSNWebService_DataField();
                                    if (df.getDescription() != null)
                                        dataField.setDescription(df.getDescription());
                                    if (df.getName() != null)
                                        dataField.setName(df.getName());
                                    if (df.getType() != null)
                                        dataField.setType(df.getType());
                                    dataField.setString("");
                                    wd.addOutputFormat(dataField);
                                }
                                wrapperConf.addWrapperDetails(wd);
                            }
                        }
                        details.setWrapper(wrapperConf);
                    }
                }
                response.addVirtualSensorDetails(details);
            }
        }
    }

    //

    //
    return response;
}

From source file:com.castlabs.csf.cff.CreateStreamingDeliveryTargetFileset.java

public Map<Track, String> setupTracks() throws IOException, CommandAbortException, XPathExpressionException,
        SAXException, ParserConfigurationException {
    Map<Track, String> track2File = new HashMap<Track, String>();
    List<File> xmls = new ArrayList<File>();
    for (File inputFile : inputFiles) {
        if (inputFile.getName().endsWith("mp4")) {
            Movie movie = MovieCreator.build(new FileDataSourceImpl(inputFile));
            for (Track track : movie.getTracks()) {
                if (checkCodecAndLanguage(track, inputFile.getName())) {
                    track2File.put(track, inputFile.getName());
                }/*from  ww  w  . j a va  2 s .  c  o m*/
            }
        } else {
            Track track = null;
            if (inputFile.getName().endsWith(".aac")) {
                track = new AACTrackImpl(new FileDataSourceImpl(inputFile));
                logger.fine("Created AAC Track from " + inputFile.getName());
            } else if (inputFile.getName().endsWith(".h264")) {
                track = new H264TrackImpl(new FileDataSourceImpl(inputFile));
                logger.fine("Created H264 Track from " + inputFile.getName());
            } else if (inputFile.getName().endsWith(".ac3")) {
                track = new AC3TrackImpl(new FileDataSourceImpl(inputFile));
                logger.fine("Created AC3 Track from " + inputFile.getName());
            } else if (inputFile.getName().endsWith(".ec3")) {
                track = new EC3TrackImpl(new FileDataSourceImpl(inputFile));
                logger.fine("Created EC3 Track from " + inputFile.getName());
            } else if (inputFile.getName().endsWith(".dtshd")) {
                track = new DTSTrackImpl(new FileDataSourceImpl(inputFile));
                logger.fine("Created DTS HD Track from " + inputFile.getName());
            } else if (inputFile.getName().endsWith(".xml")) {
                xmls.add(inputFile);

            } else {
                logger.warning("Cannot identify type of " + inputFile
                        + ". Extensions mp4, aac, ac3, ec3 or dtshd are known.");
            }
            if (track != null) {
                if (language != null) {
                    track.getTrackMetaData().setLanguage(language);
                } else {
                    logger.fine("No language given for raw track - defaulting to " + DEFAULT_LANG);
                    track.getTrackMetaData().setLanguage(DEFAULT_LANG);
                }
                if ((checkCodecAndLanguage(track, inputFile.getName()))) {
                    track2File.put(track, inputFile.getName());
                }
            }
        }
    }

    if (!xmls.isEmpty()) {
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        dbFactory.setNamespaceAware(true);
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        HashMap<String, List<File>> languageGrouped = new HashMap<String, List<File>>();
        final HashMap<File, Long> startTimes = new HashMap<File, Long>();
        for (File xml : xmls) {
            Document doc = dBuilder.parse(xml);
            String lang = SMPTETTTrackImpl.getLanguage(doc);
            List<File> sameLangFiles = languageGrouped.get(lang);
            if (sameLangFiles == null) {
                sameLangFiles = new ArrayList<File>();
                languageGrouped.put(lang, sameLangFiles);
            }
            sameLangFiles.add(xml);
            startTimes.put(xml, SMPTETTTrackImpl.earliestTimestamp(doc));
        }

        for (Map.Entry<String, List<File>> stringListEntry : languageGrouped.entrySet()) {
            String lang = stringListEntry.getKey();
            List<File> sameLangFiles = stringListEntry.getValue();
            Collections.sort(sameLangFiles, new Comparator<File>() {
                @Override
                public int compare(File o1, File o2) {
                    return (int) (startTimes.get(o1) - startTimes.get(o2));
                }
            });
            track2File.put(new SMPTETTTrackImpl(sameLangFiles.toArray(new File[sameLangFiles.size()])),
                    sameLangFiles.get(0).getName());
            logger.fine("Created SMPTE-TT Track from " + sameLangFiles + " in " + lang);
        }
    }
    return track2File;
}