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:eionet.gdem.conversion.ConvertDDXMLMethod.java

/**
 * Converts conversion result object into Hashtable that is used in XML-RPC method result.
 *
 * @param dto Result transfer object/*from w ww  .j av a  2  s  . c  om*/
 * @return Hash table with result
 * @throws GDEMException If an error occurs
 */
public static final Hashtable<String, Object> convertExcelResult(ConversionResultDto dto) throws GDEMException {
    Hashtable<String, Object> result = new Hashtable<String, Object>();

    result.put("resultCode", dto.getStatusCode());
    result.put("resultDescription", dto.getStatusDescription());
    result.put("conversionLog", dto.getConversionLogAsHtml());
    Vector<Hashtable<String, Object>> convertedFiles = new Vector<Hashtable<String, Object>>();

    if (dto.getConvertedFiles() != null) {
        for (ConvertedFileDto convertedFileDto : dto.getConvertedFiles()) {
            Hashtable<String, Object> convertedFile = new Hashtable<String, Object>();
            convertedFile.put("fileName", convertedFileDto.getFileName());
            convertedFile.put("content", convertedFileDto.getFileContentAsByteArray());
            convertedFiles.add(convertedFile);
        }
    }
    result.put("convertedFiles", convertedFiles);
    return result;
}

From source file:Main.java

/**
 * Gets the activity list./*from w  ww . j  a va 2 s .  c  o m*/
 * 
 * @param context
 *            the context
 * @param intent
 *            the intent
 * 
 * @return the activity list
 */
public static List<Hashtable<String, Object>> getActivityList(Context context, Intent intent) {
    List<Hashtable<String, Object>> result = new ArrayList<Hashtable<String, Object>>();
    PackageManager pm = context.getPackageManager();
    List<ResolveInfo> list = pm.queryIntentActivities(intent.addCategory("android.intent.category.DEFAULT"), 0);
    for (ResolveInfo info : list) {
        Hashtable<String, Object> h = new Hashtable<String, Object>();

        CharSequence labelSeq = info.activityInfo.loadLabel(pm);
        String label = labelSeq != null ? labelSeq.toString() : info.activityInfo.name;

        h.put(LABEL, label);
        h.put(INTENT, activityIntent(info.activityInfo.applicationInfo.packageName, info.activityInfo.name));
        result.add(h);
    }
    Collections.sort(result, displayNameComparator);
    return result;

}

From source file:Utilities.java

/**
 * Maps the specified key to the specified value in the specified
 * <code>Hashtable</code>. If the specified value is <code>null</code> any
 * existing mapping of the specified key is removed from the
 * <code>Hashtable</code>. The old value mapped to the specified key
 * is returned, or <code>null</code> if no value was mapped to the key.
 *///from   w w w.j  ava 2 s . c  o  m

public static Object put(Hashtable table, Object key, Object value) {
    return value == null ? table.remove(key) : table.put(key, value);
}

From source file:ucar.unidata.idv.control.chart.HistogramWrapper.java

/**
 * Plot the displayed {@link DataChoice}.
 * /*  w  ww  . ja  v  a2s.  c o  m*/
 * @param histoWrapper Cannot be {@code null}.
 */
public static void plotHistogram(HistogramWrapper histoWrapper) {
    XYPlot p = histoWrapper.plot;
    List<DataChoiceWrapper> dcWrappers = histoWrapper.getDataChoiceWrappers();

    try {
        for (int dataSetIdx = 0; dataSetIdx < p.getDatasetCount(); dataSetIdx++) {
            MyHistogramDataset dataset = (MyHistogramDataset) p.getDataset(dataSetIdx);
            dataset.removeAllSeries();
        }

        Hashtable props = new Hashtable();
        props.put(TrackDataSource.PROP_TRACKTYPE, TrackDataSource.ID_TIMETRACE);

        for (int paramIdx = 0; paramIdx < dcWrappers.size(); paramIdx++) {
            DataChoiceWrapper wrapper = dcWrappers.get(paramIdx);

            DataChoice dataChoice = wrapper.getDataChoice();
            FlatField data = histoWrapper.getFlatField((FieldImpl) dataChoice.getData(null, props));
            Unit unit = ucar.visad.Util.getDefaultRangeUnits((FlatField) data)[0];
            double[][] samples = data.getValues(false);
            double[] actualValues = histoWrapper.filterData(samples[0],
                    histoWrapper.getTimeValues(samples, data))[0];
            NumberAxis domainAxis = new NumberAxis(wrapper.getLabel(unit));

            XYItemRenderer renderer;
            if (histoWrapper.stacked) {
                renderer = new StackedXYBarRenderer();
            } else {
                renderer = new XYBarRenderer();
            }
            p.setRenderer(paramIdx, renderer);
            Color c = wrapper.getColor(paramIdx);
            domainAxis.setLabelPaint(c);
            renderer.setSeriesPaint(0, c);

            MyHistogramDataset dataset = new MyHistogramDataset();
            dataset.setType(HistogramType.FREQUENCY);
            dataset.addSeries(dataChoice.getName() + " [" + unit + "]", actualValues, histoWrapper.bins);
            p.setDomainAxis(paramIdx, domainAxis, false);
            p.mapDatasetToDomainAxis(paramIdx, paramIdx);
            p.setDataset(paramIdx, dataset);
        }
    } catch (VisADException | RemoteException e) {
        LogUtil.logException("Error creating data set", e);
    }
}

From source file:Main.java

/**
 * Convert an Android bundle to a hashtable
 * @param bundle//from   www  . j  ava2 s.com
 * @return
 */
public static Hashtable bundleToHashtable(Bundle bundle) {
    Hashtable retVal = new Hashtable();
    Set<String> keys = bundle.keySet();
    Iterator<String> iterator = keys.iterator();

    String key;
    Object val;
    while (iterator.hasNext()) {
        key = iterator.next();
        val = bundle.get(key);
        if (val instanceof String) {
            retVal.put(key, val);
        } else if (val instanceof Integer) {
            retVal.put(key, val);
        }
    }

    return retVal;
}

From source file:eu.europa.ec.markt.dss.validation.crl.OnlineCRLSource.java

/**
 * Downloads a CRL from given LDAP url, e.g. ldap://ldap.infonotary.com/dc=identity-ca,dc=infonotary,dc=com
 *
 * @throws CertificateException//w  w  w. j  av a  2  s . c  o m
 * @throws CRLException
 */

private static X509CRL downloadCRLFromLDAP_(final String ldapURL) throws DSSException {

    final Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, ldapURL);
    try {

        final DirContext ctx = new InitialDirContext(env);
        final Attributes attributes = ctx.getAttributes("");
        final javax.naming.directory.Attribute attribute = attributes.get("certificateRevocationList;binary");
        final byte[] val = (byte[]) attribute.get();
        if (val == null || val.length == 0) {

            throw new DSSException("Can not download CRL from: " + ldapURL);
        }
        final InputStream inStream = new ByteArrayInputStream(val);
        return DSSUtils.loadCRL(inStream);
    } catch (Exception e) {

        LOG.warning(e.getMessage());
        e.printStackTrace();
    }
    return null;
}

From source file:com.mirth.connect.connectors.jms.JmsReceiverTests.java

private static ConnectionFactory lookupConnectionFactoryWithJndi(JmsConnectorProperties connectorProperties)
        throws Exception {
    Hashtable<String, Object> env = new Hashtable<String, Object>();
    env.put(Context.PROVIDER_URL, connectorProperties.getJndiProviderUrl());
    env.put(Context.INITIAL_CONTEXT_FACTORY, connectorProperties.getJndiInitialContextFactory());
    env.put(Context.SECURITY_PRINCIPAL, connectorProperties.getUsername());
    env.put(Context.SECURITY_CREDENTIALS, connectorProperties.getPassword());

    initialContext = new InitialContext(env);
    String connectionFactoryName = connectorProperties.getJndiConnectionFactoryName();
    return (ConnectionFactory) initialContext.lookup(connectionFactoryName);
}

From source file:LDAPTest.java

/**
     * Gets a context from the properties specified in the file ldapserver.properties
     * @return the directory context/*  w  w w.  ja  va2 s .  co m*/
     */
    public static DirContext getContext() throws NamingException, IOException {
        Properties props = new Properties();
        FileInputStream in = new FileInputStream("ldapserver.properties");
        props.load(in);
        in.close();

        String url = props.getProperty("ldap.url");
        String username = props.getProperty("ldap.username");
        String password = props.getProperty("ldap.password");

        Hashtable<String, String> env = new Hashtable<String, String>();
        env.put(Context.SECURITY_PRINCIPAL, username);
        env.put(Context.SECURITY_CREDENTIALS, password);
        DirContext initial = new InitialDirContext(env);
        DirContext context = (DirContext) initial.lookup(url);

        return context;
    }

From source file:com.icesoft.applications.faces.auctionMonitor.AddAuctionItem.java

public static Hashtable parseFile(Reader reader) {
    BufferedReader in = new BufferedReader(reader);
    Hashtable params = new Hashtable();
    String line;/*from w  ww .  j  a v  a 2 s.  c  om*/
    try {
        String name;
        String value;
        while (null != (line = in.readLine())) {
            int index = line.indexOf(' ');
            name = line.substring(0, index);
            value = line.substring(index + 1);
            params.put(name, value);
        }
    } catch (IOException e) {
        if (log.isErrorEnabled()) {
            log.error("Error while parsing an auction item file into the hashtable");
        }
    }
    return params;
}

From source file:Main.java

public static Hashtable<Integer, Vector<Integer>> getNodeMembership(final Vector<Vector<Integer>> CmtyVV) {
    Hashtable<Integer, Vector<Integer>> NIDComVH = new Hashtable<Integer, Vector<Integer>>();
    for (int CID = 0; CID < CmtyVV.size(); CID++) {
        for (Integer NID : CmtyVV.get(CID)) {
            if (!NIDComVH.contains(NID)) {
                Vector<Integer> v = new Vector<Integer>();
                v.add(CID);//  w  w w  . java 2 s.  com
                NIDComVH.put(NID, v);
            } else {
                Vector<Integer> v = NIDComVH.get(NID);
                v.add(CID);
                NIDComVH.put(NID, v);
            }
        }
    }
    return NIDComVH;
}