當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。