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