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


Java LinkedHashMap.put方法代码示例

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


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

示例1: locateRoutes

import java.util.LinkedHashMap; //导入方法依赖的package包/类
@Override
protected LinkedHashMap<String, ZuulRoute> locateRoutes() {
    LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<String, ZuulRoute>();
    //从application.properties中加载路由信息
    routesMap.putAll(super.locateRoutes());
    //从db中加载路由信息
    routesMap.putAll(locateRoutesFromDB());
    //优化一下配置
    LinkedHashMap<String, ZuulRoute> values = new LinkedHashMap<>();
    for (Map.Entry<String, ZuulRoute> entry : routesMap.entrySet()) {
        String path = entry.getKey();
        // Prepend with slash if not already present.
        if (!path.startsWith("/")) {
            path = "/" + path;
        }
        if (StringUtils.hasText(this.properties.getPrefix())) {
            path = this.properties.getPrefix() + path;
            if (!path.startsWith("/")) {
                path = "/" + path;
            }
        }
        values.put(path, entry.getValue());
    }
    return values;
}
 
开发者ID:xiaomin0322,项目名称:zuul-gateway,代码行数:26,代码来源:CustomRouteLocator.java

示例2: getIndicesForQuery

import java.util.LinkedHashMap; //导入方法依赖的package包/类
public static LinkedHashMap<Integer, Integer> getIndicesForQuery(final String str,
                                                                 final String query) {
    final LinkedHashMap<Integer, Integer> indices = new LinkedHashMap<>();

    final int start = org.apache.commons.lang3.StringUtils.indexOfIgnoreCase(str, query);
    final int length = query.length();

    indices.put(start, start + length);

    int i = start + 1;

    while ((i = org.apache.commons.lang3.StringUtils.indexOfIgnoreCase(str, query, i)) > 0) {
        indices.put(i, i + length);
        i += length;
    }

    return indices;
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:19,代码来源:SearchUtils.java

示例3: readGroupedEntryMap

import java.util.LinkedHashMap; //导入方法依赖的package包/类
protected static <T extends GroupedBiomeEntry> void readGroupedEntryMap(JsonObject o, LinkedHashMap<String, T> list, Class<T> clazz) {
    for(Map.Entry<String, JsonElement> entry : o.entrySet()) {
        EnumBiomeCategory category = EnumBiomeCategory.get(entry.getKey());
        if (category == null) { continue; }
        JsonObject cgroups = JsonUtil.asObject(entry.getValue());

        for (Map.Entry<String, JsonElement> groupentry : cgroups.entrySet()) {
            String group = groupentry.getKey();
            JsonArray gbiomes = JsonUtil.asArray(groupentry.getValue());

            for (JsonElement biome : gbiomes) {
                T bd = IJsonable.create(clazz);
                if(bd == null) { return; }
                bd.fromJson(JsonUtil.asObject(biome));
                bd.category = category;
                bd.group = group;
                list.put(bd.getMapKey(), bd);
            }
        }
    }
}
 
开发者ID:stuebz88,项目名称:modName,代码行数:22,代码来源:BiomeSettings.java

示例4: serverBootStrapWithOptionsTest

import java.util.LinkedHashMap; //导入方法依赖的package包/类
@Test
public void serverBootStrapWithOptionsTest() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
	LinkedHashMap<String, Object> channelHandlerOptions = new LinkedHashMap<String, Object>();
	
	channelHandlerOptions.put("lineFrame", new LineBasedFrameDecoder(2000));
	channelHandlerOptions.put("decoder", new StringDecoder());
	channelHandlerOptions.put("encoder", new StringEncoder());
	channelHandlerOptions.put("handler", new ChannelInboundHandlerAdapter() {
		
		@Override
		public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
			log.info("Message Received and forward to ConsumerProcessor. Msg -> {}", msg);
		}
	});
	
	Server server = BootStrap.builder()
			.port(5252)
			.options(channelHandlerOptions)
			.messageConsumer(msg -> log.info(msg))
			.build();
	
	assertNotNull(server);
}
 
开发者ID:Creativesource-Sys,项目名称:jfast,代码行数:24,代码来源:ServerTest.java

示例5: test_LinkedHashMap

import java.util.LinkedHashMap; //导入方法依赖的package包/类
@Test
public void test_LinkedHashMap() throws Exception {
    LinkedHashMap<String, String> data = new LinkedHashMap<String, String>();
    data.put("1", "a");
    data.put("2", "b");

    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    Object read = deserialize.readObject();
    assertTrue(read instanceof LinkedHashMap);
    @SuppressWarnings("unchecked")
    String key1 = ((LinkedHashMap<String, String>)read).entrySet().iterator().next().getKey();
    assertEquals("1", key1);
    
    assertEquals(data, read);

    try {
        deserialize.readObject();
        fail();
    } catch (IOException expected) {
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:29,代码来源:AbstractSerializationTest.java

示例6: actualAdapterWithTableNotToAdapt

import java.util.LinkedHashMap; //导入方法依赖的package包/类
@Test
public void actualAdapterWithTableNotToAdapt()
{
    this.verifier.starting(this.description.get());
    LinkedHashMap<String, VerifiableTable> tableMap = new LinkedHashMap<>();
    tableMap.put("table1", TableTestUtils.ACTUAL);
    tableMap.put("table2", TableTestUtils.ACTUAL_2);
    this.verifier.withActualAdapter(ACTUAL_ADAPTER).withTablesNotToAdapt("table1")
            .verify(tableMap);
    this.verifier.succeeded(this.description.get());
}
 
开发者ID:goldmansachs,项目名称:tablasco,代码行数:12,代码来源:TableVerifierTest.java

示例7: getValues

import java.util.LinkedHashMap; //导入方法依赖的package包/类
public Map<String, Serializable> getValues()
{
    LinkedHashMap<String, Serializable> answer = new LinkedHashMap<String, Serializable>();
    for (String column : resultSet.getMetaData().getColumnNames())
    {
        answer.put(column, getValue(column));
    }
    return answer;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:CMISResultSetRow.java

示例8: testGetAllTwoProfilesFromSessionAndRequest

import java.util.LinkedHashMap; //导入方法依赖的package包/类
@Test
public void testGetAllTwoProfilesFromSessionAndRequest() {
    profiles.put(CLIENT1, PROFILE1);
    context.setRequestAttribute(Pac4jConstants.USER_PROFILES, profiles);
    final LinkedHashMap<String, CommonProfile> profiles2 = new LinkedHashMap<>();
    profiles2.put(CLIENT2, PROFILE2);
    context.setSessionAttribute(Pac4jConstants.USER_PROFILES, profiles2);
    assertEquals(PROFILE1, profileManager.getAll(true).get(0));
    assertEquals(PROFILE2, profileManager.getAll(true).get(1));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:ProfileManagerTests.java

示例9: putOrAdd

import java.util.LinkedHashMap; //导入方法依赖的package包/类
protected static final void putOrAdd(LinkedHashMap<String, Object> map, LinkedList<Object> list, String name,
		Object value) {
	if (map == null) {
		list.add(value);
	} else {
		map.put(name, value);
	}
}
 
开发者ID:berkesa,项目名称:datatree-adapters,代码行数:9,代码来源:XmlBuiltin.java

示例10: getResults

import java.util.LinkedHashMap; //导入方法依赖的package包/类
public LinkedHashMap<String, String> getResults() {
    LinkedHashMap<String, String> results = new LinkedHashMap<>();
    for (int i = 0; i < mCommands.length(); i++) {
        try {
            JSONObject command = mCommands.getJSONObject(i);
            results.put(command.getString("path"), command.getString("command"));
        } catch (JSONException ignored) {
        }
    }
    return results;
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:12,代码来源:ImportProfile.java

示例11: sortHashMapByValues

import java.util.LinkedHashMap; //导入方法依赖的package包/类
/**
 * Sorts LinkedHashMap by its values(natural descending order). keeps the
 * duplicates as it is.
 *
 * @param passedMap
 *          An Object of type LinkedHashMap to be sorted by its values.
 *
 * @return An Object containing the sorted LinkedHashMap.
 */
private LinkedHashMap<String,String> sortHashMapByValues(LinkedHashMap<String,String> passedMap) {
    List<String> mapKeys = new ArrayList<String>(passedMap.keySet());
    List<String> mapValues = new ArrayList<String>(passedMap.values());

    Collections.sort(mapValues, new ValueComparator());
    Collections.sort(mapKeys);
    Collections.reverse(mapValues);
    LinkedHashMap<String,String> sortedMap = new LinkedHashMap<String,String>();

    Iterator<String> valueIt = mapValues.iterator();
    while (valueIt.hasNext()) {
      String val = valueIt.next();
      Iterator<String> keyIt = mapKeys.iterator();
      while (keyIt.hasNext()) {
        String key = keyIt.next();
        String comp1 = passedMap.get(key).toString();
        String comp2 = val.toString();

        if (comp1.equals(comp2)) {
          passedMap.remove(key);
          mapKeys.remove(key);
          sortedMap.put(key, val);
          break;
        }
      }
    }
    return sortedMap;
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:38,代码来源:PRTimeReporter.java

示例12: weeklyAdjusted

import java.util.LinkedHashMap; //导入方法依赖的package包/类
public LinkedHashMap<LocalDate, Stock> weeklyAdjusted(String symbol, HashMap<String, String> options) throws UnsupportedEncodingException, InvalidApiKeyException, InvalidFunctionOptionException, MalFormattedFunctionException, MissingApiKeyException, UltraHighFrequencyRequestException {
    String function = "TIME_SERIES_WEEKLY_ADJUSTED";
    String queryString = ALPHA_VANTAGE_API_URL + "function=" + function + "&symbol=" + symbol + "&apikey=" + apiKey + "&";
    String encodedUrl = options.keySet().stream().map(key -> {
        try {
            return key + "=" + UriUtils.encode(options.get(key), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }).collect(joining("&", queryString, ""));

    LinkedHashMap<LocalDate, Stock> result = new LinkedHashMap<>();
    JsonNode jsonNode = restTemplate.getForObject(encodedUrl, JsonNode.class);
    Iterator<Map.Entry<String, JsonNode>> it = jsonNode.fields();
    while (it.hasNext()) {
        Map.Entry<String, JsonNode> mapEntry = it.next();
        ExceptionUtil.handleException(mapEntry, function);
        if (mapEntry.getKey().equals("Weekly Adjusted Time Series")) {
            JsonNode node = mapEntry.getValue();
            Iterator<Map.Entry<String, JsonNode>> timeSeriesIter = node.fields();
            while (timeSeriesIter.hasNext()) {
                Map.Entry<String, JsonNode> timeSeriesMap = timeSeriesIter.next();
                LocalDate localDate = LocalDate.parse(timeSeriesMap.getKey(), DateTimeFormatter.ISO_LOCAL_DATE);
                String open = String.valueOf(timeSeriesMap.getValue().get("1. open")).replaceAll("\"", "");
                String high = String.valueOf(timeSeriesMap.getValue().get("2. high")).replaceAll("\"", "");
                String low = String.valueOf(timeSeriesMap.getValue().get("3. low")).replaceAll("\"", "");
                String close = String.valueOf(timeSeriesMap.getValue().get("4. close")).replaceAll("\"", "");
                String volume = String.valueOf(timeSeriesMap.getValue().get("5. volume")).replaceAll("\"", "");
                result.put(localDate, Stock.newStpckInstance(symbol, open, high, low, close, volume));
            }

        }
    }
    return result;
}
 
开发者ID:cautiontowind,项目名称:alpha-vantage,代码行数:37,代码来源:StockTemplate.java

示例13: getUrlParameters

import java.util.LinkedHashMap; //导入方法依赖的package包/类
protected LinkedHashMap<String, String> getUrlParameters(Chain chain) {
    final HttpUrl url = chain.request().url();
    int size = url.querySize();
    final LinkedHashMap<String, String> params = new LinkedHashMap<>();
    for (int i = 0; i < size; i++) {
        params.put(url.queryParameterName(i), url.queryParameterValue(i));
    }
    return params;
}
 
开发者ID:QuincySx,项目名称:AvenueNet,代码行数:10,代码来源:BaseInterceptor.java

示例14: organizeEntries

import java.util.LinkedHashMap; //导入方法依赖的package包/类
/**
 * Organizes the valid data extracted from the log entries into LinkedHashMap.
 *
 * @param store
 *          A global LinkedHashMap containing the processing elements (with
 *          time in milliseconds) in hierarchical structure.
 * @param matchedPR
 *          A PR matching the given search string.
 * @param bTime
 *          Time taken by the specific processing element.
 * @param docName
 *          Name of the document being processed.
 */
@SuppressWarnings("unchecked")
private void organizeEntries(LinkedHashMap<String, Object> store,
                             String matchedPR, String bTime, String docName) {
  allDocs.add(docName);
  if (store.containsKey(matchedPR)) {
    ((LinkedHashMap<String, Object>) store.get(matchedPR))
        .put(docName, bTime);
  } else {
    LinkedHashMap<String, Object> tempLHM = new LinkedHashMap<String, Object>();
    tempLHM.put(docName, bTime);
    store.put(matchedPR, tempLHM);
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:27,代码来源:DocTimeReporter.java

示例15: asMap

import java.util.LinkedHashMap; //导入方法依赖的package包/类
/**
 * Returns a newly created LinkedHashMap mapping each key to its
 * corresponding value, in the given order.
 */
public static <K, V> LinkedHashMap<K,V> asMap(K[] keys, V... values) {
	LinkedHashMap<K,V> ans = new LinkedHashMap<K,V>();
	for (int i = 0; i < keys.length && i < values.length; i++)
		ans.put(keys[i], values[i]);
	return ans;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:11,代码来源:Util.java


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