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:com.MainChart.java

public MainChart(String applicationTitle, String chartTitle) throws IOException {
    super(applicationTitle);
    this.multiHashtable = new Hashtable<>();
    // This will create the dataset 
    // PieDataset dataset = createDataset();
    // based on the dataset we create the chart
    final JFreeChart chart = ChartFactory.createBarChart("GPA Analysis By Country", // chart title
            "Country", // domain axis label
            "GPA", // range axis label
            createDataset(), // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );//from   w  w  w. jav  a  2s .c  om

    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setBackgroundPaint(SystemColor.inactiveCaption);//change background color

    //set  bar chart color

    //CategoryItemRenderer renderer = new CustomRenderer(); 
    //plot.setRenderer(renderer);
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    // add it to our application
    setContentPane(chartPanel);

}

From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.CursorCollectionDefault.java

public CursorCollectionDefault() {
    super();

    controls = new Hashtable<Integer, Control>();
}

From source file:com.nokia.helium.jpa.ORMEntityManager.java

/**  
 * Constructor./* w ww  .  j av  a 2s.co  m*/
 * @param urlPath path for which entity manager to be
 * created.
 */
@SuppressWarnings("unchecked")
public ORMEntityManager(String urlPath) throws Exception {
    String name = "metadata";
    Hashtable persistProperties = new Hashtable();
    persistProperties.put("javax.persistence.jdbc.driver", "org.apache.derby.jdbc.EmbeddedDriver");
    persistProperties.put("javax.persistence.jdbc.url", "jdbc:derby:" + urlPath);
    persistProperties.put(PersistenceUnitProperties.PERSISTENCE_CONTEXT_CLOSE_ON_COMMIT, "false");
    persistProperties.put(PersistenceUnitProperties.PERSISTENCE_CONTEXT_REFERENCE_MODE, "WEAK");
    persistProperties.put(PersistenceUnitProperties.BATCH_WRITING, "JDBC");
    persistProperties.put("eclipselink.read-only", "true");
    persistProperties.put(PersistenceUnitProperties.LOGGING_LEVEL, "warning");
    File dbFile = new File(urlPath);
    commitCountObject = new ORMCommitCount();
    if (dbFile.exists()) {
        try {
            log.debug("checking db integrity for :" + urlPath);
            if (!checkDatabaseIntegrity(urlPath)) {
                log.debug("db integrity failed cleaning up old db");
                try {
                    log.debug("deleting the url path" + urlPath);
                    FileUtils.forceDelete(dbFile);
                    log.debug("successfully removed the urlpath" + urlPath);
                } catch (java.io.IOException iex) {
                    log.debug("deleting the db directory failed", iex);
                    throw new BuildException("failed deleting corrupted db", iex);
                }
            } else {
                log.debug("db exists and trying to create entity manager");
                EntityManagerFactory factory = Persistence.createEntityManagerFactory(name, persistProperties);
                entityManager = factory.createEntityManager();
                entityManager.getTransaction().begin();
                return;
            }
        } catch (Exception ex) {
            log.debug("Failed to open the database, might be corrupted, creating new db", ex);
            try {
                FileUtils.deleteDirectory(dbFile);
            } catch (java.io.IOException iex) {
                log.debug("deleting the db directory failed");
                throw iex;
            }
        }
    }
    log.debug("url path not exists" + urlPath + "creating it");
    persistProperties.put("javax.persistence.jdbc.url", "jdbc:derby:" + urlPath + ";create=true");
    persistProperties.put(PersistenceUnitProperties.DDL_GENERATION, "create-tables");
    persistProperties.put(PersistenceUnitProperties.DDL_GENERATION_MODE, "database");
    persistProperties.put(PersistenceUnitProperties.PERSISTENCE_CONTEXT_CLOSE_ON_COMMIT, "false");
    persistProperties.put(PersistenceUnitProperties.PERSISTENCE_CONTEXT_REFERENCE_MODE, "WEAK");
    persistProperties.put(PersistenceUnitProperties.BATCH_WRITING, "JDBC");
    persistProperties.put("eclipselink.read-only", "true");
    EntityManagerFactory factory = Persistence.createEntityManagerFactory(name, persistProperties);
    entityManager = factory.createEntityManager();
    entityManager.getTransaction().begin();
    entityManager.persist(new Version());
    entityManager.getTransaction().commit();
    entityManager.clear();
    entityManager.getTransaction().begin();
}

From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.WindowManagerCalibratorDefault.java

public WindowManagerCalibratorDefault() {
    controls = new Hashtable<Position, Hashtable<String, TexturedControl>>();
}

From source file:com.clican.pluto.cms.ui.listener.StartupListener.java

public void contextInitialized(ServletContextEvent event) {
    super.contextInitialized(event);
    try {/* w w  w. j ava  2 s .  c om*/
        Velocity.init(
                Thread.currentThread().getContextClassLoader().getResource("velocity.properties").getPath());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    ApplicationContext ctx = null;
    JndiUtils.setJndiFactory(MockContextFactory.class.getName());
    Hashtable<String, String> ht = new Hashtable<String, String>();
    ht.put(Context.INITIAL_CONTEXT_FACTORY, MockContextFactory.class.getName());
    try {
        ctx = (ApplicationContext) JndiUtils.lookupObject(ApplicationContext.class.getName());
        if (ctx == null) {
            log.warn("Cannot get ApplicationContext from JNDI");
        }
    } catch (Exception e) {
        log.warn("Cannot get ApplicationContext from JNDI");
    }
    if (ctx == null) {
        ctx = (new ClassPathXmlApplicationContext(new String[] { "classpath*:META-INF/ui-*.xml", }));
    }
    XmlWebApplicationContext wac = (XmlWebApplicationContext) WebApplicationContextUtils
            .getRequiredWebApplicationContext(event.getServletContext());
    wac.setParent(ctx);
    wac.refresh();
    event.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    Constants.ctx = wac;
}

From source file:com.alfaariss.oa.engine.user.provisioning.storage.StorageManager.java

/**
 * Creates the object.//  w ww .  j av  a2 s . c o  m
 */
public StorageManager() {
    _logger = LogFactory.getLog(StorageManager.class);
    _htStorages = new Hashtable<String, IStorage>();
}

From source file:com.adobe.acs.commons.http.headers.impl.WeeklyExpiresHeaderFilterTest.java

@Before
public void setup() throws Exception {
    properties = new Hashtable<String, Object>();
    properties.put(WeeklyExpiresHeaderFilter.PROP_EXPIRES_TIME, "02:30");

    when(componentContext.getProperties()).thenReturn(properties);
    when(componentContext.getBundleContext()).thenReturn(bundleContext);

}

From source file:EmailTree.java

public void init() {
    Hashtable h = new Hashtable();
    Hashtable paul = new Hashtable();
    paul.put("Work", addresses[0]);
    paul.put("Home", addresses[1]);
    Hashtable damian = new Hashtable();
    damian.put("Work", addresses[2]);
    damian.put("Pager", addresses[3]);
    damian.put("Home", addresses[4]);
    Hashtable angela = new Hashtable();
    angela.put("Home", addresses[5]);
    h.put("Paul", paul);
    h.put("Damian", damian);
    h.put("Angela", angela);
    tree = new JTree(h);

    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
    renderer.setOpenIcon(new ImageIcon("mailboxdown.gif"));
    renderer.setClosedIcon(new ImageIcon("mailboxup.gif"));
    renderer.setLeafIcon(new ImageIcon("letter.gif"));
    EmailTreeCellEditor emailEditor = new EmailTreeCellEditor();
    DefaultTreeCellEditor editor = new DefaultTreeCellEditor(tree, renderer, emailEditor);
    tree.setCellEditor(editor);/*from w  w  w.  j  av  a  2 s .com*/
    tree.setEditable(true);

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

From source file:com.clican.pluto.common.util.JndiUtils.java

/**
 * Bind the resource manager instance to the JNDI directory.
 * <p>/*from  w ww .ja v a2s. c om*/
 * This method will use the full JNDI path provided for the resource
 * manager, and will create if necessary the individual segments of that
 * path.
 * 
 * @param jndiName
 *            The full JNDI path at which the resource manager instance will
 *            be bound in the JNDI directory. JNDI clients can use that path
 *            to obtain the resource manager instance.
 * @param obj
 *            The object to be bound.
 * @return <b>true</b> if the resource manager was successfully bound to
 *         JNDI using the provided path; otherwise <b>false</b>.
 * 
 * @see #unbind(String)
 */
public static boolean bind(String jndiName, Object obj) {
    if (log.isDebugEnabled()) {
        log.debug("Binding object [" + obj + "] in JNDI at path [" + jndiName + "].");
    }
    Context ctx = null;

    try {
        // Create a binding that is local to this host only.
        Hashtable<String, String> ht = new Hashtable<String, String>();
        // If a special JNDI initial context factory was specified in the
        // constructor, then use it.
        if (jndiInitialContextFactory != null) {
            ht.put(Context.INITIAL_CONTEXT_FACTORY, jndiInitialContextFactory);
        }
        // Turn off binding replication .
        // ht.put(WLContext.REPLICATE_BINDINGS, "false");
        ctx = new InitialContext(ht);

        String[] arrJndiNames = jndiName.split("/");
        String subContext = "";

        for (int i = 0; i < arrJndiNames.length - 1; i++) {
            subContext = subContext + "/" + arrJndiNames[i];
            try {
                ctx.lookup(subContext);
            } catch (NameNotFoundException e) {
                ctx.createSubcontext(subContext);
            }

        }

        if (obj instanceof Serializable || jndiInitialContextFactory != null) {
            ctx.bind(jndiName, obj);
        } else {
            NonSerializableFactory.bind(jndiName, obj);
        }
    } catch (NamingException ex) {
        log.error("An error occured while binding [" + jndiName + "] to JNDI:", ex);
        return false;
    } finally {
        if (ctx != null) {
            try {
                ctx.close();
            } catch (NamingException ne) {
                log.error("Close context error:", ne);
            }
        }
    }
    return true;
}

From source file:edu.caltechUcla.sselCassel.projects.jMarkets.shared.interfaces.PriceChart.java

/** Creates a new instance of PriceChart */
public PriceChart() {
    lines = new Hashtable();
}