Example usage for java.util Dictionary put

List of usage examples for java.util Dictionary put

Introduction

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

Prototype

public abstract V put(K key, V value);

Source Link

Document

Maps the specified key to the specified value in this dictionary.

Usage

From source file:Main.java

public static void main(String args[]) {
    Dictionary ht = new Hashtable();
    ht.put("a", "a");
    ht.put("b", new Double(2));
    ht.put("c", "b");
    ht.put("d", new Integer(30));
    show(ht);/*from   ww  w.  j  a  va2 s. c o m*/
}

From source file:Main.java

public static void main(String[] args) {

    Dictionary d = new Hashtable();

    // put some elements
    d.put("1", "from java2s.com");
    d.put("2", "Cocoa");
    d.put("5", "Coffee");

    // print how many times put was called
    System.out.println("Number of times put was called:" + d.size());
}

From source file:Main.java

public static void main(String[] args) {
    Dictionary d = new Hashtable();

    // add some elements
    d.put("1", "from java2s.com");
    d.put("2", "Cocoa");
    d.put("5", "Coffee");

    // return an enumeration of the keys from this dictionary.
    for (Enumeration e = d.keys(); e.hasMoreElements();) {
        System.out.println(e.nextElement());
    }/* www .ja v  a 2 s .  c  o  m*/
}

From source file:Main.java

public static void main(String[] args) {

    Dictionary d = new Hashtable();

    // add 2 elements
    d.put(1, "Cocoa");
    d.put(4, "from java2s.com" + "Bar");
    System.out.println("1 is " + d.get(1));
    System.out.println("4 is " + d.get(4));

    // generates a series of elements, one at a time
    for (Enumeration e = d.elements(); e.hasMoreElements();) {
        System.out.println(e.nextElement());
    }/*from  w w  w. j ava  2  s  .c  o  m*/
}

From source file:Main.java

public static void main(String[] args) {

    Dictionary d = new Hashtable();

    // add some elements
    d.put("1", "from java2s.com");
    d.put("2", "Cocoa");
    d.put("5", "from java2s.com");

    // remove one element
    System.out.println(d.get("5"));
    System.out.println(d.remove("5") + " has been removed");
    System.out.println(d.get("5"));
}

From source file:Main.java

public static void main(String[] args) {

    // Create a new hasthtable
    Dictionary d = new Hashtable();

    // Put some elements
    d.put("1", "from java2s.com");
    d.put("2", "Cocoa");
    d.put("5", "Coffee");

    // print the size of the dictionary
    System.out.println("Size of dictionary:" + d.size());
    ;//from w ww . j  a v  a2s  .c  om
}

From source file:Main.java

public static void main(String[] args) {

    Dictionary d = new Hashtable();

    // add elements in the hashtable
    d.put("1", "from java2s.com");
    d.put("2", "Cocoa");
    d.put("5", "Coffee");

    // return true if this dictionary maps no keys to value.
    boolean b = d.isEmpty();
    System.out.println("Dictionary is empty:" + b);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JSlider slider = new JSlider();

    Dictionary table = slider.getLabelTable();

    ImageIcon icon = new ImageIcon("icon.gif");
    JLabel label = new JLabel(icon);

    // Set at desired positions
    table.put(new Integer(slider.getMinimum()), label);
    table.put(new Integer(slider.getMaximum()), label);

    // Force the slider to use the new labels
    slider.setLabelTable(table);//from   w w  w.  j  a  v  a  2s. c  o m

}

From source file:org.apache.stratos.redirector.servlet.ui.util.Util.java

public static void domainRegisterServlet(BundleContext bundleContext) throws Exception {
    if (!CarbonUtils.isRemoteRegistry()) {
        HttpServlet reirectorServlet = new HttpServlet() {
            // the redirector filter will forward the request before this servlet is hit
            protected void doGet(HttpServletRequest request, HttpServletResponse response)
                    throws ServletException, IOException {
            }/*from w w  w  .ja v  a 2s .  co m*/
        };

        Filter redirectorFilter = new AllPagesFilter();

        Dictionary redirectorServletAttributes = new Hashtable(2);
        Dictionary redirectorParams = new Hashtable(2);
        redirectorParams.put("url-pattern", "/" + MultitenantConstants.TENANT_AWARE_URL_PREFIX);
        redirectorParams.put("associated-filter", redirectorFilter);
        redirectorParams.put("servlet-attributes", redirectorServletAttributes);

        redirectorServiceRegistration = bundleContext.registerService(Servlet.class.getName(), reirectorServlet,
                redirectorParams);

    }
}

From source file:org.opencastproject.publication.youtube.YouTubeUtils.java

/**
 * Disciplined way of setting properties.
 *
 * @param dictionary may not be {@code null}
 * @param key  may not be {@code null}/*from  w w w  . j a  va 2  s  .  c  o  m*/
 * @param value may not be {@code null}
 */
static void put(final Dictionary dictionary, final YouTubeKey key, final Object value) {
    dictionary.put(keyPrefix + key.name(), value);
}