本文整理了Java中java.util.Dictionary.get()
方法的一些代码示例,展示了Dictionary.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dictionary.get()
方法的具体详情如下:
包路径:java.util.Dictionary
类名称:Dictionary
方法名:get
[英]Returns the value which is associated with key.
[中]返回与键关联的值。
代码示例来源:origin: stanfordnlp/CoreNLP
private static <K,V> void log(RedwoodChannels channels, String description, Dictionary<K,V> dict) {
//(a real data structure)
Map<K, V> map = Generics.newHashMap();
//(copy to map)
Enumeration<K> keys = dict.keys();
while(keys.hasMoreElements()){
K key = keys.nextElement();
V value = dict.get(key);
map.put(key,value);
}
//(log like normal)
log(channels, description, map);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Dictionary does not know the putAll method. Please use Map.putAll().
* @param m1 the to directory.
* @param m2 the from directory.
* @param <K> type of the key
* @param <V> type of the value
* @since Ant 1.6
* @deprecated since 1.6.x.
*/
@Deprecated
public static <K, V> void putAll(Dictionary<? super K, ? super V> m1,
Dictionary<? extends K, ? extends V> m2) {
StreamUtils.enumerationAsStream(m2.keys()).forEach(key -> m1.put(key, m2.get(key)));
}
代码示例来源:origin: apache/ignite
if (b.getState() <= Bundle.RESOLVED || b.getHeaders().get(Constants.FRAGMENT_HOST) != null)
continue;
代码示例来源:origin: org.apache.karaf.decanter.marshaller/org.apache.karaf.decanter.marshaller.csv
@Activate
public void activate(ComponentContext componentContext) {
Dictionary<String, Object> config = componentContext.getProperties();
separator = (config.get("separator") != null) ? (String) config.get("separator") : ",";
}
代码示例来源:origin: com.sun.enterprise/osgi-adapter
private void init(Bundle b) {
Attributes attrs = getMainAttributes();
Dictionary headers = b.getHeaders();
for (Object o : Collections.list(headers.keys())) {
attrs.putValue((String)o, (String)headers.get(o));
}
}
代码示例来源:origin: org.osgi/org.osgi.compendium
/**
* Create an EventProperties from the specified dictionary.
*
* <p>
* The specified properties will be copied into this EventProperties.
* Properties whose key is not of type {@code String} will be ignored. A
* property with the key "event.topics" will be ignored.
*
* @param properties The properties to use for this EventProperties object
* (may be {@code null}).
*/
EventProperties(Dictionary<String, ?> properties) {
int size = (properties == null) ? 0 : properties.size();
Map<String, Object> p = new HashMap<String, Object>(size);
if (size > 0) {
for (Enumeration<?> e = properties.keys(); e.hasMoreElements();) {
Object key = e.nextElement();
if ((key instanceof String) && !EVENT_TOPIC.equals(key)) {
Object value = properties.get(key);
p.put((String) key, value);
}
}
}
// safely publish the map
this.properties = Collections.unmodifiableMap(p);
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.reasoners.jena
@Activate
public void activate(ComponentContext context) {
this.path = (String) context.getProperties().get(ReasoningService.SERVICE_PATH);
}
}
代码示例来源:origin: apache/ignite
/**
* @throws Exception
*/
@Test
public void testAllBundlesActiveAndFeaturesInstalled() throws Exception {
// Asssert all bundles except fragments are ACTIVE.
for (Bundle b : bundleCtx.getBundles()) {
System.out.println(String.format("Checking state of bundle [symbolicName=%s, state=%s]",
b.getSymbolicName(), b.getState()));
if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null)
assertTrue(b.getState() == Bundle.ACTIVE);
}
// Check that according to the FeaturesService, all Ignite features except ignite-log4j are installed.
Feature[] features = featuresSvc.getFeatures(IGNITE_FEATURES_NAME_REGEX);
assertNotNull(features);
assertEquals(EXPECTED_FEATURES, features.length);
for (Feature f : features) {
if (IGNORED_FEATURES.contains(f.getName()))
continue;
boolean installed = featuresSvc.isInstalled(f);
System.out.println(String.format("Checking if feature is installed [featureName=%s, installed=%s]",
f.getName(), installed));
assertTrue(installed);
assertEquals(PROJECT_VERSION.replaceAll("-", "."), f.getVersion().replaceAll("-", "."));
}
}
代码示例来源:origin: org.glassfish.hk2/osgi-adapter
private void init(Bundle b) {
Attributes attrs = getMainAttributes();
Dictionary headers = b.getHeaders();
for (Object o : Collections.list(headers.keys())) {
attrs.putValue((String)o, (String)headers.get(o));
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Dictionary does not have an equals.
* Please use Map.equals().
*
* <p>Follows the equals contract of Java 2's Map.</p>
* @param d1 the first directory.
* @param d2 the second directory.
* @return true if the directories are equal.
* @since Ant 1.5
* @deprecated since 1.6.x.
*/
@Deprecated
public static boolean equals(Dictionary<?, ?> d1, Dictionary<?, ?> d2) {
if (d1 == d2) {
return true;
}
if (d1 == null || d2 == null) {
return false;
}
if (d1.size() != d2.size()) {
return false;
}
// don't need the opposite check as the Dictionaries have the
// same size, so we've also covered all keys of d2 already.
return StreamUtils.enumerationAsStream(d1.keys())
.allMatch(key -> d1.get(key).equals(d2.get(key)));
}
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
private void applyAuthSupplier(Dictionary<String, String> d, HTTPConduit c) {
Enumeration<String> keys = d.keys();
while (keys.hasMoreElements()) {
String k = keys.nextElement();
if (k.startsWith("authSupplier")) {
String v = d.get(k);
Object obj;
try {
obj = Class.forName(v).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
if (obj instanceof HttpAuthSupplier) {
c.setAuthSupplier((HttpAuthSupplier)obj);
}
}
}
}
}
代码示例来源:origin: org.apache.sling/org.apache.sling.junit.core
/** Return the path at which to mount this servlet, or null
* if it must not be mounted.
*/
private String getServletPath(ComponentContext ctx) {
final Dictionary<?, ?> config = ctx.getProperties();
String result = (String)config.get(SERVLET_PATH_NAME);
if(result != null && result.trim().length() == 0) {
result = null;
}
return result;
}
代码示例来源:origin: spring-projects/spring-roo
private static boolean isFragment(Bundle bundle)
{
return bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null;
}
}
代码示例来源:origin: org.apache.felix/org.osgi.compendium
/**
* Constructs an event.
*
* @param topic The topic of the event.
* @param properties The event's properties (may be <code>null</code>). A
* property whose key is not of type <code>String</code> will be
* ignored.
* @throws IllegalArgumentException If topic is not a valid topic name.
*/
public Event(String topic, Dictionary/* <String,Object> */properties) {
validateTopicName(topic);
this.topic = topic;
int size = (properties == null) ? 1 : (properties.size() + 1);
Map p = new HashMap(size);
if (properties != null) {
for (Enumeration e = properties.keys(); e.hasMoreElements();) {
Object key = e.nextElement();
if (key instanceof String) {
Object value = properties.get(key);
p.put(key, value);
}
}
}
p.put(EventConstants.EVENT_TOPIC, topic);
this.properties = p; // safely publish the map
}
代码示例来源:origin: apache/jackrabbit-oak
protected static String lookup(ComponentContext context, String property) {
//Prefer property from BundleContext first
if (context.getBundleContext().getProperty(property) != null) {
return context.getBundleContext().getProperty(property);
}
if (context.getProperties().get(property) != null) {
return context.getProperties().get(property).toString();
}
return null;
}
}
代码示例来源:origin: rhuss/jolokia
protected String getBundleVersion(String pSymbolicName) {
BundleContext context = JolokiaServlet.getCurrentBundleContext();
if (context != null) {
for (Bundle bundle: context.getBundles()) {
if (pSymbolicName.equalsIgnoreCase(bundle.getSymbolicName())) {
Dictionary headers = bundle.getHeaders();
return (String) headers.get("Bundle-Version");
}
}
}
return null;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
private void applyProxyAuthorization(Dictionary<String, String> d, HTTPConduit c) {
Enumeration<String> keys = d.keys();
ProxyAuthorizationPolicy p = c.getProxyAuthorization();
while (keys.hasMoreElements()) {
String k = keys.nextElement();
if (k.startsWith("proxyAuthorization.")) {
if (p == null) {
p = new ProxyAuthorizationPolicy();
c.setProxyAuthorization(p);
}
String v = d.get(k);
k = k.substring("proxyAuthorization.".length());
if ("UserName".equals(k)) {
p.setUserName(v);
} else if ("Password".equals(k)) {
p.setPassword(v);
} else if ("Authorization".equals(k)) {
p.setAuthorization(v);
} else if ("AuthorizationType".equals(k)) {
p.setAuthorizationType(v);
}
}
}
}
代码示例来源:origin: org.apache.jackrabbit/oak-blob
private static String lookup(ComponentContext context, String property) {
// Prefer property from BundleContext first
if (context.getBundleContext().getProperty(property) != null) {
return context.getBundleContext().getProperty(property);
}
if (context.getProperties().get(property) != null) {
return context.getProperties().get(property).toString();
}
return null;
}
代码示例来源:origin: spring-projects/spring-roo
/**
* This service is being activated so setup it:
* <ul>
* <li>Create and open the {@link MetadataDependencyRegistryTracker}.</li>
* </ul>
*/
protected void activate(final ComponentContext componentContext) {
this.registryTracker =
new MetadataDependencyRegistryTracker(componentContext.getBundleContext(), this);
this.registryTracker.open();
for (final Bundle b : componentContext.getBundleContext().getBundles()) {
if (!MY_BUNDLE_SYMBOLIC_NAME.equals(b.getSymbolicName())) {
continue;
}
final Object v = b.getHeaders().get("Bundle-Version");
if (v != null) {
final String version = v.toString();
bundleVersionInfo = extractVersionInfoFromString(version);
}
break;
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
private void applyAuthorization(Dictionary<String, String> d, HTTPConduit c) {
Enumeration<String> keys = d.keys();
AuthorizationPolicy p = c.getAuthorization();
while (keys.hasMoreElements()) {
String k = keys.nextElement();
if (k.startsWith("authorization.")) {
if (p == null) {
p = new AuthorizationPolicy();
c.setAuthorization(p);
}
String v = d.get(k);
k = k.substring("authorization.".length());
if ("UserName".equals(k)) {
p.setUserName(v);
} else if ("Password".equals(k)) {
p.setPassword(v);
} else if ("Authorization".equals(k)) {
p.setAuthorization(v);
} else if ("AuthorizationType".equals(k)) {
p.setAuthorizationType(v);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!