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


Java Map类代码示例

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


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

示例1: getEurekaStatus

import java.util.Map; //导入依赖的package包/类
private Map<String, Object> getEurekaStatus() {

        Map<String, Object> stats = new HashMap<>();
        stats.put("time", new Date());
        stats.put("currentTime", StatusResource.getCurrentTimeAsString());
        stats.put("upTime", StatusInfo.getUpTime());
        stats.put("environment", ConfigurationManager.getDeploymentContext()
            .getDeploymentEnvironment());
        stats.put("datacenter", ConfigurationManager.getDeploymentContext()
            .getDeploymentDatacenter());

        PeerAwareInstanceRegistry registry = getRegistry();

        stats.put("isBelowRenewThreshold", registry.isBelowRenewThresold() == 1);

        populateInstanceInfo(stats);

        return stats;
    }
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:20,代码来源:EurekaResource.java

示例2: createProxy

import java.util.Map; //导入依赖的package包/类
private String createProxy ( final ValueArchive archive, final List<String> sources )
{
    final Map<String, String> data = new HashMap<String, String> ();

    final String id = Names.makeName ( archive ) + ".proxy";

    for ( final String source : sources )
    {
        if ( source.contains ( "," ) )
        {
            throw new IllegalArgumentException ( String.format ( "Item name '%s' is invalid. Proxy sources must not contain comma (,) in their name.", source ) );
        }
    }

    Collections.sort ( sources ); // make output reproducible

    data.put ( "sources", StringHelper.join ( sources, ", " ) );

    addData ( Factories.FACTORY_DA_PROXY_SOURCE, id, data );

    return id;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:23,代码来源:ValueArchiveProcessor.java

示例3: isEntityTypeValid

import java.util.Map; //导入依赖的package包/类
private static <T extends Entity> boolean isEntityTypeValid(ICommandSender commandSender, Map<String, String> params)
{
    String s = func_179651_b(params, "type");
    s = s != null && s.startsWith("!") ? s.substring(1) : s;

    if (s != null && !EntityList.isStringValidEntityName(s))
    {
        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.generic.entity.invalidType", new Object[] {s});
        chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
        commandSender.addChatMessage(chatcomponenttranslation);
        return false;
    }
    else
    {
        return true;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:18,代码来源:PlayerSelector.java

示例4: unmarshall

import java.util.Map; //导入依赖的package包/类
public Map<K, V> unmarshall(JsonUnmarshallerContext context) throws Exception {
    Map<K, V> map = new HashMap<K, V>();
    int originalDepth = context.getCurrentDepth();

    if (context.getCurrentToken() == JsonToken.VALUE_NULL) {
        return null;
    }

    while (true) {
        JsonToken token = context.nextToken();
        if (token == null) return map;

        if (token == FIELD_NAME) {
            K k = keyUnmarshaller.unmarshall(context);
            token = context.nextToken();
            V v = valueUnmarshaller.unmarshall(context);
            map.put(k, v);
        } else if (token == END_ARRAY || token == END_OBJECT) {
            if (context.getCurrentDepth() <= originalDepth) return map;
        }
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:23,代码来源:MapUnmarshaller.java

示例5: logQueueStatus

import java.util.Map; //导入依赖的package包/类
public static void logQueueStatus() {
    for (Map.Entry<String, AbstractNulsQueue> entry : QUEUES_MAP.entrySet()) {
        try {
            AbstractNulsQueue queue = entry.getValue();
            long nowIn = queue.getStatInfo().getInCount().get();
            long nowOut = queue.getStatInfo().getOutCount().get();
            long latelyInTps = (nowIn - queue.getStatInfo().getLastInCount()) / queue.getStatInfo().getLatelySecond();
            long latelyOutTps = (nowOut - queue.getStatInfo().getLastOutCount()) / queue.getStatInfo().getLatelySecond();
            queue.getStatInfo().setLatelyInTps(latelyInTps);
            queue.getStatInfo().setLatelyOutTps(latelyOutTps);
            queue.getStatInfo().setLastInCount(nowIn);
            queue.getStatInfo().setLastOutCount(nowOut);
            Log.info(queue.getStatInfo().toString());
        } catch (Exception e) {
        }
    }
}
 
开发者ID:nuls-io,项目名称:nuls,代码行数:18,代码来源:QueueManager.java

示例6: render

import java.util.Map; //导入依赖的package包/类
@Override
protected void render(Block html) {
  set(TITLE, join("Angel WorkerCounterBlock", $(WORKER_ATTEMPT_ID)));

  try {
    WorkerAttemptId workerAttemptId = new WorkerAttemptId($(WORKER_ATTEMPT_ID));

    Map<String, String> metricsMap =
        amContext.getWorkerManager().getWorker(workerAttemptId.getWorkerId())
            .getWorkerAttempt(workerAttemptId).getMetrics();
    TABLE<Hamlet> worker_metrics_table = html.table();
    html.h6($(WORKER_ATTEMPT_ID));

    worker_metrics_table.tr().th(_TH, "NAME").th(_TH, "VALUE")._();
    for (String key : metricsMap.keySet()) {
      String value = metricsMap.get(key);
      worker_metrics_table.tr().td(String.valueOf(key)).td(value)._();
    }
    worker_metrics_table._();
  } catch (UnvalidIdStrException e) {
    LOG.error("unvalid id string, ", e);
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:24,代码来源:WorkerCounterBlock.java

示例7: testGetHT_SINE

import java.util.Map; //导入依赖的package包/类
@Test
public void testGetHT_SINE() {
    try {
        Map<LocalDate, HtSineIndicator> indicatorMap = technicalIndicatorOperation.getHT_SINE("VOD.L", TimeInterval.DAILY, SeriesType.high);
        assertEquals(4456, indicatorMap.size());
    } catch (InvalidApiKeyException ex1) {
        ex1.printStackTrace();
        fail("Invalid Api Key Exception");
    } catch (InvalidFunctionOptionException ex2) {
        ex2.printStackTrace();
        fail("Required Function Properties Missing or is Invalid in Exception");
    } catch (MalFormattedFunctionException ex3) {
        ex3.printStackTrace();
        fail("Invalid Function Exception");
    } catch (MissingApiKeyException ex4) {
        ex4.printStackTrace();
        fail("Missing Api Key Exception");
    } catch (UltraHighFrequencyRequestException ex5) {
        ex5.printStackTrace();
        fail("Ultra High Frequency Request Exception");
    }
}
 
开发者ID:cautiontowind,项目名称:alpha-vantage,代码行数:23,代码来源:TechnicalIndicatorTemplateTest.java

示例8: createModule

import java.util.Map; //导入依赖的package包/类
private File createModule(String cnb, File cluster, String... attr) throws IOException {
    String dashes = cnb.replace('.', '-');
    
    File tmp = new File(new File(cluster, "modules"), dashes + ".jar");

    Map<String,String> attribs = new HashMap<String, String>();
    for (int i = 0; i < attr.length; i += 2) {
        attribs.put(attr[i], attr[i + 1]);
    }

    Map<String,String> files = new HashMap<String, String>();
    files.put("fake/" + cnb, cnb);

    tmp.getParentFile().mkdirs();
    SetupHid.createJar(tmp, files, attribs);

    return tmp;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:StandardModuleSpaceTest.java

示例9: create

import java.util.Map; //导入依赖的package包/类
public static ModbusMaster create ( final BundleContext context, final ScheduledExecutorService executor, final String id, final NioProcessor processor, final Map<String, String> parameters ) throws Exception
{
    final ModbusMaster device = new ModbusMaster ( context, id, executor, processor, "ModbusMaster", "modbus" );

    try
    {
        device.configure ( parameters );
    }
    catch ( final Exception e )
    {
        // dispose what was already created
        device.dispose ();
        throw e;
    }

    return device;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:ModbusMaster.java

示例10: getClassFieldByClassName

import java.util.Map; //导入依赖的package包/类
/** 查询出sql对应的field类型 */
public static Field getClassFieldByClassName(String name, String sqlField) {
	sqlField = sqlField.replaceAll("_", "");
	if (modelSqlFieldMap.get(StringUtils.lowerCase(name)) != null) {
	} else {
		if (modelFieldMap.get(StringUtils.lowerCase(name)) != null) {
			List<Field> list = modelFieldMap.get(StringUtils.lowerCase(name));
			Map<String, Field> map = new HashMap<>();
			for (Field field : list) {
				map.put(StringUtils.lowerCase(field.getName()), field);
			}
			modelSqlFieldMap.put(StringUtils.lowerCase(name), map);
		} else {
			return null;
		}
	}

	return modelSqlFieldMap.get(StringUtils.lowerCase(name)).get(StringUtils.lowerCase(sqlField));
}
 
开发者ID:finefuture,项目名称:data-migration,代码行数:20,代码来源:ClassCache.java

示例11: loadData

import java.util.Map; //导入依赖的package包/类
private Collection<Map<String, Object>> loadData(
		Map<String, Object> parameter, String entityQuerySql,Criteria criteria) {
	Map<String,Object> entityQueryParameters=(Map<String,Object>)parameter.get(Constants.ENTITY_QUERY_PARAMETERS);
	Map<String, Object> queryParam = retriveQueryParameters(parameter,entityQueryParameters);
	String querySql=parseQuerySql(entityQuerySql,parameter);
	ParseResult result=this.parseCriteria(criteria,true,"x");
	if(result!=null){
		querySql="select * from ("+querySql+") x where "+result.getAssemblySql().toString();
		if(queryParam==null){
			queryParam=new HashMap<String,Object>();
		}
		queryParam.putAll(result.getValueMap());
	}
	if(queryParam==null){
		return this.getJdbcTemplate().queryForList(querySql);
	}else{
		return this.getNamedParameterJdbcTemplate().queryForList(querySql, queryParam);			
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:20,代码来源:CommonPR.java

示例12: writeTimer

import java.util.Map; //导入依赖的package包/类
private Stream<String> writeTimer(Timer timer, Map<String, DatadogMetricMetadata> metadata) {
    final long wallTime = clock.wallTime();
    final HistogramSnapshot snapshot = timer.takeSnapshot(false);
    final Stream.Builder<String> metrics = Stream.builder();

    Meter.Id id = timer.getId();
    metrics.add(writeMetric(id, "sum", wallTime, snapshot.total(getBaseTimeUnit())));
    metrics.add(writeMetric(id, "count", wallTime, snapshot.count()));
    metrics.add(writeMetric(id, "avg", wallTime, snapshot.mean(getBaseTimeUnit())));
    metrics.add(writeMetric(id, "max", wallTime, snapshot.max(getBaseTimeUnit())));

    addToMetadataList(metadata, id, "sum", Statistic.TotalTime, null);
    addToMetadataList(metadata, id, "count", Statistic.Count, "occurrence");
    addToMetadataList(metadata, id, "avg", Statistic.Value, null);
    addToMetadataList(metadata, id, "max", Statistic.Max, null);

    for (ValueAtPercentile v : snapshot.percentileValues()) {
        String suffix = DoubleFormat.toString(v.percentile() * 100) + "percentile";
        metrics.add(writeMetric(id, suffix, wallTime, v.value(getBaseTimeUnit())));

        addToMetadataList(metadata, id, suffix, Statistic.Value, null);
    }

    return metrics.build();
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:26,代码来源:DatadogMeterRegistry.java

示例13: initiateService

import java.util.Map; //导入依赖的package包/类
@Override
public BatchBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
	final Object builder = configurationValues.get( BUILDER );
	if ( builder == null ) {
		return new BatchBuilderImpl(
				ConfigurationHelper.getInt( Environment.STATEMENT_BATCH_SIZE, configurationValues, 1 )
		);
	}

	if ( BatchBuilder.class.isInstance( builder ) ) {
		return (BatchBuilder) builder;
	}

	final String builderClassName = builder.toString();
	try {
		return (BatchBuilder) registry.getService( ClassLoaderService.class ).classForName( builderClassName ).newInstance();
	}
	catch (Exception e) {
		throw new ServiceException( "Could not build explicit BatchBuilder [" + builderClassName + "]", e );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:BatchBuilderInitiator.java

示例14: runImpl

import java.util.Map; //导入依赖的package包/类
/**
    * @see com.it.br.gameserver.network.clientpackets.ClientBasePacket#runImpl()
    */

   @Override
protected void runImpl()
   {
   	L2PcInstance activeChar = getClient().getActiveChar();
	if(activeChar == null)
		return;
	
	if (_bossId != 0)
	{
		_log.info("C5: RequestGetBossRecord: d: "+_bossId+" ActiveChar: "+activeChar); // should be always 0, log it if isnt 0 for furture research
	}
	
	RaidBossPointsManager.getInstance();
	int points = RaidBossPointsManager.getPointsByOwnerId(activeChar.getObjectId());
	RaidBossPointsManager.getInstance();
	int ranking = RaidBossPointsManager.calculateRanking(activeChar.getObjectId());
	
	RaidBossPointsManager.getInstance();
	Map<Integer, Integer> list = RaidBossPointsManager.getList(activeChar);
	
	// trigger packet
	activeChar.sendPacket(new ExGetBossRecord(ranking, points, list));
   }
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:28,代码来源:RequestGetBossRecord.java

示例15: 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


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