Example usage for java.util Hashtable get

List of usage examples for java.util Hashtable get

Introduction

In this page you can find the example usage for java.util Hashtable get.

Prototype

@SuppressWarnings("unchecked")
public synchronized V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:CutPasteSample.java

private static Action findAction(Action actions[], String key) {
    Hashtable<Object, Action> commands = new Hashtable<Object, Action>();
    for (int i = 0; i < actions.length; i++) {
        Action action = actions[i];
        commands.put(action.getValue(Action.NAME), action);
    }/*from w  w w  . j  av  a  2  s .  c om*/
    return commands.get(key);
}

From source file:Main.java

public static Bundle hashtableToBundle(Hashtable table) {
    Bundle bundle = new Bundle();

    Iterator iterator = table.keySet().iterator();
    String key;/*from ww  w .jav a  2 s.com*/
    Object val;
    while (iterator.hasNext()) {
        key = (String) iterator.next();
        val = table.get(key);
        if (val instanceof Integer) {
            bundle.putInt(key, (Integer) val);
        } else if (val instanceof String) {
            bundle.putString(key, (String) val);
        }
    }
    return bundle;

}

From source file:Main.java

static Hashtable hashtableMerge(Hashtable dst, Hashtable src) {
    if (dst == null)
        return src;
    if (src == null)
        return dst;

    Enumeration e = src.keys();/*  ww w.j a  v a  2 s . com*/

    while (e.hasMoreElements()) {
        Object element = e.nextElement();
        dst.put(element, src.get(element));
    }
    return dst;
}

From source file:Main.java

static Hashtable hashtableClone(Hashtable ht) {
    if (ht == null)
        return null;

    Hashtable htresp = new Hashtable();
    Enumeration e = ht.keys();/*from w w  w .  ja v  a  2s . c  o  m*/

    while (e.hasMoreElements()) {
        Object element = e.nextElement();
        htresp.put(element, ht.get(element));
    }
    return htresp;
}

From source file:com.projity.configuration.Dictionary.java

public static NamedItem get(Object category, String name) {
    Hashtable subMap = (Hashtable) getInstance().mainMap.get(category);
    if (subMap == null)
        return null;
    return (NamedItem) subMap.get(name);
}

From source file:Main.java

public static Hashtable<Integer, Set<Integer>> getNodeMembership(Hashtable<Integer, Set<Integer>> nIDComVH,
        final Vector<Set<Integer>> cmtyVV) {
    for (int i = 0; i < cmtyVV.size(); i++) {
        int CID = i;
        for (Integer NID : cmtyVV.get(i)) {
            if (nIDComVH.containsKey(NID)) {
                Set<Integer> x = nIDComVH.get(NID);
                x.add(CID);/*from w  w w.ja v  a 2 s  .c  om*/
            } else {
                Set<Integer> x = new HashSet<Integer>();
                x.add(CID);
                nIDComVH.put(NID, x);
            }

        }
    }
    return nIDComVH;
}

From source file:Main.java

private static List<NameValuePair> buildNameValuePair(Hashtable<String, String> httpPost) {
    if (httpPost == null)
        return null;

    List<NameValuePair> nvps = new ArrayList<NameValuePair>();
    Enumeration<String> keys = httpPost.keys();
    while (keys.hasMoreElements()) {
        String key = (String) keys.nextElement();
        String value = (String) httpPost.get(key);
        BasicNameValuePair nv = new BasicNameValuePair(key, value);
        nvps.add(nv);/*from  w  w  w . j a  va2 s  . co m*/
    }

    return nvps;
}

From source file:Main.java

static Hashtable hashtableClone(Hashtable ht1, Hashtable ht2) {
    if (ht1 == null && ht2 == null)
        return null;

    Hashtable htresp = new Hashtable();

    if (ht1 != null) {
        Enumeration e = ht1.keys();
        while (e.hasMoreElements()) {
            Object element = e.nextElement();
            htresp.put(element, ht1.get(element));
        }/*from  www  . ja  va  2 s . c o  m*/
    }
    if (ht2 != null) {
        Enumeration e = ht2.keys();
        while (e.hasMoreElements()) {
            Object element = e.nextElement();
            htresp.put(element, ht2.get(element));
        }
    }
    return htresp;
}

From source file:Main.java

/**
 * dump bipartite community affiliation into a text file with node names
 * // ww  w .j a  va2 s.c om
 * @param OutFNm
 * @param CmtyVV
 * @param NIDNmH
 */
static void dumpCmtyVV(final String OutFNm, Vector<Vector<Integer>> CmtyVV, Hashtable<Integer, String> NIDNmH) {
    PrintWriter f;
    try {
        f = new PrintWriter(OutFNm);

        for (int c = 0; c < CmtyVV.size(); c++) {
            for (int u = 0; u < CmtyVV.get(c).size(); u++) {
                if (NIDNmH.containsKey(CmtyVV.get(c).get(u))) {
                    f.printf("%s\t", NIDNmH.get(CmtyVV.get(c).get(u)));
                } else {
                    f.printf("%d\t", (int) CmtyVV.get(c).get(u));
                }
            }
            f.printf("\n");
        }
        f.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * Saves an index (Hashtable) to a file.
 * /*from   w  w  w .j  a  va 2 s.  c  o  m*/
 * @param root_
 *            The file where the index is stored in.
 * @param index
 *            The indextable.
 * @exception IOException
 *                If an internal error prevents the file from being written.
 */
public static void saveIndex(File root_, String name, Hashtable index) throws IOException {
    File indexfile = new File(root_, name);
    PrintWriter out = new PrintWriter(new FileWriter(indexfile));
    Enumeration keys = index.keys();
    String key = null;
    while (keys.hasMoreElements()) {
        key = (String) keys.nextElement();
        out.println(key);
        out.println((Long) index.get(key));
    }
    out.close();
}