Example usage for java.util HashMap keySet

List of usage examples for java.util HashMap keySet

Introduction

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

Prototype

public Set<K> keySet() 

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:de.berlios.gpon.wui.actions.data.ItemSearchAction.java

private void addAssociatedProperties(List idMapped, HashMap associatedPropertyMap) {

    // build up a pathDigest -> ipd-List mapping
    final Hashtable pathAndProperties = new Hashtable();

    CollectionUtils.forAllDo(associatedPropertyMap.keySet(), new Closure() {
        // foreach key in associatedPropertyMap do:
        public void execute(Object o) {
            String key = (String) o;

            String[] keySplit = ItemSearchForm.splitAssociatedPropertyKey(key);

            String pathDigest = keySplit[0];
            String ipdId = keySplit[1];

            if (!pathAndProperties.containsKey(pathDigest)) {
                pathAndProperties.put(pathDigest, new ArrayList());
            }/*from   w  w  w .j av a  2s .  c o  m*/

            ((List) pathAndProperties.get(pathDigest)).add(new Long(ipdId));
        }
    });

    final String[] digests = (String[]) Collections.list(pathAndProperties.keys()).toArray(new String[0]);

    final PathResolver pathResolver = (PathResolver) getObjectForBeanId("pathResolver");

    CollectionUtils.forAllDo(idMapped, new Closure() {

        public void execute(Object o) {

            ItemMap im = (ItemMap) o;

            // foreach digest

            for (int digIdx = 0; digIdx < digests.length; digIdx++) {
                String digest = digests[digIdx];

                Set items = pathResolver.getItemsForPath(im.getItem().getId(), digest);

                if (items != null && items.size() > 0) {
                    if (items.size() > 1) {
                        throw new RuntimeException("more than one associated item found");
                    }

                    // get one & only item
                    Item item = ((Item[]) items.toArray(new Item[0]))[0];

                    Long[] ipds = (Long[]) ((List) pathAndProperties.get(digest)).toArray(new Long[0]);

                    ItemMappedById associatedImbi = new ItemMappedById(item);

                    for (int ipdIdx = 0; ipdIdx < ipds.length; ipdIdx++) {
                        Value value = associatedImbi.getValueObject(ipds[ipdIdx] + "");

                        if (value != null) {
                            im.addAdditionalAttribute(digest + "|" + ipds[ipdIdx], value);
                        }
                    }
                }
            }

        }
    });
}

From source file:com.sfs.whichdoctor.importer.ExamImporter.java

/**
 * Gets the description map.// www  .  jav  a  2s . co m
 *
 * @return the description map
 */
public final TreeMap<String, List<String>> getDescriptionMap() {

    TreeMap<String, List<String>> descriptionMap = new TreeMap<String, List<String>>();

    HashMap<Object, List<Object>> beanMap = this.getBeanMap();
    for (Object objPerson : beanMap.keySet()) {
        PersonBean person = (PersonBean) objPerson;
        String indexDescription = getIndexDescription(person);

        List<String> descriptions = new ArrayList<String>();

        for (Object objExam : beanMap.get(person)) {
            ExamBean exam = (ExamBean) objExam;
            descriptions.add(getValueDescription(exam));
        }
        descriptionMap.put(indexDescription, descriptions);
    }

    return descriptionMap;
}

From source file:de.uzk.hki.da.metadata.MetadataStructure.java

protected void printIndexInfo(String objectId) {
    HashMap<String, HashMap<String, List<String>>> indexInfo = getIndexInfo(objectId);
    for (String id : indexInfo.keySet()) {
        logger.info("-----------------------------------------------------");
        logger.info("ID: " + id);
        for (String info : indexInfo.get(id).keySet()) {
            logger.info(info + ": " + indexInfo.get(id).get(info));
        }/*  ww w. ja va  2 s .  co  m*/
        logger.info("-----------------------------------------------------");
    }
}

From source file:com.github.ignition.support.http.IgnitedHttpPost.java

public IgnitedHttpPost(IgnitedHttpClient ignitedHttp, String url, HttpEntity payload,
        HashMap<String, String> defaultHeaders) {
    super(ignitedHttp);
    this.request = new org.apache.http.client.methods.HttpPost(url);
    ((HttpEntityEnclosingRequest) request).setEntity(payload);

    request.setHeader(HTTP_CONTENT_TYPE_HEADER, payload.getContentType().getValue());
    for (String header : defaultHeaders.keySet()) {
        request.setHeader(header, defaultHeaders.get(header));
    }/*w ww .  ja  v a  2 s.  co m*/
}

From source file:org.forgerock.openam.mobile.commons.ASyncRestRequest.java

/**
 * Adds headers to all requests heading out of the HTTP Client. Ensures that we include
 * version information.//from   w  w  w .j  av a 2s. c o m
 */
private void addHeaders(HashMap<String, String> headers) {
    boolean versionAdded = false;

    if (headers != null) {
        for (String key : headers.keySet()) {
            if (key.equalsIgnoreCase(versionHeaderKey)) { //http headers are case-insensitive
                versionAdded = true;
            }
            request.addHeader(key, headers.get(key));
        }
    }

    if (!versionAdded) {
        request.addHeader(versionHeaderKey, versionHeaderValue); //add default
    }
}

From source file:cms.service.util.ItemUtility.java

public Element replaceData(Element target, HashMap<String, String> varmap) {
    //ItemUtility iu=new ItemUtility();
    String xml = target.asXML();//w w w  . j  ava 2s  .  c  o m

    for (String key : varmap.keySet()) {
        xml = xml.replaceAll(key, varmap.get(key).trim());
    }
    Element newElm = this.getRootElementFromXML(xml);

    return newElm;
}

From source file:com.mc.printer.model.panel.task.BuildModelTask.java

@Override
public Object doBackgrounp() {
    javax.swing.JTabbedPane tabs = AutoPrinterApp.getMainView().getMainWorkPanel();
    if (tabs != null) {
        if (tabs.getSelectedIndex() >= 0) {
            Component selectedcom = tabs.getSelectedComponent();
            if (selectedcom instanceof CanvasWork) {
                CanvasWork selectPanel = (CanvasWork) selectedcom;
                FormBeans beansForm = selectPanel.getBeansForm();

                /**/
                if (beansForm.getHeightcm() == 0 || beansForm.getWidthcm() == 0) {
                    int res = BaseMessage.CONFIRM(
                            "?\r\nA4.");
                    if (res != JOptionPane.OK_OPTION) {
                        return null;
                    }/*from   w  ww.j a v a  2 s .  c  o m*/
                }

                String imagePath = beansForm.getImgpath();
                HashMap<String, ComponentBean> parameterMap = selectPanel.getSavedForms();
                if (parameterMap.size() > 0) {
                    Set set = parameterMap.keySet();
                    boolean foundKey = false;
                    //???
                    List<ComponentBean> beans = new ArrayList();
                    Iterator it = set.iterator();
                    while (it.hasNext()) {
                        ComponentBean com = parameterMap.get(it.next().toString());
                        beans.add(com);
                        if (com.isIskey()) {
                            foundKey = true;
                        }
                    }
                    beansForm.setElements(beans);
                    //
                    //                        if (!foundKey) {
                    //                            BaseMessage.ERROR("PRIMARY KEY.");
                    //                            return null;
                    //                        }

                    BaseFileChoose fileChoose = new BaseFileChoose("?",
                            new String[] { Constants.MODEL_SUFFIX }, AutoPrinterApp.getMainFrame());
                    String selectedPath = fileChoose.showSaveDialog();
                    if (!selectedPath.trim().equals("")) {

                        //get formname
                        selectedPath = selectedPath + File.separator + beansForm.getFormname();
                        //String time=DateHelper.format(new Date(), "yyyyMMddHHmmss");
                        String finalZip = selectedPath;
                        if (!selectedPath.endsWith("." + Constants.MODEL_SUFFIX)) {
                            finalZip = selectedPath + "." + Constants.MODEL_SUFFIX;
                        }

                        String tempDir = selectedPath + File.separator + Constants.MODEL_TEMP_DIR;

                        File imageFile = new File(imagePath);

                        String xmlPath = tempDir + File.separator + imageFile.getName() + ".xml";
                        XMLHelper helper = new XMLHelper(xmlPath, beansForm);
                        try {
                            helper.write();
                        } catch (JAXBException ex) {
                            ex.printStackTrace();
                            logger.error(ex.getMessage());
                            return ex;
                        }

                        File paramFile = new File(xmlPath);
                        if (paramFile.isFile() && paramFile.exists()) {
                            try {
                                FileUtils.copyFileToDirectory(imageFile, new File(tempDir));
                                ZipHelper.createZip(tempDir, finalZip);
                                return "??.\r\n" + finalZip;
                            } catch (IOException ex) {
                                ex.printStackTrace();
                                logger.error(ex.getMessage());
                                return ex;
                            } finally {
                                try {
                                    FileUtils.deleteDirectory(new File(selectedPath));
                                } catch (IOException ex) {
                                    ex.printStackTrace();
                                    logger.error(ex.getMessage());
                                    return ex;
                                }
                            }
                        }
                    }
                } else {
                    return "??.";
                }
            } else {
                return "??????.";
            }
        } else {
            return ".";
        }
    } else {
        return ".";
    }
    return null;
}

From source file:net.emotivecloud.scheduler.drp4one.OneExtraFuncs.java

public Integer getKeyOfValue(HashMap<String, Integer> hm, Integer value) {

    Iterator<String> kIter = hm.keySet().iterator();
    while (kIter.hasNext()) {
        String key = kIter.next();
        if (hm.get(key) == value) {
            return hm.get(key);
        }/* www .  ja  v  a  2s .  com*/
    }
    return -1;
}

From source file:Evaluator.StatCalculator.java

public double correlationCalc(HashMap<String, Double> kderunQidMap, HashMap<String, Double> aprunQidMap) {
    double xArray[], yArray[];
    int count = 0;

    xArray = new double[kderunQidMap.size()];
    yArray = new double[kderunQidMap.size()];

    Iterator it = kderunQidMap.keySet().iterator();
    while (it.hasNext()) {
        String run = (String) it.next();
        xArray[count] = kderunQidMap.get(run);
        yArray[count++] = aprunQidMap.get(run);
    }//  w w w .  ja v  a 2 s  .c o m

    PearsonsCorrelation prc = new PearsonsCorrelation();
    return prc.correlation(xArray, yArray);

}

From source file:Evaluator.StatCalculator.java

public double kendalTauCalc(HashMap<String, Double> kderunQidMap, HashMap<String, Double> aprunQidMap) {
    double xArray[], yArray[];
    int count = 0;

    xArray = new double[kderunQidMap.size()];
    yArray = new double[kderunQidMap.size()];

    Iterator it = kderunQidMap.keySet().iterator();
    while (it.hasNext()) {
        String run = (String) it.next();
        xArray[count] = kderunQidMap.get(run);
        yArray[count++] = aprunQidMap.get(run);
    }// ww w. j av  a  2 s  .  c o  m

    KendallsCorrelation kc = new KendallsCorrelation();
    return kc.correlation(xArray, yArray);

}