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: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;/*from   ww  w . j a v a2 s  .  c o  m*/
}

From source file:FileMonitor.java

/**
 * Constructor.//from  www .  j  a  v  a2  s  .  c o m
 */
private FileMonitor() {
    // Create timer, run timer thread as daemon.
    timer = new Timer(true);
    timerEntries = new Hashtable<String, FileMonitorTask>();
}

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);//  w  ww.  ja  v  a  2  s. c  om
}

From source file:de.ingrid.iplug.ckan.utils.ScriptEngine.java

/**
 * Execute the given scripts with the given parameters
 * @param scripts The script files//from ww w .j a  va  2 s .  c  o m
 * @param parameters The parameters
 * @param compile Boolean indicating whether to compile the script or not
 * @return Map with the absolute paths of the scripts as keys and the execution results as values
 * If an execution returns null, the result will not be added
 * @throws Exception
 */
public static Map<String, Object> execute(Resource[] scripts, Map<String, Object> parameters, boolean compile)
        throws Exception {

    Map<Integer, Bindings> bindings = new Hashtable<Integer, Bindings>();
    Map<String, Object> results = new Hashtable<String, Object>();

    for (Resource script : scripts) {
        // get the engine for the script
        javax.script.ScriptEngine engine = getEngine(script);

        // initialize/get the bindings
        if (!bindings.containsKey(engine.hashCode())) {
            Bindings newBindings = engine.createBindings();
            newBindings.putAll(parameters);
            bindings.put(engine.hashCode(), newBindings);
        }
        Bindings curBindings = bindings.get(engine.hashCode());

        // execute the script
        CompiledScript compiledScript = null;
        Object result = null;
        if (compile && (compiledScript = getCompiledScript(script)) != null) {
            result = compiledScript.eval(curBindings);
        } else {
            result = engine.eval(new InputStreamReader(script.getInputStream()), curBindings);
        }
        if (result != null) {
            results.put(script.getFilename(), result);
        }
    }
    return results;
}

From source file:com.khubla.cbean.serializer.impl.json.JSONObjectSerializer.java

@Override
public Object deserialize(String str) throws SerializerException {
    try {/*w  w w . j  a  va2s  . c o m*/
        final JSONObject jsonObject = new JSONObject(str);
        final Hashtable<String, String> hash = new Hashtable<String, String>();
        final Iterator<String> keys = jsonObject.keys();
        while (keys.hasNext()) {
            final String key = keys.next();
            final String value = jsonObject.getString(key);
            hash.put(key, value);
        }
        return classHasher.hashToClass(hash);
    } catch (final Exception e) {
        throw new SerializerException(e);
    }
}

From source file:Main.java

/**
 * Gets the activity list./* w  w  w. j  a  v  a2s  . 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:gov.nih.nci.cabig.caaers.service.synchronizer.TreatmentAssignmentSynchronizer.java

public void migrate(Study dbStudy, Study xmlStudy, DomainObjectImportOutcome<Study> outcome) {
    //create an Index of existing ones (available in DB)
    Hashtable<String, TreatmentAssignment> dbTacIndexMap = new Hashtable<String, TreatmentAssignment>();
    Hashtable<String, TreatmentAssignment> dbCtepIndexMap = new Hashtable<String, TreatmentAssignment>();
    for (TreatmentAssignment ta : dbStudy.getActiveTreatmentAssignments()) {
        String ctepDbId = StringUtils.upperCase(ta.getCtepDbIdentifier());
        String tac = StringUtils.upperCase(ta.getCode());
        dbTacIndexMap.put(tac, ta);//from w  ww  .  ja  v a2 s.  c o m
        if (StringUtils.isNotEmpty(ctepDbId))
            dbCtepIndexMap.put(ctepDbId, ta);
    }

    //Identify New TreatmentAssignments and also update existing ones.
    for (TreatmentAssignment xmlTreatmentAssignment : xmlStudy.getTreatmentAssignments()) {

        // //CAAERS-7367 - /REFACTORED - always prefer the tac that is available.
        String ctepDbId = StringUtils.upperCase(xmlTreatmentAssignment.getCtepDbIdentifier());
        String tac = StringUtils.upperCase(xmlTreatmentAssignment.getCode());
        if (StringUtils.isEmpty(tac) && StringUtils.isEmpty(ctepDbId))
            continue; //no I cannot process this record
        TreatmentAssignment ta = null;

        //try to identify the TA by ctep-id
        if (StringUtils.isNotEmpty(ctepDbId)) {
            ta = dbCtepIndexMap.get(ctepDbId);
        }
        //TA not found : try to find by tac
        if (ta == null)
            ta = dbTacIndexMap.get(tac);

        //still tac null -- create a new one.
        if (ta == null) {
            ta = xmlTreatmentAssignment;
            dbStudy.addTreatmentAssignment(xmlTreatmentAssignment);
            continue;
        }

        //it is an existing TA, so lets sync up the attributes
        ta.setCtepDbIdentifier(xmlTreatmentAssignment.getCtepDbIdentifier());
        ta.setCode(xmlTreatmentAssignment.getCode());
        ta.setDescription(xmlTreatmentAssignment.getDescription());
        ta.setComments(xmlTreatmentAssignment.getComments());
        ta.setDoseLevelOrder(xmlTreatmentAssignment.getDoseLevelOrder());

        //marking the TA as processed by removing it from index
        dbTacIndexMap.remove(tac);

    }

    //soft delete - all the TAs that were not present in XML Study
    AbstractMutableRetireableDomainObject.retire(dbTacIndexMap.values());

}

From source file:SparseTest.java

public SparseTableModel(int rows, String columnHeaders[]) {
    if ((rows < 0) || (columnHeaders == null)) {
        throw new IllegalArgumentException("Invalid row count/columnHeaders");
    }// w  w w. jav  a 2  s.com
    this.rows = rows;
    this.columns = columnHeaders.length;
    headers = columnHeaders;
    lookup = new Hashtable();
}

From source file:com.sf.ddao.conn.JNDIDataSourceHandler.java

public void init(AnnotatedElement element, Annotation annotation) {
    JNDIDao daoAnnotation = (JNDIDao) annotation;
    String dsName = daoAnnotation.value();
    try {//from   w ww.  jav  a  2 s  .  c  o  m
        InitialContext ic = new InitialContext(new Hashtable());
        dataSource = (DataSource) ic.lookup(DS_CTX_PREFIX + dsName);
    } catch (Exception e) {
        throw new InitializerException("Failed to find DataSource " + dsName, e);
    }
}

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);/*from  w  ww.j ava2s  .com*/
}