當前位置: 首頁>>代碼示例>>Java>>正文


Java LinkedHashMap.entrySet方法代碼示例

本文整理匯總了Java中java.util.LinkedHashMap.entrySet方法的典型用法代碼示例。如果您正苦於以下問題:Java LinkedHashMap.entrySet方法的具體用法?Java LinkedHashMap.entrySet怎麽用?Java LinkedHashMap.entrySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.LinkedHashMap的用法示例。


在下文中一共展示了LinkedHashMap.entrySet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getOption

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * replacement的value為String類型時,直接根據key替換,否則轉為Json》String後再替換
 * @author ack (chenzhao)  @DATE: Aug 23, 2017 
 * @param replacement
 * @return 返回生成option字符串
 */
public  String getOption(LinkedHashMap<String, Object> replacement){
	Set<Entry<String, Object>> entrySet=replacement.entrySet();
	Iterator<Entry<String, Object>> iterator=entrySet.iterator();
	while (iterator.hasNext()) {
		Entry<String, Object>entry=(Entry<String, Object>) iterator.next();
		//如果value非String,則將value轉為json再轉為String
		String value=entry.getValue()+"";
		Object objValue=entry.getValue() ;
		if(!(objValue instanceof String)){
			if(objValue instanceof List||objValue instanceof Object[]){//如果是數組或集合
				JSONArray jsonArray=JSONArray.fromObject(objValue);
				value=jsonArray.toString();
			}else{
				JSONObject jsonObjecct=JSONObject.fromObject(entry.getValue());
				value=jsonObjecct.toString();
			}
		}
		//根據key替換Option字符串裏的字符
		chartString=chartString.replace(entry.getKey()+"", value);
	}
	return chartString;
}
 
開發者ID:pcbaby-ch,項目名稱:echarts,代碼行數:29,代碼來源:Echart.java

示例2: doneParsing

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/** Do any post-parsing processig. */
void doneParsing() {
   status = 3;
   LinkedHashMap<String,Open> copy = new LinkedHashMap<String,Open>(opens);
   opens.clear();
   for(Map.Entry<String,Open> e: copy.entrySet()) {
      String a = e.getKey();
      Open m = e.getValue();
      if (a.indexOf('$')>=0) {
         String base = m.filename;
         int i = base.lastIndexOf('/');
         if (i>=0) base = base.substring(i+1);
         if (!copy.containsKey(base) && !opens.containsKey(base)) {
            for(i=0; i<base.length(); i++) {
               char c = base.charAt(i);
               if ((c>='a' && c<='z') || (c>='A' && c<='Z')) continue;
               if (i!=0 && ((c>='0' && c<='9') || c=='_' || c=='\'' || c=='\"')) continue;
               break;
            }
            if (i>=base.length()) a = base;
         }
      }
      opens.put(a, new Open(m.pos, m.isPrivate, a, m.args, m.filename));
   }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:26,代碼來源:CompModule.java

示例3: getPieSeriesStr

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * 分析組裝echart餅圖需要的series部分String
 * @author ack (chenzhao)  @DATE: Aug 23, 2017 
 * @param varList 提示:list記錄中首字段必須是lineName
 * @return
 */
public static StringBuffer getPieSeriesStr(List<LinkedHashMap<String, Object>> varList) {
	StringBuffer seriesStr=new StringBuffer("[");
	for (int i = 0; i < varList.size(); i++) {
		LinkedHashMap<String, Object> row=varList.get(i);
		Set<Entry<String, Object>> entrySet=row.entrySet();
		Iterator<Entry<String, Object>> iter=entrySet.iterator();
		String lineStr="";
		String lineName="";
		String lineValue="";
		for (int j = 0;iter.hasNext(); j++) {//組裝一條折線數據
			Entry<String, Object> entry=iter.next();
			if(j==0){//map中一行記錄的首值
				lineName="name:'"+entry.getValue();
			}else{
				lineValue=entry.getValue()+"";
			}
			lineStr="{"+lineName+"',value:"+lineValue+"}";
		}
		if(i==varList.size()-1)
			seriesStr.append(lineStr+"]");
		else
			seriesStr.append(lineStr+",");
	}
	return seriesStr;
}
 
開發者ID:pcbaby-ch,項目名稱:echarts,代碼行數:32,代碼來源:Echart.java

示例4: main

import java.util.LinkedHashMap; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
    LinkedHashMap<String, Integer> arrows = new LinkedHashMap<String, Integer>(){{
        put(">>>----->>", 0); put(">>----->", 0); put(">----->", 0);}};

    for (int i = 0; i < 4; i++) {
        String line = reader.readLine();
        // if(line.length() < 7) continue;
        for (Map.Entry<String, Integer> arr :
                arrows.entrySet()) {
            int index = line.indexOf(arr.getKey());
            while(index > -1){
                arrows.put(arr.getKey(), arr.getValue() + 1);
                index = line.indexOf(arr.getKey(), index + arr.getKey().length());
            }
            // replace with neutral symbol, to ensure that after replacement we will not produce new arrow
            // -> nested arrows
            line = line.replaceAll(arr.getKey(), "*");
        }
    }
    long num = Long.parseLong(arrows.entrySet().stream()
        .sorted(Comparator.comparingInt(arr -> (arr.getKey().length())))
        .map(e -> e.getValue().toString()).collect(Collectors.joining("")));
    StringBuilder strNum = new StringBuilder(Long.toString(num, 2));
    strNum.append(new StringBuilder(strNum).reverse());
    System.out.println(Long.parseLong(strNum.toString(), 2));
}
 
開發者ID:kostovhg,項目名稱:SoftUni,代碼行數:27,代碼來源:p12_LittleJohn.java

示例5: convertLinkedHashMap

import java.util.LinkedHashMap; //導入方法依賴的package包/類
private static void convertLinkedHashMap(LinkedHashMap<String,?> message,LogLevel level){
    if (message!=null) {
        log(showline(), level);
        for (Map.Entry<String, ?> entry : message.entrySet()) {
            try {
                log("[MAP] : [" + entry.getKey() + "] => [" + entry.getValue() + "]", level);
            } catch (Exception e) {
                log("[MAP] : Error Key => '" + entry.getKey()+"'", LogLevel.ERROR);
            }
        }

        log(showline(), level);
    }
    else{
        log("[MAP] : Map is Null",LogLevel.WARN);
    }
}
 
開發者ID:afiqiqmal,項目名稱:EzyLogger,代碼行數:18,代碼來源:LogPrint.java

示例6: debugDoQuery

import java.util.LinkedHashMap; //導入方法依賴的package包/類
private static void debugDoQuery(String dataSource, final XulHttpServer.XulHttpServerResponse response, LinkedHashMap<String, String> queries, boolean pullMode) {
	final XulDataService xulDataService = obtainDataService();
	try {
		final QueryClause dataQuery = xulDataService.query(dataSource);

		if (queries != null) {
			for (Map.Entry<String, String> entry : queries.entrySet()) {
				dataQuery.where(entry.getKey()).is(entry.getValue());
			}
		}

		debugExecQuery(response, dataQuery, pullMode);
	} catch (Exception e) {
		e.printStackTrace(new PrintStream(response.getBodyStream()));
		response.addHeader("Content-Type", "text/plain")
			.send();
	}
}
 
開發者ID:starcor-company,項目名稱:starcor.xul,代碼行數:19,代碼來源:XulDataService.java

示例7: getBulkConflictCheckQuery

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * bulkRequestsに含まれるエンティティの一括検索用のクエリを作成する.
 * @param bulkRequests 一括検索するリクエストのリスト
 * @return 検索クエリ
 */
private Map<String, Object> getBulkConflictCheckQuery(LinkedHashMap<String, BulkRequest> bulkRequests) {
    // 検索條件のためのHash初期化
    List<Object> orList = new ArrayList<Object>();

    // データ競合確認のためのクエリを生成する
    for (Entry<String, BulkRequest> request : bulkRequests.entrySet()) {
        // エラーデータは無視する
        if (request.getValue().getError() != null) {
            continue;
        }
        // TODO スキーマ情報の主キーから生成、ユニークキーのチェック、NTKP対応
        List<Object> andList = new ArrayList<Object>();
        Map<String, Object> and = new HashMap<String, Object>();
        andList.add(QueryMapFactory.termFilter(OEntityDocHandler.KEY_STATIC_FIELDS + ".__id.untouched",
                (String) request.getValue().getDocHandler().getStaticFields().get("__id"), false));
        // タイプの指定
        andList.add(QueryMapFactory.termQuery("_type",
                request.getValue().getDocHandler().getType()));
        andList.add(QueryMapFactory.termQuery(OEntityDocHandler.KEY_ENTITY_ID,
                (String) request.getValue().getDocHandler().getEntityTypeId()));
        and.put("and", andList);
        orList.add(and);
    }
    // 対象データが存在しないとき
    if (orList.size() == 0) {
        return null;
    }

    return composeQueryWithOrFilter(orList);
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:36,代碼來源:EsODataProducer.java

示例8: execute

import java.util.LinkedHashMap; //導入方法依賴的package包/類
public void execute(LinkedHashMap<String, ScheduleEvent> events) {
	if(events == null) {
		logger.error("schedule event list is null");
	} else {
		logger.debug("schedule event list contains " + events.size() + " events");
		for(Map.Entry<String, ScheduleEvent> entry : events.entrySet()) {
			execute(entry.getValue());
		}
	}
}
 
開發者ID:edgexfoundry,項目名稱:device-modbus,代碼行數:11,代碼來源:ScheduleEventExecutor.java

示例9: process

import java.util.LinkedHashMap; //導入方法依賴的package包/類
private void process(List<MenuItem> list, LinkedHashMap<String, Integer> map, int col, String label, ItemStack[] items) {
    int index = 0;
    for (Entry<String, Integer> e : map.entrySet()) {
        index++;
        if (index > 5)
            break;
        list.add(new MenuItem(index, col, items[index - 1], COLORS[index - 1] + "#" + index + ChatColor.GRAY + " - " + COLORS[index - 1] + e.getKey(), new String[] {
                label + ChatColor.GRAY + ": " + ChatColor.WHITE + e.getValue()
        }, null));
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:12,代碼來源:TopManager.java

示例10: printChoreServiceDetails

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * Prints a summary of important details about the service. Used for debugging purposes
 */
private void printChoreServiceDetails(final String header) {
  LinkedHashMap<String, String> output = new LinkedHashMap<String, String>();
  output.put(header, "");
  output.put("ChoreService corePoolSize: ", Integer.toString(getCorePoolSize()));
  output.put("ChoreService scheduledChores: ", Integer.toString(getNumberOfScheduledChores()));
  output.put("ChoreService missingStartTimeCount: ",
    Integer.toString(getNumberOfChoresMissingStartTime()));

  for (Entry<String, String> entry : output.entrySet()) {
    if (LOG.isTraceEnabled()) LOG.trace(entry.getKey() + entry.getValue());
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:16,代碼來源:ChoreService.java

示例11: printChoreDetails

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * Prints a summary of important details about the chore. Used for debugging purposes
 */
private void printChoreDetails(final String header, ScheduledChore chore) {
  LinkedHashMap<String, String> output = new LinkedHashMap<String, String>();
  output.put(header, "");
  output.put("Chore name: ", chore.getName());
  output.put("Chore period: ", Integer.toString(chore.getPeriod()));
  output.put("Chore timeBetweenRuns: ", Long.toString(chore.getTimeBetweenRuns()));

  for (Entry<String, String> entry : output.entrySet()) {
    if (LOG.isTraceEnabled()) LOG.trace(entry.getKey() + entry.getValue());
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:15,代碼來源:ChoreService.java

示例12: buildFromTemplate

import java.util.LinkedHashMap; //導入方法依賴的package包/類
public static InputFormat buildFromTemplate(String inputTemplate, LinkedHashMap<String, String> labeledInputTokens) {
    if (inputTemplate == null) {
        return null;
    }
    String canonicalInputTemplate = inputTemplate;
    List<String> canonicalInputTokens = new ArrayList();
    Map<String, String> canonicalInputLabels = new HashMap();
    int i = 1;
    for (Entry<String, String> stringStringEntry : labeledInputTokens.entrySet()) {
        String inputLabel = (String) stringStringEntry.getKey();
        String inputToken = (String) stringStringEntry.getValue();
        String canonicalToken = "%" + i;
        String canonicalTokenWithType = canonicalToken + "\\$s";
        canonicalInputTokens.add(canonicalToken);
        canonicalInputLabels.put(inputLabel, canonicalToken);
        if (canonicalInputTemplate.contains(inputToken)) {
            canonicalInputTemplate = StringUtils.replaceFirstLiteral(canonicalInputTemplate, inputToken, canonicalTokenWithType);
            i++;
        } else {
            Log.d(TAG, "Input template is missing one of the specified input tokens: template = " + inputTemplate + " |  missing token = " + inputToken);
            return null;
        }
    }
    InputFormat inputFormat = new InputFormat();
    inputFormat.canonicalInputTemplate = canonicalInputTemplate;
    inputFormat.canonicalInputTokens = canonicalInputTokens;
    inputFormat.canonicalInputLabels = canonicalInputLabels;
    return inputFormat;
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:30,代碼來源:InputFormat.java

示例13: doneParsing

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/** Do any post-parsing processig. */
void doneParsing() {
	status = 3;
	LinkedHashMap<String,Open> copy = new LinkedHashMap<String,Open>(opens);
	opens.clear();
	for (Map.Entry<String,Open> e : copy.entrySet()) {
		String a = e.getKey();
		Open m = e.getValue();
		if (a.indexOf('$') >= 0) {
			String base = m.filename;
			int i = base.lastIndexOf('/');
			if (i >= 0)
				base = base.substring(i + 1);
			if (!copy.containsKey(base) && !opens.containsKey(base)) {
				for (i = 0; i < base.length(); i++) {
					char c = base.charAt(i);
					if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
						continue;
					if (i != 0 && ((c >= '0' && c <= '9') || c == '_' || c == '\'' || c == '\"'))
						continue;
					break;
				}
				if (i >= base.length())
					a = base;
			}
		}
		opens.put(a, new Open(m.pos, m.isPrivate, a, m.args, m.filename));
	}
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:30,代碼來源:CompModule.java

示例14: getMapAsString

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * 
 * @param map
 * @return 
 */
private String getMapAsString(LinkedHashMap<String, List<TextPosition>> map) {
    StringBuffer sb = new StringBuffer();

    for (Map.Entry<String, List<TextPosition>> entry : map.entrySet()) {
        String word = entry.getKey();
        List<TextPosition> positions = entry.getValue();

        sb.append(word);
        sb.append(" ");
    }

    return sb.toString().trim();
}
 
開發者ID:malikalamgirian,項目名稱:PDF2RDF,代碼行數:19,代碼來源:TitleExtractor.java

示例15: sortScopes

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * Sorts the scopes map using {@link ContextScope#getOrder()}
 * @param scopes Scopes map to sort
 */
private static void sortScopes(LinkedHashMap<String, ContextScope> scopes) {
	List<Map.Entry<String, ContextScope>> entries = new ArrayList<>(scopes.entrySet());
	scopes.clear();
	entries.stream()
			.sorted(Comparator.comparing(Map.Entry::getValue, Comparator.comparingInt((v) -> v.getOrder())))
			.forEachOrdered(e -> scopes.put(e.getKey(), e.getValue()));
}
 
開發者ID:holon-platform,項目名稱:holon-core,代碼行數:12,代碼來源:ContextManager.java


注:本文中的java.util.LinkedHashMap.entrySet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。