本文整理匯總了Java中java.util.HashMap.putAll方法的典型用法代碼示例。如果您正苦於以下問題:Java HashMap.putAll方法的具體用法?Java HashMap.putAll怎麽用?Java HashMap.putAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.HashMap
的用法示例。
在下文中一共展示了HashMap.putAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: searchAuditHistory
import java.util.HashMap; //導入方法依賴的package包/類
/**
* Method to search audit history logs
*
* @return
*/
public Promise<Result> searchAuditHistory() {
try {
JsonNode requestData = request().body().asJson();
ProjectLogger.log("Request for Search Audit History: " + requestData, LoggerEnum.INFO.name());
Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
reqObj.setOperation(ActorOperations.SEARCH_AUDIT_LOG.getValue());
reqObj.setRequestId(ExecutionContext.getRequestId());
reqObj.setEnv(getEnvironment());
HashMap<String, Object> innerMap = new HashMap<>();
innerMap.put(JsonKey.REQUESTED_BY, ctx().flash().get(JsonKey.USER_ID));
innerMap.putAll(reqObj.getRequest());
reqObj.setRequest(innerMap);
return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
} catch (Exception e) {
return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
}
}
示例2: multipartCommit
import java.util.HashMap; //導入方法依賴的package包/類
/** For intelligent ingestion mode only. Called when all chunks of a part have been uploaded. */
private void multipartCommit() throws Exception {
final HashMap<String, RequestBody> params = new HashMap<>();
params.putAll(upload.baseParams);
params.put("part", Util.createStringPart(Integer.toString(container.num)));
RetryNetworkFunc<ResponseBody> func;
func = new RetryNetworkFunc<ResponseBody>(5, 5, Upload.DELAY_BASE) {
@Override
Response<ResponseBody> work() throws Exception {
return Networking.getUploadService().commit(params).execute();
}
};
func.call();
}
示例3: assertWontGrow
import java.util.HashMap; //導入方法依賴的package包/類
@GwtIncompatible // reflection
private static void assertWontGrow(
int size, HashMap<Object, Object> map1, HashMap<Object, Object> map2) throws Exception {
// Only start measuring table size after the first element inserted, to
// deal with empty-map optimization.
map1.put(0, null);
int initialBuckets = bucketsOf(map1);
for (int i = 1; i < size; i++) {
map1.put(i, null);
}
assertThat(bucketsOf(map1))
.named("table size after adding " + size + " elements")
.isEqualTo(initialBuckets);
/*
* Something slightly different happens when the entries are added all at
* once; make sure that passes too.
*/
map2.putAll(map1);
assertThat(bucketsOf(map1))
.named("table size after adding " + size + " elements")
.isEqualTo(initialBuckets);
}
示例4: getDados
import java.util.HashMap; //導入方法依賴的package包/類
public HashMap<String, Object> getDados() {
HashMap<String, Object> mapLista = new HashMap<>();
ResultSet rs = Call.selectFrom("VER_AMORTIZACAO where \"ID PRESTACAO\" = ?", "*", numPrestacao);
Consumer<HashMap<String, Object>> act = (map) -> {
mapLista.putAll(map);
};
Call.forEchaResultSet(act, rs);
return mapLista;
}
示例5: show
import java.util.HashMap; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void show(Context context) {
HashMap<String, Object> shareParamsMap = new HashMap<String, Object>();
shareParamsMap.putAll(params);
MobSDK.init(context.getApplicationContext());
ShareSDK.initSDK(context);
// 打開分享菜單的統計
ShareSDK.logDemoEvent(1, null);
int iTheme = 0;
try {
iTheme = ResHelper.parseInt(String.valueOf(shareParamsMap.remove("theme")));
} catch (Throwable t) {}
OnekeyShareTheme theme = OnekeyShareTheme.fromValue(iTheme);
OnekeyShareThemeImpl themeImpl = theme.getImpl();
themeImpl.setShareParamsMap(shareParamsMap);
themeImpl.setDialogMode(shareParamsMap.containsKey("dialogMode") ? ((Boolean) shareParamsMap.remove("dialogMode")) : false);
themeImpl.setSilent(shareParamsMap.containsKey("silent") ? ((Boolean) shareParamsMap.remove("silent")) : false);
themeImpl.setCustomerLogos((ArrayList<CustomerLogo>) shareParamsMap.remove("customers"));
themeImpl.setHiddenPlatforms((HashMap<String, String>) shareParamsMap.remove("hiddenPlatforms"));
themeImpl.setPlatformActionListener((PlatformActionListener) shareParamsMap.remove("callback"));
themeImpl.setShareContentCustomizeCallback((ShareContentCustomizeCallback) shareParamsMap.remove("customizeCallback"));
if (shareParamsMap.containsKey("disableSSO") ? ((Boolean) shareParamsMap.remove("disableSSO")) : false) {
themeImpl.disableSSO();
}
themeImpl.show(context.getApplicationContext());
}
示例6: commitClickEvent
import java.util.HashMap; //導入方法依賴的package包/類
public void commitClickEvent(HashMap<String, Object> commonInfo, String viewName, HashMap<String, Object> viewData) {
if (TextUtils.isEmpty(viewName)) {
TrackerLog.d("commitClickEvent viewName is null");
return;
}
TrackerLog.d("viewName=" + viewName);
HashMap<String, String> argsInfo = new HashMap<String, String>();
// add the common info
if (commonInfo != null && !commonInfo.isEmpty()) {
argsInfo.putAll(TrackerUtil.getHashMap(commonInfo));
}
if (argsInfo.containsKey(TrackerConstants.PAGE_NAME)) {
argsInfo.remove(TrackerConstants.PAGE_NAME);
}
// add the special info
if (viewData != null && !viewData.isEmpty()) {
argsInfo.putAll(TrackerUtil.getHashMap(viewData));
}
if (GlobalsContext.trackerOpen) {
if (!argsInfo.isEmpty()) {
TrackerUtil.commitCtrlEvent(viewName, argsInfo);
} else {
TrackerUtil.commitCtrlEvent(viewName, null);
}
}
}
示例7: createModel
import java.util.HashMap; //導入方法依賴的package包/類
/**
* Creates the corresponding model for this template with some variables.
*
* @param otherVariables The variables.
*
* @return The corresponding JTwig model.
*/
public final JtwigModel createModel(final Map<String, Object> otherVariables) {
final HashMap<String, Object> variables = new HashMap<String, Object>(this.variables);
if(otherVariables != null) {
variables.putAll(otherVariables);
}
return JtwigModel.newModel(variables)
.with(Constants.VARIABLE_GENERATOR_NAME, Constants.APP_NAME)
.with(Constants.VARIABLE_GENERATOR_VERSION, Constants.APP_VERSION)
.with(Constants.VARIABLE_GENERATOR_WEBSITE, Constants.APP_WEBSITE);
}
示例8: ConditionalCountAlertCondition
import java.util.HashMap; //導入方法依賴的package包/類
@AssistedInject
public ConditionalCountAlertCondition(Searches searches,
Configuration configuration,
@Assisted Stream stream,
@Nullable @Assisted("id") String id,
@Assisted DateTime createdAt,
@Assisted("userid") String creatorUserId,
@Assisted Map<String, Object> parameters,
@Assisted("title") @Nullable String title) {
super(stream, id, ConditionalCountAlertCondition.class.getCanonicalName(), createdAt, creatorUserId, parameters, title);
this.searches = searches;
this.configuration = configuration;
this.query = (String) parameters.get("query");
this.time = Tools.getNumber(parameters.get("time"), 5).intValue();
final String thresholdType = (String) parameters.get("threshold_type");
final String upperCaseThresholdType = thresholdType.toUpperCase(Locale.ENGLISH);
if (!thresholdType.equals(upperCaseThresholdType)) {
final HashMap<String, Object> updatedParameters = new HashMap<>();
updatedParameters.putAll(parameters);
updatedParameters.put("threshold_type", upperCaseThresholdType);
super.setParameters(updatedParameters);
}
this.thresholdType = ThresholdType.valueOf(upperCaseThresholdType);
this.threshold = Tools.getNumber(parameters.get("threshold"), 0).intValue();
}
開發者ID:alcampos,項目名稱:graylog-plugin-alert-conditional-count,代碼行數:28,代碼來源:ConditionalCountAlertCondition.java
示例9: getHeaderAttributeMap
import java.util.HashMap; //導入方法依賴的package包/類
protected Map<String, String> getHeaderAttributeMap() {
HashMap<String, String> attributeMap = new HashMap<>();
if (mAdditionalAttributeMap != null) {
attributeMap.putAll(mAdditionalAttributeMap);
}
attributeMap.put(DictionaryHeader.DICTIONARY_ID_KEY, mDictName);
attributeMap.put(DictionaryHeader.DICTIONARY_LOCALE_KEY, mLocale.toString());
attributeMap.put(DictionaryHeader.DICTIONARY_VERSION_KEY,
String.valueOf(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())));
return attributeMap;
}
示例10: getControllerNodeIPs
import java.util.HashMap; //導入方法依賴的package包/類
@Override
public Map<String, String> getControllerNodeIPs() {
// We return a copy of the mapping so we can guarantee that
// the mapping return is the same as one that will be (or was)
// dispatched to IHAListeners
HashMap<String,String> retval = new HashMap<String,String>();
synchronized(controllerNodeIPsCache) {
retval.putAll(controllerNodeIPsCache);
}
return retval;
}
示例11: writeTo
import java.util.HashMap; //導入方法依賴的package包/類
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(this.getMessage());
out.writeException(this.getCause());
writeStackTraces(this, out);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
out.writeMapOfLists(headers, StreamOutput::writeString, StreamOutput::writeString);
out.writeMapOfLists(metadata, StreamOutput::writeString, StreamOutput::writeString);
} else {
HashMap<String, List<String>> finalHeaders = new HashMap<>(headers.size() + metadata.size());
finalHeaders.putAll(headers);
finalHeaders.putAll(metadata);
out.writeMapOfLists(finalHeaders, StreamOutput::writeString, StreamOutput::writeString);
}
}
示例12: getStats
import java.util.HashMap; //導入方法依賴的package包/類
public HashMap<String, Stats> getStats() {
HashMap<String, Stats> tstats = new HashMap<>();
synchronized (lock) {
if (networkStats.isEmpty()) {
networkStats = readStats();
if (networkStats == null) {
networkStats = new HashMap<>();
}
}
tstats.putAll(networkStats);
}
return tstats;
}
示例13: cleanOfflineBroker
import java.util.HashMap; //導入方法依賴的package包/類
/**
* Remove offline broker
*/
private void cleanOfflineBroker() {
try {
if (this.lockNamesrv.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS))
try {
ConcurrentHashMap<String, HashMap<Long, String>> updatedTable = new ConcurrentHashMap<String, HashMap<Long, String>>();
Iterator<Entry<String, HashMap<Long, String>>> itBrokerTable = this.brokerAddrTable.entrySet().iterator();
while (itBrokerTable.hasNext()) {
Entry<String, HashMap<Long, String>> entry = itBrokerTable.next();
String brokerName = entry.getKey();
HashMap<Long, String> oneTable = entry.getValue();
HashMap<Long, String> cloneAddrTable = new HashMap<Long, String>();
cloneAddrTable.putAll(oneTable);
Iterator<Entry<Long, String>> it = cloneAddrTable.entrySet().iterator();
while (it.hasNext()) {
Entry<Long, String> ee = it.next();
String addr = ee.getValue();
if (!this.isBrokerAddrExistInTopicRouteTable(addr)) {
it.remove();
log.info("the broker addr[{} {}] is offline, remove it", brokerName, addr);
}
}
if (cloneAddrTable.isEmpty()) {
itBrokerTable.remove();
log.info("the broker[{}] name's host is offline, remove it", brokerName);
} else {
updatedTable.put(brokerName, cloneAddrTable);
}
}
if (!updatedTable.isEmpty()) {
this.brokerAddrTable.putAll(updatedTable);
}
} finally {
this.lockNamesrv.unlock();
}
} catch (InterruptedException e) {
log.warn("cleanOfflineBroker Exception", e);
}
}
示例14: performRequest
import java.util.HashMap; //導入方法依賴的package包/類
@Override
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders)
throws IOException, AuthFailureError {
String url = request.getUrl();
HashMap<String, String> map = new HashMap<String, String>();
map.putAll(request.getHeaders());
map.putAll(additionalHeaders);
if (mUrlRewriter != null) {
String rewritten = mUrlRewriter.rewriteUrl(url);
if (rewritten == null) {
throw new IOException("URL blocked by rewriter: " + url);
}
url = rewritten;
}
URL parsedUrl = new URL(url);
HttpURLConnection connection = openConnection(parsedUrl, request);
for (String headerName : map.keySet()) {
connection.addRequestProperty(headerName, map.get(headerName));
}
setConnectionParametersForRequest(connection, request);
// Initialize HttpResponse with data from the HttpURLConnection.
ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1);
int responseCode = connection.getResponseCode();
if (responseCode == -1) {
// -1 is returned by getResponseCode() if the response code could not be retrieved.
// Signal to the caller that something was wrong with the connection.
throw new IOException("Could not retrieve response code from HttpUrlConnection.");
}
StatusLine responseStatus = new BasicStatusLine(protocolVersion,
connection.getResponseCode(), connection.getResponseMessage());
BasicHttpResponse response = new BasicHttpResponse(responseStatus);
response.setEntity(entityFromConnection(connection));
for (Entry<String, List<String>> header : connection.getHeaderFields().entrySet()) {
if (header.getKey() != null) {
Header h = new BasicHeader(header.getKey(), header.getValue().get(0));
response.addHeader(h);
}
}
return response;
}
示例15: performRequest
import java.util.HashMap; //導入方法依賴的package包/類
@Override
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders) throws IOException, AuthFailureError {
String friendlyName = System.currentTimeMillis() + "";
StethoURLConnectionManager connectionManager = new StethoURLConnectionManager(friendlyName);
String urlString = request.getUrl();
HashMap<String, String> map = new HashMap<String, String>();
map.putAll(request.getHeaders());
map.putAll(additionalHeaders);
URL url = new URL(urlString);
HttpURLConnection connection = openConnection(url, request);
for (String headerName : map.keySet()) {
connection.addRequestProperty(headerName, map.get(headerName));
}
connection.addRequestProperty("Accept-Encoding","gzip");
boolean isPreConnected = setConnectionParametersForRequest(connectionManager, connection, request);
ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1);
if (!isPreConnected) {
preConnect(connectionManager,connection,null);
}
int responseCode = connection.getResponseCode();
if (responseCode == -1) {
throw new IOException("Could not retrieve response code from HttpUrlConnection.");
}
StatusLine responseStatus = new BasicStatusLine(protocolVersion,
connection.getResponseCode(), connection.getResponseMessage());
BasicHttpResponse response = new BasicHttpResponse(responseStatus);
postConnect(connectionManager);
if (hasResponseBody(request.getMethod(), responseStatus.getStatusCode())) {
response.setEntity(entityFromConnection(connection));
}
for (Map.Entry<String, List<String>> header : connection.getHeaderFields().entrySet()) {
if (header.getKey() != null) {
Header h = new BasicHeader(header.getKey(), header.getValue().get(0));
response.addHeader(h);
}
}
return response;
}