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:com.linuxbox.enkive.imap.mailbox.mongo.MongoEnkiveImapMailboxMapper.java

@Override
public List<Mailbox<String>> list() throws MailboxException {
    ArrayList<Mailbox<String>> mailboxes = new ArrayList<Mailbox<String>>();
    DBObject mailboxListObject = getMailboxList();
    if (mailboxListObject != null) {
        @SuppressWarnings("unchecked")
        HashMap<String, String> mailboxTable = (HashMap<String, String>) mailboxListObject
                .get(MongoEnkiveImapConstants.MAILBOXES);

        for (String mailboxKey : mailboxTable.keySet()) {
            MailboxPath mailboxPath = new MailboxPath(session.getPersonalSpace(),
                    session.getUser().getUserName(), mailboxKey.replace("/", "."));
            EnkiveImapMailbox mailbox = new EnkiveImapMailbox(mailboxPath, 1);
            mailbox.setMailboxId(mailboxTable.get(mailboxKey));
            mailboxes.add(mailbox);//from  www  .  j a  v a  2 s .com
        }

    }
    MailboxPath inboxPath = new MailboxPath(session.getPersonalSpace(), session.getUser().getUserName(),
            MailboxConstants.INBOX);
    MailboxPath trashPath = new MailboxPath(session.getPersonalSpace(), session.getUser().getUserName(),
            "Trash");

    mailboxes.add(new EnkiveImapMailbox(inboxPath, 1));
    mailboxes.add(new EnkiveImapMailbox(trashPath, 1));
    return mailboxes;
}

From source file:mx.org.cedn.avisosconagua.engine.processors.Init.java

/**
 * Updates selected areas in the google map displayed in the web form.
 * @param nuevo new advice properties/*from  w  w w .  ja v a2s  .c  om*/
 * @param anterior previous advice properties
 */
private void procesaAreas(HashMap<String, String> nuevo, BasicDBObject anterior) {
    if (null != anterior) {
        HashMap<String, String> cambios = new HashMap<>();
        for (String key : nuevo.keySet()) {
            if (key.startsWith("area-")) {
                String states = "states" + key.substring(4);
                String municipalities = "municipalities" + key.substring(4);
                if (null == nuevo.get(states) || null == nuevo.get(municipalities)) {
                    if (((String) nuevo.get(key)).equals(anterior.get(key))) {
                        if (null != anterior.get(states)) {
                            cambios.put(states, (String) anterior.get(states));
                        }
                        if (null != anterior.get(municipalities)) {
                            cambios.put(municipalities, (String) anterior.get(municipalities));
                        }
                    }
                }

            }
        }
        if (!cambios.isEmpty()) {
            nuevo.putAll(cambios);
        }
    }
}

From source file:com.chargebee.CSV.PhoneBook.PhoneBook2.PhoneBook.java

private void display(HashMap<String, ArrayList> map) {
    Scanner sc = new Scanner(System.in);

    System.out.println("Search by : name/number?");
    String choice = sc.nextLine();
    System.out.println("Enter the " + choice + " : ");
    String param = sc.nextLine();

    if (choice.toLowerCase().equalsIgnoreCase("name")) {
        for (String key : map.keySet()) {
            if (key.toLowerCase().contains(param)) {
                ArrayList<Person> tempo = new ArrayList();
                tempo = map.get(key);//from   w w w  .j a  v  a2 s  .  c o  m
                for (Person p : tempo) {
                    p.print();
                }
            }
        }
    } else if (choice.toLowerCase().equalsIgnoreCase("number")) {
        for (Map.Entry<String, ArrayList> entry : map.entrySet()) {
            ArrayList<Person> tempo = new ArrayList();
            tempo = entry.getValue();
            for (Person p : tempo) {
                if (p.getPhone().getHomeNumber().equalsIgnoreCase(param)
                        || p.getPhone().getMobileNumber().equalsIgnoreCase(param)
                        || p.getPhone().getWorkNumber().equalsIgnoreCase(param)) {
                    p.print();
                    break;
                }
                System.out.println("Phone Number not found!!");
            }
        }
    } else {
        System.out.println("Invalid Choice!!");
    }
}

From source file:com.dagobert_engine.core.service.MtGoxApiAdapter.java

/**
 * Builds a query string/*from w w w .  ja va2 s.  c  o  m*/
 * 
 * @param args
 * @return
 */
private String buildQueryString(HashMap<String, String> args) {
    String result = new String();
    for (String hashkey : args.keySet()) {
        if (result.length() > 0)
            result += '&';
        try {
            result += URLEncoder.encode(hashkey, Constants.ENCODING) + "="
                    + URLEncoder.encode(args.get(hashkey), Constants.ENCODING);
        } catch (Exception ex) {
            Logger.getLogger(MtGoxTradeService.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    return result;
}

From source file:edu.gmu.cs.sim.util.media.chart.PieChartGenerator.java

String[] revisedLabels(HashMap map) {
    // Sort labels
    String[] labels = new String[map.size()];
    labels = (String[]) (map.keySet().toArray(labels));
    Arrays.sort(labels);/*from   w  w w  . j a  v a  2  s. c  om*/
    return labels;
}

From source file:com.tremolosecurity.embedd.EmbPostProc.java

protected HashMap<String, Attribute> setHeadersCookiesEmb(HttpFilterRequest req) throws Exception {
    Iterator<String> names;

    names = req.getHeaderNames();//from w w  w  .j ava2 s  .c o  m

    HashMap<String, Attribute> reqHeaders = new HashMap<String, Attribute>();

    while (names.hasNext()) {
        String name = names.next();
        if (name.equalsIgnoreCase("Cookie")) {

            continue;
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Header : " + name);
        }

        Attribute attrib = req.getHeader(name);
        ArrayList<String> vals = new ArrayList<String>();

        vals.addAll(attrib.getValues());
        //logger.info("Header : '" + name + "'='" + vals + "'");

        if (name.equalsIgnoreCase("Content-Type")) {
            continue;
        } else if (name.equalsIgnoreCase("If-Range")) {
            continue;
        } else if (name.equalsIgnoreCase("Range")) {
            continue;
        } else if (name.equalsIgnoreCase("If-None-Match")) {
            continue;
        }

        if (this.addHeader(name)) {
            Attribute header = reqHeaders.get(name);
            if (header == null) {
                header = new Attribute(name);
                reqHeaders.put(name, header);
            }

            header.getValues().addAll(vals);
        }

    }

    HashMap<String, Attribute> fromResults = (HashMap<String, Attribute>) req
            .getAttribute(AzSys.AUTO_IDM_HTTP_HEADERS);
    if (fromResults != null) {
        names = fromResults.keySet().iterator();

        while (names.hasNext()) {
            String name = names.next();
            reqHeaders.remove(name);

            Attribute attrib = fromResults.get(name);

            Attribute header = reqHeaders.get(name);
            if (header == null) {
                header = new Attribute(name);
                reqHeaders.put(name, header);
            }

            header.getValues().addAll(attrib.getValues());

            //logger.info("Header2 : '" + name + "'='" + header.getValues() + "'");
        }
    }

    return reqHeaders;

}

From source file:ffx.potential.parameters.ImproperTorsionType.java

/**
 * Remap new atom classes to known internal ones.
 *
 * @param typeMap a lookup between new atom types and known atom types.
 *///from w w w .  ja v  a2 s . com
public void patchClasses(HashMap<AtomType, AtomType> typeMap) {
    int count = 0;
    for (AtomType newType : typeMap.keySet()) {
        for (int i = 0; i < atomClasses.length; i++) {
            if (atomClasses[i] == newType.atomClass) {
                count++;
            }
        }
    }
    if (count > 0 && count < atomClasses.length) {
        for (AtomType newType : typeMap.keySet()) {
            for (int i = 0; i < atomClasses.length; i++) {
                if (atomClasses[i] == newType.atomClass) {
                    AtomType knownType = typeMap.get(newType);
                    atomClasses[i] = knownType.atomClass;
                }
            }

        }
        setKey(sortKey(atomClasses));
    }
}

From source file:fast.servicescreen.server.RequestServiceImpl.java

/**
 * This method forms <key=name, value=value> map into
 * several headers and ad those to the given post method
 * *///from  ww w.  j a va  2  s  .  c o  m
protected void addHeader(HttpPost post, HashMap<String, String> nameValueHeader) {
    String name = "";
    String value = "";
    for (Iterator<String> iterator = nameValueHeader.keySet().iterator(); iterator.hasNext();) {
        name = iterator.next();
        value = nameValueHeader.get(name);

        post.addHeader(name, value);
    }
}

From source file:CaseBlindHashMap.java

/**
 * Get the set of keys contained in this map. Keys values are returned as
 * simple <code>String</code>s (not the <code>CaseBlindString</code>s
 * used internally)./* w  w w  .  j av a2 s  .  c o m*/
 * 
 * This is accopmlished by making a copy of the original map - modifications
 * made to this copy are not reflected in the original.
 * 
 * @return The set of keys
 */
public Set stringKeySet() {
    Iterator iterator = super.keySet().iterator();
    HashMap stringKeys = new HashMap();

    while (iterator.hasNext()) {
        String key = ((CaseBlindString) iterator.next()).toString();

        stringKeys.put(key, get(key));
    }
    return stringKeys.keySet();
}

From source file:com.siemens.scr.avt.ad.query.common.NaturalJoinTreeTest.java

@Test
public void testLoadingFromHibernateMapping() throws JDOMException, IOException, ConfigurationException {
    joinTree.loadFromHibernateMapping(this.getClass().getResourceAsStream(testMapping));

    PropertiesConfiguration config = new PropertiesConfiguration(expectedFK);
    HashMap<String, String[]> fks = new HashMap<String, String[]>();
    Iterator it = config.getKeys();
    while (it.hasNext()) {
        String key = (String) it.next();
        fks.put(key, config.getStringArray(key));
    }//w ww . j  a  v a2s  .  co  m

    Set edges = getGraph().getEdges();

    assertEquals(fks.keySet().size(), edges.size());

    for (Object obj : edges) {
        NaturalFKEdge edge = (NaturalFKEdge) obj;
        assertEquals(fks.get(edge.getFK())[0], edge.getEndpoints().getFirst().toString());
        assertEquals(fks.get(edge.getFK())[1], edge.getEndpoints().getSecond().toString());
    }

}