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

Hashtable(Void dummy) 

Source Link

Document

A constructor chained from Properties keeps Hashtable fields uninitialized since they are not used.

Usage

From source file:com.meikai.common.web.servlet.FCKeditorUploadServlet.java

/**
 * Initialize the servlet.<br>/*from w w  w .  jav a2s  . c  o m*/
 * Retrieve from the servlet configuration the "baseDir" which is the root of the file repository:<br>
 * If not specified the value of "/UserFiles/" will be used.<br>
 * Also it retrieve all allowed and denied extensions to be handled.
 *
 */
public void init() throws ServletException {

    debug = (new Boolean(getInitParameter("debug"))).booleanValue();

    baseDir = getInitParameter("baseDir");
    enabled = (new Boolean(getInitParameter("enabled"))).booleanValue();
    if (baseDir == null)
        baseDir = "/UserFiles/";
    String realBaseDir = getServletContext().getRealPath(baseDir);
    File baseFile = new File(realBaseDir);
    if (!baseFile.exists()) {
        baseFile.mkdir();
    }

    allowedExtensions = new Hashtable(3);
    deniedExtensions = new Hashtable(3);

    allowedExtensions.put("File", FckeditorUtil.stringToArrayList(getInitParameter("AllowedExtensionsFile")));
    deniedExtensions.put("File", FckeditorUtil.stringToArrayList(getInitParameter("DeniedExtensionsFile")));

    allowedExtensions.put("Image", FckeditorUtil.stringToArrayList(getInitParameter("AllowedExtensionsImage")));
    deniedExtensions.put("Image", FckeditorUtil.stringToArrayList(getInitParameter("DeniedExtensionsImage")));

    allowedExtensions.put("Flash", FckeditorUtil.stringToArrayList(getInitParameter("AllowedExtensionsFlash")));
    deniedExtensions.put("Flash", FckeditorUtil.stringToArrayList(getInitParameter("DeniedExtensionsFlash")));

}

From source file:com.fredck.FCKeditor.uploader.SimpleUploaderServlet.java

/**
 * Initialize the servlet.<br>//  w  ww  . j  a va 2 s .  c o  m
 * Retrieve from the servlet configuration the "baseDir" which is the root
 * of the file repository:<br>
 * If not specified the value of "/UserFiles/" will be used.<br>
 * Also it retrieve all allowed and denied extensions to be handled.
 * 
 */
public void init() throws ServletException {
    debug = (new Boolean(getInitParameter("debug"))).booleanValue();
    if (debug) {
        System.out.println("\r\n---- SimpleUploaderServlet initialization started ----");
    }
    baseDir = getInitParameter("baseDir");
    enabled = (new Boolean(getInitParameter("enabled"))).booleanValue();
    if (baseDir == null) {
        baseDir = "/UserFiles/";
    }
    String realBaseDir = getServletContext().getRealPath(baseDir);
    File baseFile = new File(realBaseDir);
    if (!baseFile.exists()) {
        baseFile.mkdir();
    }
    allowedExtensions = new Hashtable(3);
    deniedExtensions = new Hashtable(3);
    allowedExtensions.put("File", stringToArrayList(getInitParameter("AllowedExtensionsFile")));
    deniedExtensions.put("File", stringToArrayList(getInitParameter("DeniedExtensionsFile")));
    allowedExtensions.put("Image", stringToArrayList(getInitParameter("AllowedExtensionsImage")));
    deniedExtensions.put("Image", stringToArrayList(getInitParameter("DeniedExtensionsImage")));
    allowedExtensions.put("Flash", stringToArrayList(getInitParameter("AllowedExtensionsFlash")));
    deniedExtensions.put("Flash", stringToArrayList(getInitParameter("DeniedExtensionsFlash")));
    if (debug) {
        System.out.println("---- SimpleUploaderServlet initialization completed ----\r\n");
    }
}

From source file:Main.java

public Main() {
    setSize(500, 340);/*from  w w w  .  ja  v  a 2 s  .  c  o m*/

    Date currentDate = new Date();
    calendar.setTime(currentDate);

    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(4, 1));

    JPanel p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Selected Date"));
    dateLabel = new JLabel(dateFormat.format(currentDate) + "     ");
    dateLabel.setFont(new Font("Arial", Font.BOLD, 24));
    p.add(dateLabel);
    p1.add(p);

    yearSlider.setPaintLabels(true);
    yearSlider.setMajorTickSpacing(5);
    yearSlider.setMinorTickSpacing(1);
    yearSlider.setPaintTicks(true);
    DateListener lst = new DateListener();
    yearSlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Year"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(yearSlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

    String[] months = (new DateFormatSymbols()).getShortMonths();
    hashTable = new Hashtable(12);
    for (int i = 0; i < 12; i++)
        hashTable.put(new Integer(i + 1), new JLabel(months[i], JLabel.CENTER));
    monthSlider.setLabelTable(hashTable);
    monthSlider.setPaintLabels(true);
    monthSlider.setMajorTickSpacing(1);
    monthSlider.setPaintTicks(true);
    monthSlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Month"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(monthSlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

    int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    daySlider = new JSlider(JSlider.HORIZONTAL, 1, maxDays, calendar.get(Calendar.DAY_OF_MONTH));
    daySlider.setPaintLabels(true);
    daySlider.setMajorTickSpacing(5);
    daySlider.setMinorTickSpacing(1);
    daySlider.setPaintTicks(true);
    daySlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Day"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(daySlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

    getContentPane().add(p1, BorderLayout.CENTER);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    enableEvents(ComponentEvent.COMPONENT_RESIZED);
    setVisible(true);
}

From source file:vn.com.vndirect.api.service.SpringAMQP.java

@SuppressWarnings({ "unchecked", "rawtypes" })
protected Context createJndiContext() throws Exception {
    Properties properties = new Properties();

    // jndi.properties is optional
    InputStream in = getClass().getClassLoader().getResourceAsStream("jndi.properties");
    if (in != null) {
        properties.load(in);/*  ww  w  .ja  v  a  2 s.com*/
    } else {
        properties.put("java.naming.factory.initial", "org.apache.camel.util.jndi.CamelInitialContextFactory");
    }
    return new InitialContext(new Hashtable(properties));
}

From source file:com.useeasy.auction.util.upload.SimpleUploaderServlet.java

/**
 * Initialize the servlet.<br>//from   www .  j  a v a 2s  .  c  o  m
 * Retrieve from the servlet configuration the "baseDir" which is the root
 * of the file repository:<br>
 * If not specified the value of "/UserFiles/" will be used.<br>
 * Also it retrieve all allowed and denied extensions to be handled.
 * 
 */
public void init() throws ServletException {

    debug = (new Boolean(getInitParameter("debug"))).booleanValue();

    if (debug)
        System.out.println("\r\n---- SimpleUploaderServlet initialization started ----");

    baseDir = getInitParameter("baseDir");
    enabled = (new Boolean(getInitParameter("enabled"))).booleanValue();
    if (baseDir == null)
        baseDir = "/UserFiles/";
    String realBaseDir = getServletContext().getRealPath(baseDir);
    File baseFile = new File(realBaseDir);
    if (!baseFile.exists()) {
        baseFile.mkdir();
    }

    allowedExtensions = new Hashtable(3);
    deniedExtensions = new Hashtable(3);

    allowedExtensions.put("File", stringToArrayList(getInitParameter("AllowedExtensionsFile")));
    deniedExtensions.put("File", stringToArrayList(getInitParameter("DeniedExtensionsFile")));

    allowedExtensions.put("Image", stringToArrayList(getInitParameter("AllowedExtensionsImage")));
    deniedExtensions.put("Image", stringToArrayList(getInitParameter("DeniedExtensionsImage")));

    allowedExtensions.put("Flash", stringToArrayList(getInitParameter("AllowedExtensionsFlash")));
    deniedExtensions.put("Flash", stringToArrayList(getInitParameter("DeniedExtensionsFlash")));

    if (debug)
        System.out.println("---- SimpleUploaderServlet initialization completed ----\r\n");

}

From source file:crds.pub.FCKeditor.uploader.SimpleUploaderServlet.java

/**
 * Initialize the servlet.<br>/*from w  ww.j a v  a  2  s  .c  o m*/
 * Retrieve from the servlet configuration the "baseDir" which is the root of the file repository:<br>
 * If not specified the value of "/UserFiles/" will be used.<br>
 * Also it retrieve all allowed and denied extensions to be handled.
 *
 */
public void init() throws ServletException {

    debug = (new Boolean(getInitParameter("debug"))).booleanValue();

    baseDir = getInitParameter("baseDir");
    enabled = (new Boolean(getInitParameter("enabled"))).booleanValue();
    if (baseDir == null)
        baseDir = "/UserFiles/";
    String realBaseDir = getServletContext().getRealPath(baseDir);
    File baseFile = new File(realBaseDir);
    if (!baseFile.exists()) {
        baseFile.mkdir();
    }

    allowedExtensions = new Hashtable(3);
    deniedExtensions = new Hashtable(3);

    allowedExtensions.put("File", stringToArrayList(getInitParameter("AllowedExtensionsFile")));
    deniedExtensions.put("File", stringToArrayList(getInitParameter("DeniedExtensionsFile")));

    allowedExtensions.put("Image", stringToArrayList(getInitParameter("AllowedExtensionsImage")));
    deniedExtensions.put("Image", stringToArrayList(getInitParameter("DeniedExtensionsImage")));

    allowedExtensions.put("Flash", stringToArrayList(getInitParameter("AllowedExtensionsFlash")));
    deniedExtensions.put("Flash", stringToArrayList(getInitParameter("DeniedExtensionsFlash")));

}

From source file:info.magnolia.cms.gui.fckeditor.FCKEditorSimpleUploadServlet.java

/**
 * Initialize the servlet.<br>//from w ww  .  java 2 s  . c  o  m
 * Retrieve from the servlet configuration the "baseDir" which is the root of the file repository:<br>
 * If not specified the value of "/UserFiles/" will be used.<br>
 * Also it retrieve all allowed and denied extensions to be handled.
 */
public void init() throws ServletException {
    allowedExtensions = new Hashtable(3);
    deniedExtensions = new Hashtable(3);

    allowedExtensions.put("file", stringToArrayList(getInitParameter("AllowedExtensionsFile")));
    deniedExtensions.put("file", stringToArrayList(getInitParameter("DeniedExtensionsFile")));

    allowedExtensions.put("image", stringToArrayList(getInitParameter("AllowedExtensionsImage")));
    deniedExtensions.put("image", stringToArrayList(getInitParameter("DeniedExtensionsImage")));

    allowedExtensions.put("flash", stringToArrayList(getInitParameter("AllowedExtensionsFlash")));
    deniedExtensions.put("flash", stringToArrayList(getInitParameter("DeniedExtensionsFlash")));
}

From source file:net.dstc.mkts.data.jpa.JpaSurveyDAO.java

private Query buildQuery(SurveyDO query) {
    String queryString = "FROM survey s";
    String whereClause = StringUtils.EMPTY;
    Map<String, Object> parameters = new Hashtable<>(20);

    if (query != null) {
        String title = query.getTitle();
        SurveyStatus status = query.getStatus();
        Date startDate = query.getStartDate();
        SurveyTargetDO target = query.getTarget();
        if (!StringUtils.isBlank(title)) {
            whereClause = "title=:title";
            parameters.put("title", title);
        }//w ww  . j ava  2s.c  om

        if (status != null) {
            whereClause += !StringUtils.isEmpty(whereClause) ? " AND " : StringUtils.EMPTY;
            whereClause += "status=:status";
            parameters.put("status", status);
        }

        if (startDate != null) {
            whereClause += !StringUtils.isEmpty(whereClause) ? " AND " : StringUtils.EMPTY;
            whereClause += "startDate=:startDate";
            parameters.put("startDate", startDate);
        }

        if (target != null) {
            int minAge = target.getMinAge();
            int maxAge = target.getMaxAge();
            int minIncome = target.getMinIncome();
            int maxIncome = target.getMaxIncome();
            String gender = target.getGender();
            String country = target.getCountry();

            if (minAge > 0) {
                whereClause += !StringUtils.isEmpty(whereClause) ? " AND " : StringUtils.EMPTY;
                whereClause += "target.minAge=:minAge";
                parameters.put("target.minAge", minAge);
            }

            if (maxAge > 0) {
                whereClause += !StringUtils.isEmpty(whereClause) ? " AND " : StringUtils.EMPTY;
                whereClause += "target.maxAge=:maxAge";
                parameters.put("target.maxAge", maxAge);
            }

            if (minIncome > 0) {
                whereClause += !StringUtils.isEmpty(whereClause) ? " AND " : StringUtils.EMPTY;
                whereClause += "target.minIncome=:minIncome";
                parameters.put("target.minIncome", minIncome);
            }

            if (maxIncome > 0) {
                whereClause += !StringUtils.isEmpty(whereClause) ? " AND " : StringUtils.EMPTY;
                whereClause += "target.maxIncome=:maxIncome";
                parameters.put("target.maxIncome", maxIncome);
            }

            if (!StringUtils.isBlank(gender)) {
                whereClause += !StringUtils.isEmpty(whereClause) ? " AND " : StringUtils.EMPTY;
                whereClause += "target.gender=:gender";
                parameters.put("gender", gender);
            }

            if (!StringUtils.isBlank(country)) {
                whereClause += !StringUtils.isEmpty(whereClause) ? " AND " : StringUtils.EMPTY;
                whereClause += "target.country=:country";
                parameters.put("target.country", country);
            }
        }

        if (!StringUtils.isEmpty(whereClause)) {
            queryString += " WHERE " + whereClause;
        }
    }

    Query jpaQuery = entityManager.createQuery(queryString);

    parameters.forEach((String parmName, Object parmValue) -> {
        jpaQuery.setParameter(parmName, parmValue);
    });

    return jpaQuery;
}

From source file:sim.app.sugarscape.util.ResultsGrapher.java

public ResultsGrapher(String resultsfile, String config, String sweep) {
    //System.out.println("starting...");
    output_params_map = new Hashtable(10);
    loadConfigFile(config);//  w  w  w  .  ja v  a  2 s  .  co  m
    this.resultsfile = resultsfile;
    raw = new ArrayList(200);
    ArrayList xp = new ArrayList(10); //number of lines/series
    try {
        File f = new File(resultsfile);
        FileReader fr = new FileReader(f);
        BufferedReader br = new BufferedReader(fr);
        String line = br.readLine();
        String var = null;

        //get the field names
        ArrayList a = new ArrayList(10);
        StringTokenizer st0 = new StringTokenizer(line, ",");
        while (st0.hasMoreTokens()) {
            a.add(st0.nextToken());
        }
        int size = a.size();
        fields = new String[size];

        for (int b = 0; b < size; b++) {
            fields[b] = (String) a.get(b);
            if (fields[b].compareToIgnoreCase(x_axis_fieldname) == 0) {
                x_axis_index = b;
            } else if (fields[b].compareToIgnoreCase(y_axis_fieldname) == 0) {
                y_axis_index = b;
            } else if (fields[b].compareToIgnoreCase(x_param_fieldname) == 0) {
                x_param_index = b;
            } else if (fields[b].compareToIgnoreCase("time") == 0) {
                time_index = b;
            } else if (fields[b].compareToIgnoreCase("run") == 0) {
                run_index = b;
                //System.out.println(run_index + " = run_index");
            } //else if (fields[b].)
        }
        if ((x_axis_index == -1) || (y_axis_index == -1)) {
            System.err.println("Missing an axis variable as specified in " + config);
            System.exit(1);
        }

        int counter = 0;
        float val;
        long time_val;
        int run_val = 0;
        int line_number = -1;
        Double x_axis_val = null;
        Double y_axis_val = null;

        Hashtable h = new Hashtable(100);
        ArrayList params = new ArrayList(100);
        timezero = new DuplicatesHashtable(100, 100);
        nonzero = new DuplicatesHashtable(100, 100);
        while ((line = br.readLine()) != null) {
            line_number++;
            if (line.startsWith("run")) {
                continue;
            }
            //raw.add(line);
            counter = 0;
            time_val = -1;
            run_val = -1;
            StringTokenizer st = new StringTokenizer(line, ",");
            while (st.hasMoreTokens()) {
                var = st.nextToken();
                val = Float.parseFloat(var);
                if (counter == time_index) {
                    time_val = Math.round(Double.parseDouble(var));
                } else if (counter == run_index) {
                    run_val = Math.round(Float.parseFloat(var));
                } else if (counter == y_axis_index) {
                    y_axis_val = Double.valueOf(var);
                } else if (counter == x_axis_index) {
                    x_axis_val = Double.valueOf(var);
                }
                counter++;

            }
            if (time_val != 0) {
                nonzero.put(new Integer(run_val), y_axis_val);
            } else {
                timezero.put(new Integer(run_val), x_axis_val);
            }
            //System.out.println(line);
        }

        System.out.println("Finished loading results file.");
        //System.out.println("x_param_fieldname = " + x_param_fieldname);
        //System.out.println("x_axis_fieldname = " + x_axis_fieldname);
        //System.out.println("y_axis_fieldname = " + y_axis_fieldname);
        loadSweepFile(sweep);
        int sweep_map = -1;
        int sweep_map_xaxis = -1;
        int sweep_map_yaxis = -1;

        for (int d = 0; d < sweep_vars.size(); d++) {
            //System.out.print( ((String)sweep_vars.get(d))+ " ");
            if (((String) sweep_vars.get(d)).compareToIgnoreCase(x_param_fieldname) == 0) {
                sweep_map = d;
            } else if (((String) sweep_vars.get(d)).compareToIgnoreCase(x_axis_fieldname) == 0) {
                sweep_map_xaxis = d;
            } else if (((String) sweep_vars.get(d)).compareToIgnoreCase(y_axis_fieldname) == 0) {
                sweep_map_yaxis = d;
            }
        }

        //Identify the runs for each level of sweep_var
        int[] sweeps = buildSeries(sweep_map);
        int[] uniq_vals = getUniqueIntVals(sweeps);
        int[][] series = new int[uniq_vals.length][sweeps.length / uniq_vals.length];
        //System.out.println("+++"+uniq_vals.length);
        int counter2 = 0;
        for (int d = 0; d < series.length; d++) {
            for (int e = 0; e < sweeps.length / uniq_vals.length; e++) {
                //series[d][e] = ((int[])sweep_vals.get(counter2))[sweep_map_xaxis];
                //System.out.print(series[d][e] + " ");
                //counter2++;
            }
            //System.out.println();
        }
        counter2 = 0;
        ArrayList[] sweep_xprecise = new ArrayList[uniq_vals.length];
        //new ArrayList(sweep_vals.size());
        for (int k = 0; k < series.length; k++) {
            sweep_xprecise[k] = new ArrayList(10);
            for (int g = 0; g < sweeps.length / uniq_vals.length; g++) {
                sweep_xprecise[k].add(sweep_vals.get(counter2));
                counter2++;
            }
        }
        FastQSortAlgorithm fast = new FastQSortAlgorithm();
        DualDoubleArrayFastQSort dual = new DualDoubleArrayFastQSort();

        double[][] sweep_x = new double[series.length][sweeps.length / uniq_vals.length];
        double[][] sweep_y = new double[series.length][sweeps.length / uniq_vals.length];
        for (int j = 0; j < series.length; j++) {
            fast.sort(series[j], sweep_xprecise[j]);

            for (int i = 0; i < sweep_xprecise[j].size(); i++) {

                Integer run = new Integer(((int[]) sweep_xprecise[j].get(i))[run_index]);

                ArrayList run_y = nonzero.get(run);
                ArrayList run_x = timezero.get(run);

                int sz = run_y.size();
                double total_y = 0d;
                double total_x = 0d;
                for (int m = 0; m < sz; m++) {
                    total_y = total_y + ((Double) run_y.get(m)).doubleValue();
                    total_x = total_x + ((Double) run_x.get(m)).doubleValue();
                }
                double y_avg = total_y / sz;
                double x_avg = total_x / sz;

                sweep_y[j][i] = y_avg;
                sweep_x[j][i] = x_avg;
            }
            dual.sort(sweep_x[j], sweep_y[j]);
            //System.out.println();
        }
        //now build the graphical series
        String label = x_param_fieldname + "=";
        XYSeries[] all_xyseries = new XYSeries[series.length];

        for (int n = 0; n < series.length; n++) {
            XYSeries xys = new XYSeries("");
            if (PARAMETERIZED_AVERAGES) {
                xys.setDescription(label + (n + 1));
                //xys.setName(label+(n+1));
            } else {
                xys.setDescription(label + uniq_vals[n]);
                //xys.setName(label+uniq_vals[n]);
            }

            for (int o = 0; o < sweep_x[n].length; o++) {
                xys.add(sweep_x[n][o], sweep_y[n][o]);
                //System.out.println(first_letter+uniq_vals[n] + " " + sweep_x[n][o] + " " + sweep_y[n][o]);
            }
            all_xyseries[n] = xys;
            //System.out.println(xys.getName());
        }
        buildGraphics(all_xyseries);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:com.meikai.common.web.servlet.FCKeditorConnectorServlet.java

/**
 * Initialize the servlet.<br>/*  ww  w  . j a  v a 2  s.  co  m*/
 * Retrieve from the servlet configuration the "baseDir" which is the root
 * of the file repository:<br>
 * If not specified the value of "/UserFiles/" will be used.
 * 
 */
public void init() throws ServletException {
    baseDir = getInitParameter("baseDir");
    debug = (new Boolean(getInitParameter("debug"))).booleanValue();
    if (baseDir == null)
        baseDir = "/UserFiles/";
    String realBaseDir = getServletContext().getRealPath(baseDir);
    File baseFile = new File(realBaseDir);
    if (!baseFile.exists()) {
        baseFile.mkdir();
    }

    allowedExtensions = new Hashtable(3);
    deniedExtensions = new Hashtable(3);

    allowedExtensions.put("File", FckeditorUtil.stringToArrayList(getInitParameter("AllowedExtensionsFile")));
    deniedExtensions.put("File", FckeditorUtil.stringToArrayList(getInitParameter("DeniedExtensionsFile")));

    allowedExtensions.put("Image", FckeditorUtil.stringToArrayList(getInitParameter("AllowedExtensionsImage")));
    deniedExtensions.put("Image", FckeditorUtil.stringToArrayList(getInitParameter("DeniedExtensionsImage")));

    allowedExtensions.put("Flash", FckeditorUtil.stringToArrayList(getInitParameter("AllowedExtensionsFlash")));
    deniedExtensions.put("Flash", FckeditorUtil.stringToArrayList(getInitParameter("DeniedExtensionsFlash")));

    try {
        SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd");
        dateCreated = simpledateformat.format(new Date());
    } catch (Exception ex) {
        logger.error("? : " + ex.getMessage());
    }
}