java.util.Dictionary.put()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(12.9k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中java.util.Dictionary.put()方法的一些代码示例,展示了Dictionary.put()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dictionary.put()方法的具体详情如下:
包路径:java.util.Dictionary
类名称:Dictionary
方法名:put

Dictionary.put介绍

[英]Associate key with value in this dictionary. If key exists in the dictionary before this call, the old value in the dictionary is replaced by value.
[中]将键与此字典中的值关联。如果在此调用之前字典中存在键,则字典中的旧值将替换为值。

代码示例

代码示例来源:origin: stackoverflow.com

private Dictionary<Integer, Integer> listViewItemHeights = new Hashtable<Integer, Integer>();

private int getScroll() {
  View c = listView.getChildAt(0); //this is the first visible row
  int scrollY = -c.getTop();
  listViewItemHeights.put(listView.getFirstVisiblePosition(), c.getHeight());
  for (int i = 0; i < listView.getFirstVisiblePosition(); ++i) {
    if (listViewItemHeights.get(i) != null) // (this is a sanity check)
      scrollY += listViewItemHeights.get(i); //add all heights of the views that are gone
  }
  return scrollY;
}

代码示例来源:origin: org.postgresql/postgresql

public void start(BundleContext context) throws Exception {
 Dictionary<String, Object> properties = new Hashtable<String, Object>();
 properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, Driver.class.getName());
 properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_NAME, org.postgresql.util.DriverInfo.DRIVER_NAME);
 properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_VERSION, org.postgresql.util.DriverInfo.DRIVER_VERSION);
 try {
  _registration = context.registerService(DataSourceFactory.class.getName(),
    new PGDataSourceFactory(), properties);
 } catch (NoClassDefFoundError e) {
  String msg = e.getMessage();
  if (msg != null && msg.contains("org/osgi/service/jdbc/DataSourceFactory")) {
   if (!Boolean.getBoolean("pgjdbc.osgi.debug")) {
    return;
   }
   new IllegalArgumentException("Unable to load DataSourceFactory. "
     + "Will ignore DataSourceFactory registration. If you need one, "
     + "ensure org.osgi.enterprise is on the classpath", e).printStackTrace();
   // just ignore. Assume OSGi-enterprise is not loaded
   return;
  }
  throw e;
 }
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.osgi

private void register(BundleContext context, String serviceClass, Object service, boolean setRanking, Dictionary<String, Object> properties) {
    if (properties == null)
      properties = new Hashtable<>(7);
    Dictionary<String, String> headers = context.getBundle().getHeaders();
    properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR));
    if (setRanking) {
      properties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MAX_VALUE));
    }
    properties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$
    registrations.add(context.registerService(serviceClass, service, properties));
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
@SuppressWarnings("unchecked")
public void start(BundleContext context) throws Exception {
  osgiServiceUtil = new OsgiServiceUtil( context );
  // Build a JtaPlatform specific for this OSGi context
  final OsgiJtaPlatform osgiJtaPlatform = new OsgiJtaPlatform( osgiServiceUtil );
  final Dictionary properties = new Hashtable();
  // In order to support existing persistence.xml files, register using the legacy provider name.
  properties.put( "javax.persistence.provider", HibernatePersistenceProvider.class.getName() );
  persistenceProviderService = context.registerService(
      PersistenceProvider.class.getName(),
      new OsgiPersistenceProviderService( osgiJtaPlatform, osgiServiceUtil ),
      properties
  );
  sessionFactoryService = context.registerService(
      SessionFactory.class.getName(),
      new OsgiSessionFactoryService( osgiJtaPlatform, osgiServiceUtil ),
      new Hashtable()
  );
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.osgi

private void register(BundleContext context, String serviceClass, Object service, boolean setRanking, Dictionary<String, Object> properties) {
    if (properties == null)
      properties = new Hashtable<String, Object>(7);
    Dictionary<String, String> headers = context.getBundle().getHeaders();
    properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR));
    if (setRanking) {
      properties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MAX_VALUE));
    }
    properties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$
    registrations.add(context.registerService(serviceClass, service, properties));
  }
}

代码示例来源:origin: stackoverflow.com

private Dictionary<Integer, Integer> listViewItemHeights = new Hashtable<Integer, Integer>();

private int getScroll() {
  View c = listView.getChildAt(0); //this is the first visible row
  int scrollY = -c.getTop();
  listViewItemHeights.put(listView.getFirstVisiblePosition(), c.getHeight());
  for (int i = 0; i < listView.getFirstVisiblePosition(); ++i) {
    if (listViewItemHeights.get(i) != null) // (this is a sanity check)
      scrollY += listViewItemHeights.get(i); //add all heights of the views that are gone
  }
  return scrollY;
}

代码示例来源:origin: apache/ignite

/**
   * Exports the Ignite instance onto the OSGi Service Registry.
   *
   * @param ignite Ignite.
   */
  private void exportOsgiService(Ignite ignite) {
    Dictionary<String, String> dict = new Hashtable<>();

    // Only add the service property if the Ignite instance name != null.
    if (ignite.name() != null)
      dict.put(OSGI_SERVICE_PROP_IGNITE_NAME, ignite.name());

    bundleCtx.registerService(Ignite.class, ignite, dict);

    if (log.isInfoEnabled())
      log.info("Exported OSGi service for Ignite with properties: " + dict);
  }
}

代码示例来源:origin: com.github.veithen.cosmos/cosmos-equinox

private void register(BundleContext context, String serviceClass, Object service, boolean setRanking, Dictionary<String, Object> properties) {
    if (properties == null)
      properties = new Hashtable<String, Object>(7);
    Dictionary<String, String> headers = context.getBundle().getHeaders();
    properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR));
    if (setRanking) {
      properties.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
    }
    properties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$
    registrations.add(context.registerService(serviceClass, service, properties));
  }
}

代码示例来源: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: spring-projects/spring-roo

public void start(BundleContext context) throws Exception {
 bundleContext = context;
 Dictionary<String, Object> props = new Hashtable<String, Object>();
 props.put("osgi.command.function", new String[] {"deploy", "install", "uninstall", "start",
   "stop", "list",});
 props.put("osgi.command.scope", "subsystem");
 context.registerService(getClass().getName(), this, props);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi

private void register(BundleContext context, String serviceClass, Object service, boolean setRanking, Dictionary<String, Object> properties) {
    if (properties == null)
      properties = new Hashtable<>(7);
    Dictionary<String, String> headers = context.getBundle().getHeaders();
    properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR));
    if (setRanking) {
      properties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MAX_VALUE));
    }
    properties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$
    registrations.add(context.registerService(serviceClass, service, properties));
  }
}

代码示例来源:origin: joyoyao/superCleanMaster

public static int getScrollY(RecyclerView rv) {
  View c = rv.getChildAt(0);
  if (c == null) {
    return 0;
  }
  LinearLayoutManager layoutManager = (LinearLayoutManager)rv.getLayoutManager();
  int firstVisiblePosition = layoutManager.findFirstVisibleItemPosition();
  int scrollY = -(c.getTop());
  sRecyclerViewItemHeights.put(layoutManager.findFirstVisibleItemPosition(), c.getHeight());
  if(scrollY<0)
    scrollY = 0;
  for (int i = 0; i < firstVisiblePosition; ++i) {
    if (sRecyclerViewItemHeights.get(i) != null) // (this is a sanity check)
      scrollY += sRecyclerViewItemHeights.get(i); //add all heights of the views that are gone
  }
  return scrollY;
}

代码示例来源:origin: spring-projects/spring-roo

public void start(BundleContext context) throws Exception {
 bundleContext = context;
 Dictionary<String, Object> props = new Hashtable<String, Object>();
 props.put("osgi.command.function", new String[] {"start"});
 props.put("osgi.command.scope", "obr");
 context.registerService(getClass().getName(), this, props);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.osgi

private void register(BundleContext context, String serviceClass, Object service, boolean setRanking, Dictionary<String, Object> properties) {
    if (properties == null)
      properties = new Hashtable<String, Object>(7);
    Dictionary<String, String> headers = context.getBundle().getHeaders();
    properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR));
    if (setRanking) {
      properties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MAX_VALUE));
    }
    properties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$
    registrations.add(context.registerService(serviceClass, service, properties));
  }
}

代码示例来源:origin: xalan/xalan

final QName name = new QName(namespace, prefix, localname);
_namespaces.put(namespace, space = new Hashtable());
space.put(lexicalQName, name);
return name;
  QName name = (QName)space.get(lexicalQName);
  space.put(lexicalQName, name);

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.contenthub.store.solr

private void registerEnhancementGraph(UriRef graphUri, MGraph enhancementGraph) {
  Dictionary<String,Object> props = new Hashtable<String,Object>();
  props.put("graph.uri", graphUri);
  props.put("graph.name", "Enhancement Graph");
  props.put("graph.description",
    "This graph stores enhancements of all content items stored within Contenthub.");
  props.put(org.osgi.framework.Constants.SERVICE_RANKING, Integer.MAX_VALUE);
  enhancementGraphRegistry = bundleContext.registerService(TripleCollection.class.getName(),
    enhancementGraph, props);
  log.debug("Enhancement graph is registered to the OSGi environment");
}

代码示例来源:origin: org.eclipse/osgi

private ServiceRegistration<?> registerPerformanceLog(BundleContext context) {
  Object service = createPerformanceLog(context.getBundle());
  String serviceName = FrameworkLog.class.getName();
  Dictionary<String, Object> serviceProperties = new Hashtable<String, Object>(7);
  Dictionary<String, String> headers = context.getBundle().getHeaders();
  serviceProperties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR));
  serviceProperties.put(Constants.SERVICE_RANKING, new Integer(Integer.MIN_VALUE));
  serviceProperties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + '.' + service.getClass().getName());
  serviceProperties.put(FrameworkLog.SERVICE_PERFORMANCE, Boolean.TRUE.toString());
  return context.registerService(serviceName, service, serviceProperties);
}

代码示例来源:origin: joyoyao/superCleanMaster

sListViewItemHeights.put(lv.getFirstVisiblePosition(), c.getHeight());
  if (sListViewItemHeights.get(i) != null) // (this is a sanity check)
    scrollY += sListViewItemHeights.get(i); //add all heights of the views that are gone

代码示例来源:origin: de.dentrassi.eclipse.neoscada.core/org.eclipse.scada.ae.server.injector

public synchronized void start () throws Exception
{
  final BundleContext context = FrameworkUtil.getBundle ( EventInjectorManager.class ).getBundleContext ();
  this.impl = new EventInjectorImpl ( context, this.evaluator );
  final Dictionary<String, Object> properties = new Hashtable<> ();
  properties.put ( Constants.SERVICE_DESCRIPTION, "Event injector manager" );
  properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
  properties.put ( "osgi.command.scope", "ein" );
  properties.put ( "osgi.command.function", new String[] { "rules", "state" } );
  properties.put ( ConfigurationAdministrator.FACTORY_ID, "org.eclipse.scada.ae.server.injector" );
  context.registerService ( ConfigurationFactory.class, this.impl, properties );
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi

private ServiceRegistration<?> registerPerformanceLog(BundleContext context) {
  Object service = createPerformanceLog(context.getBundle());
  String serviceName = FrameworkLog.class.getName();
  Dictionary<String, Object> serviceProperties = new Hashtable<>(7);
  Dictionary<String, String> headers = context.getBundle().getHeaders();
  serviceProperties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR));
  serviceProperties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MIN_VALUE));
  serviceProperties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + '.' + service.getClass().getName());
  serviceProperties.put(FrameworkLog.SERVICE_PERFORMANCE, Boolean.TRUE.toString());
  return context.registerService(serviceName, service, serviceProperties);
}

相关文章

微信公众号

最新文章

更多