本文整理汇总了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;
}
示例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));
}
}
示例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;
}
示例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));
}
示例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);
}
}
示例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();
}
}
示例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);
}
示例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());
}
}
}
示例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));
}
}
示例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());
}
}
示例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());
}
}
示例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;
}
示例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));
}
}
示例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();
}
示例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()));
}