Java Code Examples for java.util.HashMap.putAll()

The following are Jave code examples for showing how to use putAll() of the java.util.HashMap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: sunbird-lms-service   File: AuditLogController.java   View Source Code Vote up 6 votes
/**
 * 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()));
  }
}
 
Example 2
Project: filestack-java   File: UploadTransferFunc.java   View Source Code Vote up 6 votes
/** 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();
}
 
Example 3
Project: googles-monorepo-demo   File: MapsTest.java   View Source Code Vote up 6 votes
@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);
}
 
Example 4
Project: NICON   File: ReciboPagamento.java   View Source Code Vote up 5 votes
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;
}
 
Example 5
Project: TextEmoji   File: OnekeyShare.java   View Source Code Vote up 5 votes
@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());
}
 
Example 6
Project: android_viewtracker   File: DataCommitImpl.java   View Source Code Vote up 5 votes
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);
        }
    }
}
 
Example 7
Project: SkyDocs   File: DocsTemplate.java   View Source Code Vote up 5 votes
/**
 * 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);
}
 
Example 8
Project: graylog-plugin-alert-conditional-count   File: ConditionalCountAlertCondition.java   View Source Code Vote up 5 votes
@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();
}
 
Example 9
Project: AOSP-Kayboard-7.1.2   File: ExpandableBinaryDictionary.java   View Source Code Vote up 5 votes
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;
}
 
Example 10
Project: fresco_floodlight   File: Controller.java   View Source Code Vote up 5 votes
@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;
}
 
Example 11
Project: elasticsearch_my   File: ElasticsearchException.java   View Source Code Vote up 5 votes
@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);
    }
}
 
Example 12
Project: underlx   File: StatsCache.java   View Source Code Vote up 5 votes
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;
}
 
Example 13
Project: rocketmq-rocketmq-all-4.1.0-incubating   File: MQClientInstance.java   View Source Code Vote up 5 votes
/**
 * 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);
    }
}
 
Example 14
Project: iosched-reader   File: HurlStack.java   View Source Code Vote up 5 votes
@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;
}
 
Example 15
Project: Stetho-Volley   File: StethoVolleyStack.java   View Source Code Vote up 4 votes
@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;
}
 
Example 16
Project: bitbreeds-webrtc   File: BindingService.java   View Source Code Vote up 4 votes
public byte[] processBindingRequest(
        byte[] data,
        String userName,
        String password,
        InetSocketAddress sender) {

    logger.trace("Input: " + Hex.encodeHexString(data));

    StunMessage msg = StunMessage.fromBytes(data);

    logger.trace("InputParsed: " + msg);

    byte[] content = SignalUtil.joinBytesArrays(
            SignalUtil.twoBytesFromInt(0x01),
            SignalUtil.xor(
                    SignalUtil.twoBytesFromInt(sender.getPort()),
                    Arrays.copyOf(msg.getHeader().getCookie(),2)),
            SignalUtil.xor(
                    sender.getAddress().getAddress(),
                    msg.getHeader().getCookie()
                    )
    );

    StunAttribute attr = new StunAttribute(
            StunAttributeTypeEnum.XOR_MAPPED_ADDRESS,content);

    StunAttribute user = msg.getAttributeSet().get(StunAttributeTypeEnum.USERNAME);
    String strUser = new String(user.toBytes()).split(":")[0].trim();

    msg.validate(password,data);

    HashMap<StunAttributeTypeEnum,StunAttribute> outSet = new HashMap<>();
    outSet.put(StunAttributeTypeEnum.XOR_MAPPED_ADDRESS,attr);
    outSet.putAll(msg.getAttributeSet());

    StunMessage output = StunMessage.fromData(
            StunRequestTypeEnum.BINDING_RESPONSE,
            msg.getHeader().getCookie(),
            msg.getHeader().getTransactionID(),
            outSet,
            true,
            true,
            strUser,
            password
    );

    byte[] bt = output.toBytes();
    logger.trace("Response: "+Hex.encodeHexString(bt));
    return bt;
}
 
Example 17
Project: athena   File: ClusterValidationSummary.java   View Source Code Vote up 4 votes
@Override
public HashMap<BigInteger, Boolean> addInPlace(HashMap<BigInteger, Boolean> arg0, HashMap<BigInteger, Boolean> arg1) {
    // TODO Auto-generated method stub
    arg0.putAll(arg1);
    return arg0;
}
 
Example 18
Project: jrfl   File: Formatter.java   View Source Code Vote up 4 votes
/**
 * @return Variables and values
 */
public HashMap<String, String> getVariables() {
    HashMap<String, String> all = new HashMap<>();
    all.putAll(nativeVariables); all.putAll(additionalVariables);
    return all;
}
 
Example 19
Project: aws-sdk-java-v2   File: ImmutableMapParameter.java   View Source Code Vote up 4 votes
/**
 * Generates and returns a new ImmutableMapParameter instance which
 * contains all the entries added into the Builder by {@code put()}
 * method.
 */
public ImmutableMapParameter<K, V> build() {
    HashMap<K, V> builtMap = new HashMap<K, V>();
    builtMap.putAll(entries);
    return new ImmutableMapParameter<K, V>(builtMap);
}
 
Example 20
Project: javaide   File: ThemeManager.java   View Source Code Vote up 4 votes
public static HashMap<String, CodeTheme> getAll(Context context) {
    loadAll(context);
    HashMap<String, CodeTheme> hm = new HashMap<>(builtinThemes);
    if (DonateUtils.DONATED) hm.putAll(customThemes);
    return hm;
}