java.util.Hashtable.entrySet()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(204)

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

Hashtable.entrySet介绍

[英]Returns a set of the mappings contained in this Hashtable. Each element in the set is a Map.Entry. The set is backed by this Hashtable so changes to one are reflected by the other. The set does not support adding.
[中]返回此哈希表中包含的一组映射。集合中的每个元素都是一个映射。进入该集合由该哈希表支持,因此对其中一个的更改将由另一个反映出来。集合不支持添加。

代码示例

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

private void assertHasVisitedAllNodesInTree(Hashtable<CaseInsensitiveString, CycleState> state) {
  for (Map.Entry<CaseInsensitiveString, CycleState> cycleStateEntry : state.entrySet()) {
    if (cycleStateEntry.getValue() == CycleState.VISITING) {
      throw ExceptionUtils.bomb("Unexpected node in visiting state: " + cycleStateEntry.getKey());
    }
  }
}

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

protected void createTopics(Map<String, Object> data, Hashtable environment) {
  for (Iterator iter = environment.entrySet().iterator(); iter.hasNext();) {
    Map.Entry entry = (Map.Entry)iter.next();
    String key = entry.getKey().toString();
    if (key.startsWith(topicPrefix)) {
      String jndiName = key.substring(topicPrefix.length());
      data.put(jndiName, createTopic(entry.getValue().toString()));
    }
  }
}

代码示例来源:origin: sc.fiji/TrakEM2_

synchronized static public Project getActive() {
  synchronized (LOCK) {
    if (null == tabs || 0 == ht_projects.size()) return null;
    if (1 == ht_projects.size()) return (Project)ht_projects.keySet().iterator().next();
    else {
      Component c = tabs.getSelectedComponent();
      for (final Map.Entry<Project,JSplitPane> e : ht_projects.entrySet()) {
        if (e.getValue().equals(c)) return e.getKey();
      }
    }
    return null;
  }
}

代码示例来源:origin: scouter-project/scouter

public String toString() {
  StringBuffer buf = new StringBuffer();
  Iterator en = table.entrySet().iterator();
  buf.append("{");
  while (en.hasNext()) {
    if (buf.length() > 1) {
      buf.append(",");
    }
    Map.Entry e = (Map.Entry) en.next();
    buf.append(e.getKey() + "=" + e.getValue());
  }
  buf.append("}");
  return buf.toString();
}

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

private CaseInsensitiveString downstreamOf(Hashtable<CaseInsensitiveString, Node> pipelineToUpstream, final CaseInsensitiveString pipelineName) {
  for (Map.Entry<CaseInsensitiveString, Node> entry : pipelineToUpstream.entrySet()) {
    if (entry.getValue().hasDependency(pipelineName)) {
      return entry.getKey();
    }
  }
  return null;
}

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

protected void createQueues(Map<String, Object> data, Hashtable environment) {
  for (Iterator iter = environment.entrySet().iterator(); iter.hasNext();) {
    Map.Entry entry = (Map.Entry)iter.next();
    String key = entry.getKey().toString();
    if (key.startsWith(queuePrefix)) {
      String jndiName = key.substring(queuePrefix.length());
      data.put(jndiName, createQueue(entry.getValue().toString()));
    }
  }
}

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

@Override public synchronized int hashCode() {
  int result = 0;
  for (Entry<K, V> e : entrySet()) {
    K key = e.getKey();
    V value = e.getValue();
    if (key == this || value == this) {
      continue;
    }
    result += (key != null ? key.hashCode() : 0)
        ^ (value != null ? value.hashCode() : 0);
  }
  return result;
}

代码示例来源:origin: scouter-project/scouter

public String toString() {
  StringBuffer buf = new StringBuffer();
  Iterator en = table.entrySet().iterator();
  buf.append("{");
  while (en.hasNext()) {
    if (buf.length() > 1) {
      buf.append(",");
    }
    Map.Entry e = (Map.Entry) en.next();
    buf.append(e.getKey() + "=" + e.getValue());
  }
  buf.append("}");
  return buf.toString();
}

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

protected void createTopics(Map<String, Object> data, Hashtable<?, ?> environment) {
 for (Map.Entry<?, ?> entry : environment.entrySet()) {
   String key = entry.getKey().toString();
   if (key.startsWith(topicPrefix)) {
    String jndiName = key.substring(topicPrefix.length());
    data.put(jndiName, createTopic(entry.getValue().toString()));
   }
 }
}

代码示例来源:origin: scouter-project/scouter

public String toString() {
  StringBuffer buf = new StringBuffer();
  Iterator en = table.entrySet().iterator();
  buf.append("{");
  while (en.hasNext()) {
    if (buf.length() > 1) {
      buf.append(",");
    }
    Map.Entry e = (Map.Entry) en.next();
    buf.append(e.getKey() + "=" + e.getValue());
  }
  buf.append("}");
  return buf.toString();
}

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

protected void createQueues(Map<String, Object> data, Hashtable<?, ?> environment) {
 for (Map.Entry<?, ?> entry : environment.entrySet()) {
   String key = entry.getKey().toString();
   if (key.startsWith(queuePrefix)) {
    String jndiName = key.substring(queuePrefix.length());
    data.put(jndiName, createQueue(entry.getValue().toString()));
   }
 }
}

代码示例来源:origin: scouter-project/scouter

public String toString() {
  StringBuffer buf = new StringBuffer();
  Iterator en = table.entrySet().iterator();
  buf.append("{");
  while (en.hasNext()) {
    if (buf.length() > 1) {
      buf.append(",");
    }
    Map.Entry e = (Map.Entry) en.next();
    buf.append(e.getKey() + "=" + e.getValue());
  }
  buf.append("}");
  return buf.toString();
}

代码示例来源:origin: jenkinsci/jenkins

@Exported(name="usage")
public @Nonnull List<RangeItem> _getUsages() {
  List<RangeItem> r = new ArrayList<RangeItem>();
  final Jenkins instance = Jenkins.getInstance();
  for (Entry<String, RangeSet> e : usages.entrySet()) {
    final String itemName = e.getKey();
    if (instance.hasPermission(Jenkins.ADMINISTER) || canDiscoverItem(itemName)) {
      r.add(new RangeItem(itemName, e.getValue()));
    }
  }
  return r;
}

代码示例来源:origin: scouter-project/scouter

public String toString() {
  StringBuffer buf = new StringBuffer();
  Iterator en = table.entrySet().iterator();
  buf.append("{");
  while (en.hasNext()) {
    if (buf.length() > 1) {
      buf.append(",");
    }
    Map.Entry e = (Map.Entry) en.next();
    buf.append(e.getKey() + "=" + e.getValue());
  }
  buf.append("}");
  return buf.toString();
}

代码示例来源:origin: org.apache.ant/ant

/**
   * Get all the attributes in the ant-attribute:param
   * namespace and place them in a map.
   * @param el the element this attribute is in.
   * @return a map of attributes.
   */
  protected Map<String, String> getParams(UnknownElement el) {
    // this makes a copy!
    return el.getWrapper().getAttributeMap().entrySet().stream()
        .filter(e -> e.getKey().startsWith("ant-attribute:param"))
        .collect(Collectors.toMap(e -> e.getKey().substring(e.getKey().lastIndexOf(':') + 1),
            e -> el.getProject().replaceProperties((String) e.getValue()), (a, b) -> b));
  }
}

代码示例来源:origin: commons-logging/commons-logging

/**
 *@see Hashtable
 */
public Set entrySet() {
  purge();
  Set referencedEntries = super.entrySet();
  Set unreferencedEntries = new HashSet();
  for (Iterator it=referencedEntries.iterator(); it.hasNext();) {
    Map.Entry entry = (Map.Entry) it.next();
    Referenced referencedKey = (Referenced) entry.getKey();
    Object key = referencedKey.getValue();
    Object value = entry.getValue();
    if (key != null) {
      Entry dereferencedEntry = new Entry(key, value);
      unreferencedEntries.add(dereferencedEntry);
    }
  }
  return unreferencedEntries;
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Copies all user properties that have been set on the command
 * line or a GUI tool from this instance to the Project instance
 * given as the argument.
 *
 * <p>To copy all "user" properties, you will also have to call
 * {@link #copyInheritedProperties copyInheritedProperties}.</p>
 *
 * <p>Does not copy properties held by implementations of
 * delegates (like local properties).</p>
 *
 * @param other the project to copy the properties to.  Must not be null.
 *
 * @since Ant 1.6
 */
public void copyUserProperties(Project other) {
  //avoid concurrent modification:
  synchronized (userProperties) {
    for (Map.Entry<String, Object> entry : userProperties.entrySet()) {
      String arg = entry.getKey();
      if (!inheritedProperties.containsKey(arg)) {
        other.setUserProperty(arg, entry.getValue().toString());
      }
    }
  }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

private void cleanupCalls() {
  Iterator<Entry<Integer, Call>> itor = calls.entrySet().iterator() ;
  while (itor.hasNext()) {
   Call c = itor.next().getValue(); 
   itor.remove();
   c.setException(closeException); // local exception
  }
 }
}

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

private synchronized void writeObject(ObjectOutputStream stream)
    throws IOException {
  // Emulate loadFactor field for other implementations to read
  ObjectOutputStream.PutField fields = stream.putFields();
  fields.put("threshold",  (int) (DEFAULT_LOAD_FACTOR * table.length));
  fields.put("loadFactor", DEFAULT_LOAD_FACTOR);
  stream.writeFields();
  stream.writeInt(table.length); // Capacity
  stream.writeInt(size);
  for (Entry<K, V> e : entrySet()) {
    stream.writeObject(e.getKey());
    stream.writeObject(e.getValue());
  }
}

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

protected ActiveMQConnectionFactory createConnectionFactory(String name, Hashtable environment) throws URISyntaxException {
  Hashtable temp = new Hashtable(environment);
  if (DEFAULT_CONNECTION_FACTORY_NAMES[1].equals(name)) {
    // don't try to mod environment, it may be readonly
    temp.put("xa", String.valueOf(true));
  }
  String prefix = connectionPrefix + name + ".";
  for (Iterator iter = environment.entrySet().iterator(); iter.hasNext();) {
    Map.Entry entry = (Map.Entry)iter.next();
    String key = (String)entry.getKey();
    if (key.startsWith(prefix)) {
      // Rename the key...
      temp.remove(key);
      key = key.substring(prefix.length());
      temp.put(key, entry.getValue());
    }
  }
  return createConnectionFactory(temp);
}

相关文章