Tabnine Logo
Dictionary
Code IndexAdd Tabnine to your IDE (free)

How to use
Dictionary
in
java.util

Best Java code snippets using java.util.Dictionary (Showing top 20 results out of 11,043)

Refine searchRefine arrow

  • Bundle
  • BundleContext
  • Enumeration
  • ComponentContext
  • ConfigurationAdmin
  • Configuration
  • Activate
  • ConfigurationException
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.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.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: 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.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/felix

  public void deleteProperty(String key) throws Exception{
        Dictionary dic = configuration.getProperties();
        Enumeration keys = dic.keys();
        while (keys.hasMoreElements()) {
          String k = (String) keys.nextElement();
          if (k.equals(key)) {
            dic.remove(k);
              configuration.update(dic);
          }
        }
      }
}
origin: spring-projects/spring-roo

/**
 * Method to populate current Repositories using OSGi Service
 * @throws Exception 
 */
private void populateRepositories() throws Exception {
 // Cleaning Repositories
 repositories.clear();
 // Validating that RepositoryAdmin exists
 Validate.notNull(getRepositoryAdmin(), "RepositoryAdmin not found");
 // Checking if exists installed Repos and adding to repositories
 Enumeration persistedRepos = installedRepos.keys();
 while (persistedRepos.hasMoreElements()) {
  String repositoryURL = (String) persistedRepos.nextElement();
  // Checking if is a valid URL
  if (repositoryURL.startsWith("http") || repositoryURL.startsWith("file")) {
   // Installing persisted repositories 
   getRepositoryAdmin().addRepository(repositoryURL);
  }
 }
 for (Repository repo : getRepositoryAdmin().listRepositories()) {
  repositories.add(repo);
 }
}
origin: org.apache.geronimo.plugins/console-base-portlets

private static boolean checkBlueprintBundle(Bundle bundle){
  // OSGi enterprise spec(r4.2) 121.3.4 (Page 206)
  // check blueprint header
  Object bpHeader = bundle.getHeaders().get(BundleUtil.BLUEPRINT_HEADER);
  if (bpHeader!=null && (String)bpHeader!="") return true;
  
  // check blueprint definitions
  Enumeration<URL> enu = bundle.findEntries("OSGI-INF/blueprint/", "*.xml", false);
  if (enu!=null && enu.hasMoreElements()) return true;
  return false;
}

origin: org.apache.sling/org.apache.sling.hc.core

@Activate
protected void activate(final ComponentContext ctx) {
  bundleContext = ctx.getBundleContext();
  componentContext = ctx;
  healthCheckFilter = new HealthCheckFilter(bundleContext);
  final Dictionary properties = ctx.getProperties();
  filterTags = PropertiesUtil.toStringArray(properties.get(PROP_FILTER_TAGS), new String[] {});
  combineTagsWithOr = PropertiesUtil.toBoolean(properties.get(PROP_COMBINE_TAGS_WITH_OR), DEFAULT_COMBINE_TAGS_WITH_OR);
  log.debug("Activated, will select HealthCheck having tags {} {}", Arrays.asList(filterTags), combineTagsWithOr ? "using OR" : "using AND");
}
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: Adobe-Consulting-Services/acs-aem-commons

@Activate
@SuppressWarnings("squid:S1149")
protected final void activate(ComponentContext context) throws Exception {
  Dictionary<?, ?> properties = context.getProperties();
  doActivate(context);
  String[] filters = PropertiesUtil.toStringArray(properties.get(PROP_FILTER_PATTERN));
  if (filters == null || filters.length == 0) {
    throw new ConfigurationException(PROP_FILTER_PATTERN, "At least one filter pattern must be specified.");
  }
  for (String pattern : filters) {
    Dictionary<String, String> filterProps = new Hashtable<String, String>();
    log.debug("Adding filter ({}) to pattern: {}", this.toString(), pattern);
    filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_REGEX, pattern);
    filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=*)");
    ServiceRegistration filterReg = context.getBundleContext().registerService(Filter.class.getName(), this, filterProps);
    filterRegistrations.add(filterReg);
  }
}
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: Adobe-Consulting-Services/acs-aem-commons

@SuppressWarnings("squid:S1149")
protected final void registerAsSlingFilter(ComponentContext ctx, int ranking, String pattern) {
  Dictionary<String, String> filterProps = new Hashtable<String, String>();
  filterProps.put("service.ranking", String.valueOf(ranking));
  filterProps.put("sling.filter.scope", "REQUEST");
  filterProps.put("sling.filter.pattern", StringUtils.defaultIfEmpty(pattern, ".*"));
  filterRegistration = ctx.getBundleContext().registerService(Filter.class.getName(), this, filterProps);
}
origin: spring-projects/spring-roo

public void start(final BundleContext context) throws Exception {
 startLevelServiceReference = context.getServiceReference(StartLevel.class.getName());
 startLevel = (StartLevel) context.getService(startLevelServiceReference);
 for (final Bundle bundle : context.getBundles()) {
  final String value = bundle.getHeaders().get("Service-Component");
  if (value != null) {
   List<String> componentDescriptions = Arrays.asList(value.split("\\s*,\\s*"));
   for (String desc : componentDescriptions) {
    final URL url = bundle.getResource(desc);
    process(url);
origin: apache/ignite

Class<?> cls = null;
Bundle[] bundles = bundle.getBundleContext().getBundles();
  if (b.getState() <= Bundle.RESOLVED || b.getHeaders().get(Constants.FRAGMENT_HOST) != null)
    continue;
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/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: opencast/opencast

/**
 * Check the existence of the given dictionary. Throw an exception if null.
 */
public static void checkDictionary(Dictionary properties, ComponentContext componentContext)
    throws ConfigurationException {
 if (properties == null) {
  String dicName = componentContext.getProperties().get("service.pid").toString();
  throw new ConfigurationException("*", "Dictionary for " + dicName + " does not exist");
 }
}
origin: org.apache.sling/org.apache.sling.junit.core

protected void activate(ComponentContext ctx) {
  bundleContext = ctx.getBundleContext();
  bundleContext.addBundleListener(this);
  
  // Initially consider all bundles as "changed"
  for(Bundle b : bundleContext.getBundles()) {
    if(getSlingTestRegexp(b) != null) {
      changedBundles.add(b.getSymbolicName());
      log.debug("Will look for test classes inside bundle {}", b.getSymbolicName());
    }
  }
  
  lastModified = System.currentTimeMillis();
  pid = (String)ctx.getProperties().get(Constants.SERVICE_PID);
}

origin: rhuss/jolokia

private String getConfigurationFromConfigAdmin(ConfigKey pkey) {
  ConfigurationAdmin configAdmin = (ConfigurationAdmin) configAdminTracker.getService();
  if (configAdmin == null) {
    return null;
  }
  try {
    Configuration config = configAdmin.getConfiguration(CONFIG_ADMIN_PID);
    if (config == null) {
      return null;
    }
    Dictionary<?, ?> props = config.getProperties();
    if (props == null) {
      return null;
    }
    return (String) props.get(CONFIG_PREFIX + "." + pkey.getKeyValue());
  } catch (IOException e) {
    return null;
  }
}
java.utilDictionary

Javadoc

Note: Do not use this class since it is obsolete. Please use the Map interface for new implementations.

Dictionary is an abstract class which is the superclass of all classes that associate keys with values, such as Hashtable.

Most used methods

  • get
    Returns the value to which the key is mapped in this dictionary. The general contract for the isEmpt
  • put
    Maps the specified key to the specifiedvalue in this dictionary. Neither the key nor the value can b
  • keys
    Returns an enumeration of the keys in this dictionary. The general contract for the keys method is t
  • size
    Returns the number of entries (dinstint keys) in this dictionary.
  • remove
    Removes the key (and its correspondingvalue) from this dictionary. This method does nothing if the k
  • isEmpty
    Tests if this dictionary maps no keys to value. The general contract for the isEmpty method is that
  • elements
    Returns an enumeration of the values in this dictionary. The general contract for the elements metho
  • <init>
    Sole constructor. (For invocation by subclass constructors, typically implicit.)
  • Add

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • getApplicationContext (Context)
  • getSharedPreferences (Context)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now