当前位置: 首页>>代码示例>>Java>>正文


Java Map.entrySet方法代码示例

本文整理汇总了Java中java.util.Map.entrySet方法的典型用法代码示例。如果您正苦于以下问题:Java Map.entrySet方法的具体用法?Java Map.entrySet怎么用?Java Map.entrySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Map的用法示例。


在下文中一共展示了Map.entrySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEntrySetSetValue

import java.util.Map; //导入方法依赖的package包/类
public void testEntrySetSetValue() {
  // TODO: Investigate the extent to which, in practice, maps that support
  // put() also support Entry.setValue().
  if (!supportsPut) {
    return;
  }

  final Map<K, V> map;
  final V valueToSet;
  try {
    map = makePopulatedMap();
    valueToSet = getValueNotInPopulatedMap();
  } catch (UnsupportedOperationException e) {
    return;
  }

  Set<Entry<K, V>> entrySet = map.entrySet();
  Entry<K, V> entry = entrySet.iterator().next();
  final V oldValue = entry.getValue();
  final V returnedValue = entry.setValue(valueToSet);
  assertEquals(oldValue, returnedValue);
  assertTrue(entrySet.contains(mapEntry(entry.getKey(), valueToSet)));
  assertEquals(valueToSet, map.get(entry.getKey()));
  assertInvariants(map);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:26,代码来源:MapInterfaceTest.java

示例2: write

import java.util.Map; //导入方法依赖的package包/类
public void write(final ByteArrayData buffer , final Object obj ) throws IOException{
  if( ! ( obj instanceof Map ) ){
    return;
  }
  Map<Object,Object> mapObj = (Map<Object,Object>)obj;
  int i = 0;
  for( Map.Entry<Object,Object> entry : mapObj.entrySet() ){
    String key = entry.getKey().toString();
    ITextFormatter childFormatter = childFormatterContainer.get( key );
    if( childFormatter == null ){
      childFormatter = defaultFormatter;
    }
    if( i != 0 ){
      buffer.append( delimiter );
    }
    buffer.append( key.getBytes( "UTF-8" ) );
    buffer.append( fieldDelimiter );
    childFormatter.write( buffer , entry.getValue() );

    i++;
  }
}
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:23,代码来源:TextMapFormatter.java

示例3: getAllImage

import java.util.Map; //导入方法依赖的package包/类
/**
 * Scan the list of pictures in the library.
 */
@WorkerThread
public ArrayList<AlbumFolder> getAllImage() {
    Map<String, AlbumFolder> albumFolderMap = new HashMap<>();
    AlbumFolder allFileFolder = new AlbumFolder();
    allFileFolder.setChecked(true);
    allFileFolder.setName(mContext.getString(R.string.album_all_images));

    scanImageFile(albumFolderMap, allFileFolder);

    ArrayList<AlbumFolder> albumFolders = new ArrayList<>();
    Collections.sort(allFileFolder.getAlbumFiles());
    albumFolders.add(allFileFolder);

    for (Map.Entry<String, AlbumFolder> folderEntry : albumFolderMap.entrySet()) {
        AlbumFolder albumFolder = folderEntry.getValue();
        Collections.sort(albumFolder.getAlbumFiles());
        albumFolders.add(albumFolder);
    }
    return albumFolders;
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:24,代码来源:MediaReader.java

示例4: testBug49598

import java.util.Map; //导入方法依赖的package包/类
@Test
public void testBug49598() throws Exception {
    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    Tomcat.addServlet(ctx, "servlet", new Bug49598Servlet());
    ctx.addServletMapping("/", "servlet");

    tomcat.start();

    Map<String,List<String>> headers = new HashMap<String,List<String>>();
    getUrl("http://localhost:" + getPort() + "/", new ByteChunk(), headers);

    // Check for headers without a name
    for (Map.Entry<String,List<String>> header : headers.entrySet()) {
        if (header.getKey() == null) {
            // Expected if this is the response line
            List<String> values = header.getValue();
            if (values.size() == 1 &&
                    values.get(0).startsWith("HTTP/1.1")) {
                continue;
            }
            fail("Null header name detected for value " + values);
        }
    }

    // Check for exactly one Set-Cookie header
    int count = 0;
    for (String headerName : headers.keySet()) {
        if ("Set-Cookie".equals(headerName)) {
            count ++;
        }
    }
    assertEquals(1, count);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:39,代码来源:TestResponse.java

示例5: updateProperties

import java.util.Map; //导入方法依赖的package包/类
public static boolean updateProperties(Document doc, Map<String, String> propertyChanges) {
    Element rootElement = doc.getRootElement();
    boolean update = false;
    Element properties = DecentXmlHelper.firstChild(rootElement, "properties");
    if (properties != null) {
        for (Map.Entry<String, String> entry : propertyChanges.entrySet()) {
            String propertyName = entry.getKey();
            String propertyVersion = entry.getValue();
            if (DecentXmlHelper.updateFirstChild(properties, propertyName, propertyVersion)) {
                update = true;
            }
        }
    }
    return update;
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:16,代码来源:PomHelper.java

示例6: deserialize

import java.util.Map; //导入方法依赖的package包/类
public static ComplexTextTypeComponent deserialize(Map<String, Object> map) {
    String key = null;
    Map<String, String> value = new HashMap<String, String>();
    for (Map.Entry<String, Object> valEntry : map.entrySet()) {
        if (valEntry.getKey().equals("key")) {
            key = (String) valEntry.getValue();
        } else if (valEntry.getKey().startsWith("value.")) {
            value.put(((String) valEntry.getKey()).substring(6) /* Strips out the value prefix */, valEntry.getValue().toString());
        }
    }
    return new ComplexTextTypeComponent(key, value);
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:13,代码来源:TextualComponent.java

示例7: equalsBranches

import java.util.Map; //导入方法依赖的package包/类
private static boolean equalsBranches (Map<String, GitBranch> oldBranches, Map<String, GitBranch> newBranches) {
    boolean retval = oldBranches.size() == newBranches.size() && oldBranches.keySet().equals(newBranches.keySet());
    if (retval) {
        for (Map.Entry<String, GitBranch> e : oldBranches.entrySet()) {
            GitBranch oldBranch = e.getValue();
            GitBranch newBranch = newBranches.get(e.getKey());
            if (!oldBranch.getId().equals(newBranch.getId())
                    || !equalTracking(newBranch, oldBranch)) {
                retval = false;
                break;
            }
        }
    }
    return retval;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:RepositoryInfo.java

示例8: setMobileBrowsers

import java.util.Map; //导入方法依赖的package包/类
/**
 * Sets the map of mobile browsers.  This sets a flag on the request called "isMobile" and also
 * provides the custom flag called browserType which can be mapped into the theme.
 * <p>
 * Themes that understand isMobile should provide an alternative stylesheet.
 *
 * @param mobileOverrides the list of mobile browsers.
 */
public void setMobileBrowsers(final Map<String, String> mobileOverrides) {
    // initialize the overrides variable to an empty map
    this.overrides = new HashMap<>();

    for (final Map.Entry<String, String> entry : mobileOverrides.entrySet()) {
        this.overrides.put(Pattern.compile(entry.getKey()), entry.getValue());
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:ServiceThemeResolver.java

示例9: printMap

import java.util.Map; //导入方法依赖的package包/类
/**
 * Prints metrics data in a multi-line text form.
 */
void printMap(PrintWriter out, Map<String, Map<String, List<TagsMetricsPair>>> map) {
  for (Map.Entry<String, Map<String, List<TagsMetricsPair>>> context : map.entrySet()) {
    out.print(context.getKey());
    out.print("\n");
    for (Map.Entry<String, List<TagsMetricsPair>> record : context.getValue().entrySet()) {
      indent(out, 1);
      out.print(record.getKey());
      out.print("\n");
      for (TagsMetricsPair pair : record.getValue()) {
        indent(out, 2);
        // Prints tag values in the form "{key=value,key=value}:"
        out.print("{");
        boolean first = true;
        for (Map.Entry<String, Object> tagValue : pair.tagMap.entrySet()) {
          if (first) {
            first = false;
          } else {
            out.print(",");
          }
          out.print(tagValue.getKey());
          out.print("=");
          out.print(tagValue.getValue().toString());
        }
        out.print("}:\n");
        
        // Now print metric values, one per line
        for (Map.Entry<String, Number> metricValue : 
            pair.metricMap.entrySet()) {
          indent(out, 3);
          out.print(metricValue.getKey());
          out.print("=");
          out.print(metricValue.getValue().toString());
          out.print("\n");
        }
      }
    }
  }    
}
 
开发者ID:naver,项目名称:hadoop,代码行数:42,代码来源:MetricsServlet.java

示例10: revertNotify

import java.util.Map; //导入方法依赖的package包/类
public static Map<String, Map<String, String>> revertNotify(Map<String, Map<String, String>> notify) {
    if (notify != null && notify.size() > 0) {
        Map<String, Map<String, String>> newNotify = new HashMap<String, Map<String, String>>();
        for (Map.Entry<String, Map<String, String>> entry : notify.entrySet()) {
            String serviceName = entry.getKey();
            Map<String, String> serviceUrls = entry.getValue();
            if (!serviceName.contains(":") && !serviceName.contains("/")) {
                if (serviceUrls != null && serviceUrls.size() > 0) {
                    for (Map.Entry<String, String> entry2 : serviceUrls.entrySet()) {
                        String url = entry2.getKey();
                        String query = entry2.getValue();
                        Map<String, String> params = StringUtils.parseQueryString(query);
                        String group = params.get("group");
                        String version = params.get("version");
                        // params.remove("group");
                        // params.remove("version");
                        String name = serviceName;
                        if (group != null && group.length() > 0) {
                            name = group + "/" + name;
                        }
                        if (version != null && version.length() > 0) {
                            name = name + ":" + version;
                        }
                        Map<String, String> newUrls = newNotify.get(name);
                        if (newUrls == null) {
                            newUrls = new HashMap<String, String>();
                            newNotify.put(name, newUrls);
                        }
                        newUrls.put(url, StringUtils.toQueryString(params));
                    }
                }
            } else {
                newNotify.put(serviceName, serviceUrls);
            }
        }
        return newNotify;
    }
    return notify;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:40,代码来源:UrlUtils.java

示例11: Distribution

import java.util.Map; //导入方法依赖的package包/类
public Distribution(String name, Map<String, Integer> distribution)
{
    this.name = checkNotNull(name, "name is null");
    checkNotNull(distribution, "distribution is null");

    ImmutableList.Builder<String> values = ImmutableList.builder();
    this.weights = new int[distribution.size()];

    int runningWeight = 0;
    int index = 0;
    boolean isValidDistribution = true;
    for (Entry<String, Integer> entry : distribution.entrySet()) {
        values.add(entry.getKey());

        runningWeight += entry.getValue();
        weights[index] = runningWeight;

        isValidDistribution = isValidDistribution && entry.getValue() > 0;

        index++;
    }
    this.values = values.build();

    // "nations" is hack and not a valid distribution so we need to skip it
    if (isValidDistribution) {
        this.maxWeight = weights[weights.length - 1];
        this.distribution = new String[maxWeight];

        index = 0;
        for (String value : this.values) {
            int count = distribution.get(value);
            for (int i = 0; i < count; i++) {
                this.distribution[index++] = value;
            }
        }
    } else {
        this.maxWeight = -1;
        this.distribution = null;
    }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:41,代码来源:Distribution.java

示例12: clean

import java.util.Map; //导入方法依赖的package包/类
private void clean(Jedis jedis) {
    Set<String> keys = jedis.keys(root + Constants.ANY_VALUE);
    if (keys != null && keys.size() > 0) {
        for (String key : keys) {
            Map<String, String> values = jedis.hgetAll(key);
            if (values != null && values.size() > 0) {
                boolean delete = false;
                long now = System.currentTimeMillis();
                for (Map.Entry<String, String> entry : values.entrySet()) {
                    URL url = URL.valueOf(entry.getKey());
                    if (url.getParameter(Constants.DYNAMIC_KEY, true)) {
                        long expire = Long.parseLong(entry.getValue());
                        if (expire < now) {
                            jedis.hdel(key, entry.getKey());
                            delete = true;
                            if (logger.isWarnEnabled()) {
                                logger.warn("Delete expired key: " + key + " -> value: " + entry.getKey() + ", expire: " + new Date(expire) + ", now: " + new Date(now));
                            }
                        }
                    }
                }
                if (delete) {
                    jedis.publish(key, Constants.UNREGISTER);
                }
            }
        }
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:29,代码来源:RedisRegistry.java

示例13: unzipLibFiles

import java.util.Map; //导入方法依赖的package包/类
/**
 * unzipLibFiles
 *
 * @param zipFile  zipFile
 * @param abis     abis
 * @param libFiles libFiles
 */
private final static void unzipLibFiles(String zipFile, String[] abis, Map<String, Map<String, String>> libFiles) {
    for (int i = 0; i < abis.length; i++) {
        Map<String, String> files = libFiles.get(abis[i]);
        if (files != null && !files.isEmpty()) {
            for (Map.Entry<String, String> entry : files.entrySet()) {
                unzipSingleFile(zipFile, entry.getKey(), entry.getValue());
            }
        }
    }
}
 
开发者ID:LiangMaYong,项目名称:android-apkbox,代码行数:18,代码来源:ApkNative.java

示例14: doInBackground

import java.util.Map; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... params) {
    SharedPreferences sp = CacheHelper.getPreferences(CacheHelper.FAV);
    Map<String, ?> map = sp.getAll();
    for (Map.Entry<String, ?> entry : map.entrySet()) {
        if (entry.getValue() instanceof Integer) {
            Integer testId = (Integer) entry.getValue();
            mData.add(readTestCache(testId));
        }
    }
    return null;
}
 
开发者ID:FallenCrood,项目名称:Review-,代码行数:13,代码来源:FavListFragment.java

示例15: putAll

import java.util.Map; //导入方法依赖的package包/类
@Override
public void putAll(Map<? extends K, ? extends V> map) {
    for (Map.Entry<? extends K, ? extends V> entry: map.entrySet()) put(entry.getKey(), entry.getValue());
}
 
开发者ID:yacy,项目名称:yacy_grid_mcp,代码行数:5,代码来源:ComparableARC.java


注:本文中的java.util.Map.entrySet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。