Example usage for java.util Hashtable Hashtable

List of usage examples for java.util Hashtable Hashtable

Introduction

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

Prototype

public Hashtable() 

Source Link

Document

Constructs a new, empty hashtable with a default initial capacity (11) and load factor (0.75).

Usage

From source file:Main.java

public Main() {

    setLayout(new FlowLayout());
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    table = new Hashtable<Integer, Color>();
    table.put(1, Color.RED);//from   ww w. java2  s  .c o m
    table.put(2, Color.BLUE);
    table.put(3, Color.GREEN);
    table.put(4, Color.GRAY);

    c = new JComboBox<String>();
    c.addItem("Item 1");
    c.addItem("Item 2");
    c.addItem("Item 3");
    c.addItem("Item 4");
    c.addItem("Item 5");
    c.addItem("Item 6");
    c.addItem("Item 7");
    c.addItem("Item 8");

    c.setRenderer(new MyListCellRenderer(table));

    add(c);
    setSize(400, 400);
    setVisible(true);
}

From source file:CustomFileFilter.java

public CustomFileFilter() {
    this.filters = new Hashtable();
}

From source file:Main.java

/**
 * Create a Hash table from supplied Map, this is passed to Hessian encoder
 * to create Hessian encoded request body.
 * //from   www. jav a 2s .  c  o m
 * @param map The source map.
 * @return Hash table from supplied Map.
 */
protected static Hashtable<String, Object> createHashTable(Map<String, List<String>> map) {
    Hashtable<String, Object> hashtable = new Hashtable<String, Object>();

    Set<Map.Entry<String, List<String>>> set = map.entrySet();
    for (Map.Entry<String, List<String>> obj : set) {
        hashtable.put(obj.getKey(), new Vector<String>(obj.getValue()));
    }
    return hashtable;
}

From source file:myLexTo.ReadConfig.java

public Hashtable read() {
    Hashtable config = new Hashtable();

    try {/*from w w  w.  j av a  2s. com*/
        File f = new File(System.getProperty("java.class.path"));
        File dir = f.getAbsoluteFile().getParentFile();

        String path = dir.getParent().toString();
        String configFile = path + "/config.json";

        JSONTokener jsonTokener = new JSONTokener(new FileReader(path + "/config.json"));
        JSONArray arrobj = new JSONArray(jsonTokener);

        for (int i = 0; i < arrobj.length(); i++) {
            JSONObject item = arrobj.getJSONObject(i);
            String lexitron = item.getString("lexitron");
            String herblist = item.getString("herblist");
            String properties = item.getString("properties");
            String stopwords = item.getString("stopwords");
            String symptoms = item.getString("symptoms");

            config.put("lexitron", lexitron);
            config.put("herblist", herblist);
            config.put("properties", properties);
            config.put("stopwords", stopwords);
            config.put("symptoms", symptoms);
        }
    } catch (FileNotFoundException | JSONException ex) {
        Logger.getLogger(ReadConfig.class.getName()).log(Level.SEVERE, null, ex);
    }

    return config;
}

From source file:com.basistech.yca.JsonNodeFlattener.java

public static Dictionary<String, ?> flatten(JsonNode node) {
    Dictionary<String, Object> map = new Hashtable<>();
    /* We need a depth-first traversal of the node */
    try {/*w  ww . ja  v a2  s. com*/
        traverse(node, "", map);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return map;
}

From source file:XYLayout.java

public XYLayout() {
    info = new Hashtable();
}

From source file:WeblogicDbServlet.java

public void init() throws ServletException {

    Context env = null;/*from  w w w .  j  a v a  2s.c  om*/

    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    //ht.put(Context.PROVIDER_URL,"t3://localhost:7001");

    try {

        env = new InitialContext(ht);
        pool = (javax.sql.DataSource) env.lookup("oracle-8i-athletes");

        if (pool == null)
            throw new ServletException("'oracle-8i-athletes' is an unknown DataSource");

    } catch (NamingException ne) {

        throw new ServletException(ne);

    }

}

From source file:XYLayout.java

public XYLayout(int width, int height) {
    info = new Hashtable();
    this.width = width;
    this.height = height;
}

From source file:com.kevinquan.google.activityrecoginition.model.MotionHelper.java

public static List<MotionSnapshot> parseMotionSnapshots(Cursor result, final boolean sortDescending) {
    if (!CursorUtils.hasResults(result)) {
        Log.d(TAG, "No results were provided to parse motion snapshots from");
        return new ArrayList<MotionSnapshot>();
    }/*from w  w  w .  ja  va2 s  .  c  o  m*/
    Hashtable<Long, MotionSnapshot> snapshots = new Hashtable<Long, MotionSnapshot>();

    do {
        Motion thisMotion = new Motion(result);
        if (thisMotion.getTimestamp() == 0) {
            Log.w(TAG, "Current motion seems corrupt: " + thisMotion);
            continue;
        }
        if (!snapshots.containsKey(thisMotion.getTimestamp())) {
            MotionSnapshot snapshot = new MotionSnapshot(thisMotion);
            snapshots.put(snapshot.getTimestamp(), snapshot);
        } else {
            if (!snapshots.get(thisMotion.getTimestamp()).addMotion(thisMotion)) {
                Log.w(TAG, "Could not add motion to snapshot: " + thisMotion.toString());
            }
        }
    } while (result.moveToNext());

    List<MotionSnapshot> results = new ArrayList<MotionSnapshot>();
    results.addAll(snapshots.values());
    Collections.sort(results, new Comparator<MotionSnapshot>() {
        @Override
        public int compare(MotionSnapshot lhs, MotionSnapshot rhs) {
            int result = ((Long) lhs.getTimestamp()).compareTo((Long) rhs.getTimestamp());
            return sortDescending ? -1 * result : result;
        }
    });
    return results;
}

From source file:CutPasteSample.java

public static Action findAction(Action actions[], String key) {
    Hashtable commands = new Hashtable();
    for (int i = 0; i < actions.length; i++) {
        Action action = actions[i];
        commands.put(action.getValue(Action.NAME), action);
    }//from w  ww .j av a2s .  c om
    return (Action) commands.get(key);
}