List of usage examples for java.util Hashtable put
public synchronized V put(K key, V value)
From source file:Main.java
static Hashtable hashtableClone(Hashtable ht1, Hashtable ht2) { if (ht1 == null && ht2 == null) return null; Hashtable htresp = new Hashtable(); if (ht1 != null) { Enumeration e = ht1.keys(); while (e.hasMoreElements()) { Object element = e.nextElement(); htresp.put(element, ht1.get(element)); }/*from w w w . j a v a2s. com*/ } if (ht2 != null) { Enumeration e = ht2.keys(); while (e.hasMoreElements()) { Object element = e.nextElement(); htresp.put(element, ht2.get(element)); } } return htresp; }
From source file:co.runrightfast.core.utils.JmxUtils.java
static ObjectName applicationMBeanObjectName(final String domain, @NonNull final Class<?> mbeanType, final String name) { checkArgument(isNotBlank(domain));/*from w ww .jav a2 s.c om*/ checkArgument(isNotBlank(name)); try { @SuppressWarnings("UseOfObsoleteCollectionType") final Hashtable<String, String> attributes = new Hashtable<>(); attributes.put("type", mbeanType.getSimpleName()); attributes.put("name", name); return ObjectName.getInstance(domain, attributes); } catch (final MalformedObjectNameException e) { throw new RuntimeException(e); } }
From source file:Main.java
/** * Method getDropDownOptions./*from w w w. jav a 2 s .com*/ * * @param vector Vector * @param valueGetter String * @param textGetter String * @param selectedValues Vector * @return String * @throws NoSuchMethodException * @throws IllegalAccessException * @throws InvocationTargetException */ public static String getDropDownOptions(Vector vector, String valueGetter, String textGetter, Vector selectedValues) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Hashtable selectedValuesHashtable = new Hashtable(selectedValues.size()); for (int i = 0; i < selectedValues.size(); i++) { selectedValuesHashtable.put(selectedValues.elementAt(i).toString(), ""); } StringBuffer dropDownOptions = new StringBuffer(""); String optionValue = null; String optionText = null; Class[] clsParms = new Class[0]; Object[] objParms = new Object[0]; Method getterMethod = null; Object vectorElement = null; for (int i = 0; i < vector.size(); i++) { vectorElement = vector.elementAt(i); getterMethod = vectorElement.getClass().getMethod(valueGetter, clsParms); optionValue = getterMethod.invoke(vectorElement, objParms).toString(); getterMethod = vectorElement.getClass().getMethod(textGetter, clsParms); optionText = getterMethod.invoke(vectorElement, objParms).toString(); dropDownOptions.append("<option value=\"" + optionValue + "\""); if (selectedValuesHashtable.containsKey(optionValue)) { dropDownOptions.append(" selected"); } dropDownOptions.append(">" + optionText); } return dropDownOptions.toString(); }
From source file:Main.java
public static Hashtable parameterMapToHashtable(Map m) { Hashtable ret = new Hashtable(); ret.putAll(m);/* ww w . j a va 2s . c o m*/ for (Iterator i = ret.keySet().iterator(); i.hasNext();) { Object key = i.next(); String[] value = (String[]) ret.get(key); try { ret.put(key, value[0]); } catch (ArrayIndexOutOfBoundsException e) { // This should not happen but if it does just continue // processing. } } return ret; }
From source file:Main.java
static Hashtable hashtableMerge(Hashtable dst, Hashtable src) { if (dst == null) return src; if (src == null) return dst; Enumeration e = src.keys();/*from w w w . j a v a 2s.c om*/ while (e.hasMoreElements()) { Object element = e.nextElement(); dst.put(element, src.get(element)); } return dst; }
From source file:io.fabric8.mq.util.BrokerJmxUtils.java
public static Hashtable<String, String> getProperties(String string) { Hashtable<String, String> result = new Hashtable<>(); String[] props = string.split(","); for (String prop : props) { String[] keyValues = prop.split("="); result.put(keyValues[0].trim(), ObjectName.quote(keyValues[1].trim())); }/*w w w. j a v a 2 s.c o m*/ return result; }
From source file:Main.java
public static Hashtable contarElementos(Vector list) { Hashtable hash = new Hashtable(); for (int i = 0; i < list.size(); i++) { Object key = list.elementAt(i); if (hash.containsKey(key)) { Integer qtde = new Integer(((Integer) hash.get(key)).intValue() + 1); hash.put(key, qtde); } else {/*from w w w .ja va2 s . com*/ hash.put(key, new Integer(1)); } } return hash; }
From source file:com.mirth.connect.connectors.jms.JmsDispatcherTests.java
private static ConnectionFactory lookupConnectionFactoryWithJndi(JmsConnectorProperties connectorProperties) throws Exception { Hashtable<String, String> env = new Hashtable<String, String>(); 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:io.fabric8.mq.controller.util.BrokerJmxUtils.java
public static Hashtable<String, String> getProperties(String string) { Hashtable<String, String> result = new Hashtable<>(); String[] props = string.split(","); for (int i = 0; i < props.length; i++) { String[] keyValues = props[i].split("="); result.put(keyValues[0].trim(), ObjectName.quote(keyValues[1].trim())); }// w w w .j a va 2s .c om return result; }
From source file:com.springsource.insight.plugin.ldap.LdapOperationCollectionAspectTestSupport.java
protected static final Hashtable<String, Object> createEnvironment() { Hashtable<String, Object> env = new Hashtable<String, Object>(); env.put(Context.PROVIDER_URL, LDAP_URL); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.SECURITY_PRINCIPAL, LDAP_USERNAME); env.put(Context.SECURITY_CREDENTIALS, LDAP_PASSWORD); return env;// ww w . jav a2 s .co m }