Example usage for java.util Hashtable get

List of usage examples for java.util Hashtable get

Introduction

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

Prototype

@SuppressWarnings("unchecked")
public synchronized V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:org.hdiv.web.validator.AbstractEditableParameterValidator.java

@SuppressWarnings("unchecked")
protected void validateEditableParameter(String param, Errors errors) {

    RequestAttributes attr = RequestContextHolder.getRequestAttributes();
    if (attr == null) {
        // This is not a web request
        return;/*from w  w  w .  j a v a2s .c om*/
    }

    Hashtable<String, String[]> parameters = (Hashtable<String, String[]>) attr
            .getAttribute(Constants.EDITABLE_PARAMETER_ERROR, 0);
    if (parameters != null && parameters.size() > 0) {

        String[] unauthorizedValues = parameters.get(param);
        if (unauthorizedValues != null && unauthorizedValues.length > 0) {

            this.rejectParamValues(param, unauthorizedValues, errors);
        }
    }
}

From source file:jasmine.imaging.core.util.Histogram.java

public Histogram(Hashtable<Integer, Integer> count) {

    super("Histogram");

    DefaultCategoryDataset series = new DefaultCategoryDataset();

    StatisticsSolver solver = new StatisticsSolver(1000);

    for (int i = 0; i < 256; i++) {
        Integer value = count.get(i);
        if (value == null)
            value = 1;//from  w w  w  . jav a2s.  c  o  m
        for (int j = 0; j < value; j++) {
            solver.addData(i);
        }
        series.addValue(value, "row1", String.valueOf(i));
    }

    setTitle("Histogram: v=" + solver.getStandardDeviation());

    chart = new JLabel();
    getContentPane().add(chart);

    setSize(320, 240);
    setVisible(true);

    myChart = ChartFactory.createLineChart(null, null, null, series, PlotOrientation.VERTICAL, false, false,
            false);

    //updateChart();

    addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
            if (myChart != null)
                updateChart();
        }
    });

}

From source file:net.sourceforge.floggy.persistence.fr2852335.perclass.FR2852335MigrationTest.java

/**
 * DOCUMENT ME!/*from  www . ja v  a2 s . com*/
*
* @throws Exception DOCUMENT ME!
*/
public void testMigrationConcreteSubClassOfConcreteSuperClass() throws Exception {
    MigrationManager mm = MigrationManager.getInstance();
    Enumeration enumeration = mm.start(CSCOfConcreteSuperClass.class, null);

    assertEquals(PerClassStrategyEnumerationImpl.class, enumeration.getClass());

    try {
        while (enumeration.hasMoreElements()) {
            Hashtable fields = enumeration.nextElement();
            assertEquals(classification, ((Character) fields.get("classification")).charValue());
            assertEquals(name, fields.get("name"));
        }
    } finally {
        mm.finish(CSCOfConcreteSuperClass.class);
    }
}

From source file:net.sourceforge.floggy.persistence.fr2852335.perclass.FR2852335MigrationTest.java

/**
 * DOCUMENT ME!/*ww  w . j a v a2s  .  c  o  m*/
*
* @throws Exception DOCUMENT ME!
*/
public void testMigrationConcreteSubClassOfConcreteSubClass() throws Exception {
    MigrationManager mm = MigrationManager.getInstance();
    Enumeration enumeration = mm.start(CSCOfConcreteSubClass.class, null);

    assertEquals(PerClassStrategyEnumerationImpl.class, enumeration.getClass());

    try {
        while (enumeration.hasMoreElements()) {
            Hashtable fields = enumeration.nextElement();
            assertEquals(classification, ((Character) fields.get("classification")).charValue());
            assertEquals(name, fields.get("name"));
            assertEquals(checkpoint.getTime(), fields.get("start"));
        }
    } finally {
        mm.finish(CSCOfConcreteSubClass.class);
    }
}

From source file:com.modeln.build.ctrl.charts.CMnChartFormatter.java

private void formatChart(PiePlot plot, Hashtable colormap, String label) {
    // Set the chart colors
    Enumeration keys = colormap.keys();
    while (keys.hasMoreElements()) {
        String name = (String) keys.nextElement();
        Color color = (Color) colormap.get(name);
        if (color == null) {
            color = DEFAULT_COLOR;/*from   w ww  . j a v  a  2 s. c o m*/
        }
        plot.setSectionPaint(name, color);
    }

    // Set the chart label format
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1} " + label + " ({2})"));
}

From source file:com.github.r351574nc3.amex.assignment1.csv.DefaultInterpreter.java

/**
 * Convert records to {@link TestData}./*from  ww  w .  jav a2 s  . c  o m*/
 *
 * @return {@link Hashtable} instance which makes record lookup by name much easier. Records that belong to a given name are indexed
 * within the {@link Hashtable} instance. In case there is more than one instance, the object in the {@link Hashtable} is
 * a {@link LinkedList} which can be quickly iterated
 */
public Hashtable interpret(final File input) throws IOException {
    final CSVParser parser = CSVParser.parse(input, Charset.defaultCharset(),
            CSVFormat.RFC4180.withDelimiter('|'));

    // Using a {@link Hashtable with the name field on the CSV record as the key. A lower load factor is used to give more
    // priority to the time cost for looking up values. 
    final Hashtable<String, LinkedList<TestData>> index = new Hashtable<String, LinkedList<TestData>>(2, 0.5f);

    for (final CSVRecord record : parser) {
        final EmailNotificationTestData data = toTestData(record);

        LinkedList<TestData> data_ls = index.get(data.getName());
        if (data_ls == null) {
            data_ls = new LinkedList<TestData>();
            index.put(data.getName(), data_ls);
        }
        data_ls.add(data);
    }

    return index;
}

From source file:net.sourceforge.jwbf.actions.mw.old.PostDelete.java

/**
 * //  w  ww  .  j  a  v  a2s . co m
 * @param label of the article
 * @param tab with contains environment variable "wpEditToken"
 * @deprecated
 */
public PostDelete(final String label, Hashtable<String, String> tab) {

    NameValuePair action = new NameValuePair("wpConfirmB", "Delete Page");
    // this value is preseted
    NameValuePair wpReason = new NameValuePair("wpReason", "hier der Grund");
    wpReason.setName("backdraft");

    NameValuePair wpEditToken = new NameValuePair("wpEditToken", tab.get("wpEditToken"));

    PostMethod pm = new PostMethod("/index.php?title=" + label + "&action=delete");

    pm.setRequestBody(new NameValuePair[] { action, wpReason, wpEditToken });
    pm.getParams().setContentCharset(MediaWikiBot.CHARSET);
    msgs.add(pm);

}

From source file:com.jaspersoft.jasperserver.export.RemoveDuplicatedDisplayName.java

private boolean updateDuplicateNames(Hashtable ht) {
    Enumeration enu = ht.keys();//from   w w  w  . j  av a2  s .c om
    while (enu.hasMoreElements()) {
        List valueList = (List) ht.get((String) enu.nextElement());
        if (valueList.size() > 1) {
            int curValue = 2;
            for (int i = 1; i < valueList.size(); i++) {
                try {
                    osw.write("\r\n");
                    osw.write("Parent Folder: " + ((Resource) valueList.get(i)).getParentURI());
                    osw.write("\r\n");
                    osw.write("Modified Object Name(ID): " + ((Resource) valueList.get(i)).getURIString());
                    osw.write("\r\n");
                    osw.write("Modified Object Old Display Name: " + ((Resource) valueList.get(i)).getLabel());
                    osw.write("\r\n");
                } catch (IOException e) {
                }

                // need to find 2, 3, 4.. etc 
                int newNumber = findUniqueDisplayNameNumber(ht, curValue,
                        ((Resource) valueList.get(i)).getLabel());
                String newLabel = ((Resource) valueList.get(i)).getLabel() + " (" + newNumber + ")";
                // update loaded values
                ((Resource) valueList.get(i)).setLabel(newLabel);
                if (valueList.get(i) instanceof Folder) {
                    if (updateRepo) {
                        repository.saveFolder(null, (Folder) valueList.get(i));
                    }
                    try {
                        //osw.write("Modified Object New Display Name: " + ((Folder)valueList.get(i)).getLabel());
                        osw.write("Modified Object New Display Name: " + newLabel);
                        osw.write("\r\n");
                        osw.write("Modified Object Type: Folder");
                        osw.write("\r\n");
                        osw.write("\r\n");
                    } catch (IOException e) {
                    }
                } else {
                    // get the actual resource
                    if (updateRepo) {
                        Resource res = repository.getResource(null,
                                ((Resource) valueList.get(i)).getURIString());
                        res.setLabel(newLabel);
                        repository.saveResource(null, res);
                    }
                    try {
                        //osw.write("Modified Object New Display Name: " + ((Resource)valueList.get(i)).getLabel());
                        osw.write("Modified Object New Display Name: " + newLabel);
                        osw.write("\r\n");
                        osw.write("Modified Object Type: " + ((Resource) valueList.get(i)).getResourceType());
                        osw.write("\r\n");
                        osw.write("\r\n");
                    } catch (IOException e) {
                    }
                }
                curValue = newNumber + 1;
            }
        }
    }

    return true;
}

From source file:org.springframework.amqp.support.converter.Jackson2JsonMessageConverterTests.java

@Test
@SuppressWarnings("unchecked")
public void hashtable() {
    Hashtable<String, String> hashtable = new Hashtable<String, String>();
    hashtable.put("TICKER", "VMW");
    hashtable.put("PRICE", "103.2");

    Message message = converter.toMessage(hashtable, new MessageProperties());
    Hashtable<String, String> marhsalledHashtable = (Hashtable<String, String>) converter.fromMessage(message);

    assertEquals("VMW", marhsalledHashtable.get("TICKER"));
    assertEquals("103.2", marhsalledHashtable.get("PRICE"));
}

From source file:org.mahasen.util.DeleteUtil.java

/**
 * @param fileToDelete//from w  ww. ja v a2s . c om
 * @throws MalformedURLException
 * @throws RegistryException
 */
public void delete(String fileToDelete)
        throws MalformedURLException, RegistryException, MahasenConfigurationException, MahasenException {
    Id resourceId = Id.build(String.valueOf(fileToDelete.hashCode()));
    String currentFileName = null;

    try {
        MahasenResource mahasenResource = mahasenManager.lookupDHT(resourceId);

        if (mahasenManager.lookupDHT(resourceId) == null) {
            throw new MahasenException("File not found");
        }

        String fileName = mahasenResource.getProperty(MahasenConstants.FILE_NAME).toString();
        Hashtable<String, Vector<String>> iptable = mahasenResource.getSplittedPartsIpTable();

        int totalNoOfParts = 0;
        for (String partName : mahasenResource.getPartNames()) {
            totalNoOfParts += iptable.get(partName).size();
        }

        setStoredNoOfParts(totalNoOfParts);

        for (String partName : mahasenResource.getPartNames()) {
            currentFileName = fileName + "." + partName;
            for (int i = 0; i < iptable.get(partName).size(); i++) {
                String nodeIp = iptable.get(partName).get(i);

                ArrayList<NameValuePair> qparams = new ArrayList<NameValuePair>();
                qparams.add(new BasicNameValuePair(MahasenConstants.FILE_NAME, fileName + "." + partName));

                URI uri = null;
                try {
                    uri = URIUtils.createURI("https", nodeIp + ":" + MahasenConstants.SERVER_PORT, -1,
                            "/mahasen/delete_request_ajaxprocessor.jsp",
                            URLEncodedUtils.format(qparams, "UTF-8"), null);
                    MahasenDeleteWorker mahasenDeleteWorker = new MahasenDeleteWorker(uri);
                    Thread deleteThread = new Thread(mahasenDeleteWorker);
                    deleteThread.start();

                } catch (URISyntaxException e) {
                    log.info("URI not found");
                    return;
                }
            }
        }

        final BlockFlag blockFlag = new BlockFlag(true, 1500);
        while (true) {

            if (storedNoOfParts.intValue() == 0) {
                MahasenResource resourceToDelete = mahasenManager.lookupDHT(resourceId);
                mahasenManager.deletePropertyFromTreeMap(resourceId, resourceToDelete);
                mahasenManager.deleteContent(resourceId);
                blockFlag.unblock();
                break;
            }

            if (blockFlag.isBlocked()) {

                mahasenManager.getNode().getEnvironment().getTimeSource().sleep(10);
            } else {
                throw new MahasenException("Time out in delete operation for " + fileName);
            }
        }
    } catch (InterruptedException e) {
        log.error("Error deleting file : " + currentFileName);
    }
}