Example usage for java.util Hashtable put

List of usage examples for java.util Hashtable put

Introduction

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

Prototype

public synchronized V put(K key, V value) 

Source Link

Document

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

Usage

From source file:FontDerivation.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Create a 1-point font.
    Font font = new Font("Serif", Font.PLAIN, 1);
    float x = 20, y = 20;

    Font font24 = font.deriveFont(24.0f);
    g2.setFont(font24);/*from w ww. j  a va  2  s  .c  om*/
    g2.drawString("font.deriveFont(24.0f)", x, y += 30);

    Font font24italic = font24.deriveFont(Font.ITALIC);
    g2.setFont(font24italic);
    g2.drawString("font24.deriveFont(Font.ITALIC)", x, y += 30);

    AffineTransform at = new AffineTransform();
    at.shear(.2, 0);
    Font font24shear = font24.deriveFont(at);
    g2.setFont(font24shear);
    g2.drawString("font24.deriveFont(at)", x, y += 30);

    Hashtable attributes = new Hashtable();
    attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
    Font font24bold = font24.deriveFont(attributes);
    g2.setFont(font24bold);
    g2.drawString("font24.deriveFont(attributes)", x, y += 30);
}

From source file:com.dell.asm.asmcore.asmmanager.util.discovery.DeviceTypeCheckUtil.java

/**
 * Creates an SSH session to the given server on a custom TCP port
 * using the provided credentials.  This is equivalent to Expect's
 * <code>spawn ssh $hostname</code>.
 *
 * This method is essentially the same as ExpectUtils.SSH, but it
 * properly disconnects the ssh session. ExpectUtils.SSH is buggy
 * and leaves the ssh connection open. <b>Do not use ExpectUtils.SSH!</b>
 *
 * @param hostname the DNS or IP address of the remote server
 * @param username the account name to use when authenticating
 * @param password the account password to use when authenticating
 * @return the controlling Expect4j instance
 * @throws Exception on a variety of errors
 *///from   w  w w  .  jav a  2 s  .co  m
private static Expect4j ssh(String hostname, String username, String password) throws Exception {
    final int port = 22;
    LOGGER.debug("Creating SSH session with " + hostname + ":" + port + " as " + username);

    JSch jsch = new JSch();
    final Session session = jsch.getSession(username, hostname, port);
    if (password != null) {
        LOGGER.trace("Setting the Jsch password to the one provided (not shown)");
        session.setPassword(password);
    }

    Hashtable<String, String> config = new Hashtable<>();
    config.put("StrictHostKeyChecking", "no");
    session.setConfig(config);
    session.setDaemonThread(true);
    session.connect(3 * 1000); // making a connection with timeout.

    ChannelShell channel = (ChannelShell) session.openChannel("shell");
    channel.setPtyType("vt102");

    Expect4j expect = new Expect4j(channel.getInputStream(), channel.getOutputStream()) {
        @Override
        public void close() {
            super.close();
            session.disconnect();
        }
    };

    channel.connect(5 * 1000);

    return expect;
}

From source file:TestTree4.java

public TestTree4() {
    super("Custom Icon Example");
    setSize(350, 450);//from   w  ww . j a va 2s . c o  m
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    // Build the hierarchy of containers & objects
    String[] schoolyard = { "School", "Playground", "Parking Lot", "Field" };
    String[] mainstreet = { "Grocery", "Shoe Shop", "Five & Dime", "Post Office" };
    String[] highway = { "Gas Station", "Convenience Store" };
    String[] housing = { "Victorian_blue", "Faux Colonial", "Victorian_white" };
    String[] housing2 = { "Mission", "Ranch", "Condo" };
    Hashtable homeHash = new Hashtable();
    homeHash.put("Residential 1", housing);
    homeHash.put("Residential 2", housing2);

    Hashtable cityHash = new Hashtable();
    cityHash.put("School grounds", schoolyard);
    cityHash.put("Downtown", mainstreet);
    cityHash.put("Highway", highway);
    cityHash.put("Housing", homeHash);

    Hashtable worldHash = new Hashtable();
    worldHash.put("My First VRML World", cityHash);

    // Build our tree out of our big hashtable
    tree1 = new JTree(worldHash);
    tree2 = new JTree(worldHash);

    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree2.getCellRenderer();
    renderer.setClosedIcon(new ImageIcon("door.closed.gif"));
    renderer.setOpenIcon(new ImageIcon("door.open.gif"));
    renderer.setLeafIcon(new ImageIcon("world.gif"));

    JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tree1, tree2);

    getContentPane().add(pane, BorderLayout.CENTER);
}

From source file:eionet.gdem.dcm.conf.LdapTest.java

protected DirContext getDirContext() throws NamingException {
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    DirContext ctx = new InitialDirContext(env);
    return ctx;//ww  w .  ja  v a2  s . co  m
}

From source file:org.knowhowlab.osgi.monitoradmin.mocks.MonitorableMockServiceReference.java

public MonitorableMockServiceReference(String pid) {
    super(new String[] { Monitorable.class.getName() });
    Hashtable<String, String> props = new Hashtable<String, String>();
    props.put(Constants.SERVICE_PID, pid);
    setProperties(props);//from w  w  w  . j  a v a 2  s  .co m
}

From source file:org.knowhowlab.osgi.monitoradmin.mocks.MonitorableMockServiceReference.java

public MonitorableMockServiceReference(Bundle bundle, String pid) {
    super(bundle, new String[] { Monitorable.class.getName() });
    Hashtable<String, String> props = new Hashtable<String, String>();
    props.put(Constants.SERVICE_PID, pid);
    setProperties(props);/*from  w w w  . java 2  s. c  o m*/
}

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

@Test
public void array2() throws Exception {
    Hashtable<String, Object> ht = new Hashtable<>();
    ht.put("a[0][0]", "dog");
    JsonNode roundTrip = JsonNodeFlattener.unflatten(ht);
    JsonNode ref = new ObjectMapper(new YAMLFactory()).readTree("a: [ [ dog ] ]");
    assertEquals(ref, roundTrip);/*from   ww  w .  ja va  2s .c  o m*/
}

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

@Test
public void objectInArray() throws Exception {
    Hashtable<String, Object> ht = new Hashtable<>();
    ht.put("a[0].cat", "dog");
    ht.put("a[0].dog", "cat");
    JsonNode roundTrip = JsonNodeFlattener.unflatten(ht);
    JsonNode ref = new ObjectMapper(new YAMLFactory()).readTree("a: [ { cat: dog, dog: cat } ]");
    assertEquals(ref, roundTrip);/* w w  w  .  jav  a  2  s.c  o  m*/
}

From source file:com.jaspersoft.jasperserver.api.security.externalAuth.ldap.JSLdapContextSource.java

public DirContext getReadWriteContext(String userDn, Object credentials) {
    Hashtable env = new Hashtable(getAnonymousEnv());

    env.put(Context.SECURITY_PRINCIPAL, userDn);
    env.put(Context.SECURITY_CREDENTIALS, credentials);
    env.remove(SUN_LDAP_POOLING_FLAG);/*  w  ww  .  j  a  v a  2s .  c om*/

    if (logger.isDebugEnabled()) {
        logger.debug("Creating context with principal: '" + userDn + "'");
    }

    return createContext(env);
}

From source file:gov.nih.nci.cabig.caaers.tools.JMXBeansRegistrar.java

/**
 * @return//from w w w .ja v  a 2 s. c  om
 * @throws MalformedObjectNameException
 * @throws NullPointerException
 */
private ObjectName prepareObjectName(SessionFactory sessionFactory)
        throws MalformedObjectNameException, NullPointerException {
    Hashtable tb = new Hashtable();
    tb.put("type", "statistics");
    tb.put("sessionFactory", "Session Factory #" + sessionFactories.indexOf(sessionFactory));
    ObjectName on = new ObjectName("hibernate", tb); // MBean object
    // name
    return on;
}