Example usage for java.util Map putAll

List of usage examples for java.util Map putAll

Introduction

In this page you can find the example usage for java.util Map putAll.

Prototype

void putAll(Map<? extends K, ? extends V> m);

Source Link

Document

Copies all of the mappings from the specified map to this map (optional operation).

Usage

From source file:com.edgenius.wiki.render.RenderUtil.java

/**
 * Parse macro string and return macro name and its parameters. The value from key of WikiConstants.MACRO_NAME_KEY in return map 
 * is macro name then with its parameters. This input suppose only has one macro (the first is parse if there are multiple macro) 
 * and this macro doesn't  be check if esacped,i.e., like \{macor} also is treat as valid macro.  
 * If input hasn't valid macro, null is returned.
 * @param macro//from w w w .  j a v a2 s.com
 * @return
 */
public static Map<String, String> parseSignleMacro(String macro) {
    if (StringUtils.isBlank(macro))
        return null;

    MatchResult rs = FilterRegxConstants.SINGLE_MACRO_FILTER_PATTERN.matcher(macro).toMatchResult();
    int count = rs.groupCount();
    if (count < 1)
        return null;

    Map<String, String> out = new HashMap<String, String>();
    out.put(WikiConstants.MACRO_NAME_KEY, rs.group(1));
    if (count > 1) {
        BaseMacroParameter params = new BaseMacroParameter();
        params.setParams(rs.group(2));
        out.putAll(params.getParams());
    }
    return out;
}

From source file:com.sworddance.util.UriFactoryImpl.java

public static URI createUriWithQuery(URI uri, Map<String, String> parameters) {
    Map<String, String> queryMap = getQueryMap(uri);
    queryMap.putAll(parameters);
    String noQueryUriString = uri.toString();
    int queryDelimiterIndex = noQueryUriString.indexOf('?');
    if (queryDelimiterIndex > -1) {
        noQueryUriString = noQueryUriString.substring(0, queryDelimiterIndex);
    }//from  w  w  w.j  av a  2 s. c  om
    URI noQueryUri = createUriWithSchemaAndPath(noQueryUriString);
    String queryString = createQueryString(queryMap);
    return URI.create(noQueryUri + "?" + queryString);
}

From source file:br.msf.commons.util.CollectionUtils.java

public static String resolveValue(final CharSequence value, final Map<String, String> properties) {
    if (value == null) {
        return null;
    }/*from w w w .j av  a 2s.co m*/
    final EnhancedStringBuilder builder = new EnhancedStringBuilder(value);
    if (CharSequenceUtils.isNotBlank(value)) {
        // create the properties map to use in the crossreference resolution.
        Map<String, String> supportedProps = new LinkedHashMap<>();
        // adds system props
        supportedProps.putAll(getSystemProps());
        // adds convenience props
        supportedProps.putAll(getUtilProps());
        // adds instance props, including defaults
        supportedProps.putAll(properties);
        // resolve crossreference props
        builder.replaceParams(supportedProps);
    }
    return builder.toString();
}

From source file:io.fabric8.kubernetes.pipeline.devops.ApplyStepExecution.java

protected static void addPropertiesFileToMap(URL url, Map<String, String> answer) throws AbortException {
    if (url != null) {
        try (InputStream in = url.openStream()) {
            Properties properties = new Properties();
            properties.load(in);/*ww w . ja va 2s  .com*/
            Map<String, String> map = toMap(properties);
            answer.putAll(map);
        } catch (IOException e) {
            throw new AbortException("Failed to load properties URL: " + url + ". " + e);
        }
    }
}

From source file:com.discovery.darchrow.net.URIUtil.java

/**
 * url(charsetType null,,?,url).//from www .j  a  v a  2s  .c  o m
 *
 * @param beforeUrl
 *            ???, ?,    ?? keyAndArrayMap
 * @param keyAndArrayMap
 *            ?map value? request.getParameterMap
 * @param charsetType
 *            ??null empty,?,?<br>
 *            ??,??,ie?chrome ? url , ?
 * @return if isNullOrEmpty(keyAndArrayMap) return beforeUrl;
 * @see #combineQueryString(Map, String)
 */
public static String getEncodedUrlByArrayMap(String beforeUrl, Map<String, String[]> keyAndArrayMap,
        String charsetType) {
    if (Validator.isNullOrEmpty(keyAndArrayMap)) {
        return beforeUrl;
    }

    // map ?  ?
    Map<String, String[]> appendMap = new HashMap<String, String[]>();
    appendMap.putAll(keyAndArrayMap);

    // ? action before ??
    // "action": "https://202.6.215.230:8081/purchasing/purchase.do?action=loginRequest",
    // "fullEncodedUrl":
    // "https://202.6.215.230:8081/purchasing/purchase.do?action=loginRequest?miscFee=0&descp=&klikPayCode=03BELAV220&callback=%2Fpatment1url&totalAmount=60000.00&payType=01&transactionNo=20140323024019&signature=1278794012&transactionDate=23%2F03%2F2014+02%3A40%3A19&currency=IDR",

    // *******************************************
    String beforePath = beforeUrl;

    // ??
    if (StringUtil.isContain(beforeUrl, URIComponents.QUESTIONMARK)) {
        // ???
        beforePath = getBeforePath(beforeUrl);
        String query = StringUtil.substring(beforeUrl, URIComponents.QUESTIONMARK, 1);

        Map<String, String[]> map = parseQueryToArrayMap(query, null);
        appendMap.putAll(map);
    }

    StringBuilder builder = new StringBuilder("");
    builder.append(beforePath);
    builder.append(URIComponents.QUESTIONMARK);

    // *******************************************
    String queryString = combineQueryString(appendMap, charsetType);
    builder.append(queryString);

    return builder.toString();
}

From source file:bluej.collect.DataCollectorImpl.java

public static void packageOpened(Package pkg) {
    final ProjectDetails proj = new ProjectDetails(pkg.getProject());

    final MultipartEntity mpe = new MultipartEntity();

    final Map<FileKey, List<String>> versions = new HashMap<FileKey, List<String>>();

    for (ClassTarget ct : pkg.getClassTargets()) {

        String relative = CollectUtility.toPath(proj, ct.getSourceFile());

        mpe.addPart("project[source_files][][name]", CollectUtility.toBody(relative));

        String anonymisedContent = CollectUtility.readFileAndAnonymise(proj, ct.getSourceFile());

        if (anonymisedContent != null) {
            mpe.addPart("source_histories[][source_history_type]", CollectUtility.toBody("complete"));
            mpe.addPart("source_histories[][name]", CollectUtility.toBody(relative));
            mpe.addPart("source_histories[][content]", CollectUtility.toBody(anonymisedContent));
            versions.put(new FileKey(proj, relative), Arrays.asList(Utility.splitLines(anonymisedContent)));
        }//from  w w w. java2  s. c o  m
    }

    submitEvent(pkg.getProject(), pkg, EventName.PACKAGE_OPENING, new Event() {

        @Override
        public void success(Map<FileKey, List<String>> fileVersions) {
            fileVersions.putAll(versions);
        }

        @Override
        public MultipartEntity makeData(int sequenceNum, Map<FileKey, List<String>> fileVersions) {
            return mpe;
        }
    });
}

From source file:br.ojimarcius.commons.util.CollectionUtils.java

public static String resolveValue(final CharSequence value, final Map<String, String> properties) {
    if (value == null) {
        return null;
    }//from   www . j  a  v a2  s . co  m
    final EnhancedStringBuilder builder = new EnhancedStringBuilder(value);
    if (CharSequenceUtils.isNotBlank(value)) {
        // create the properties map to use in the crossreference resolution.
        Map<String, String> supportedProps = new LinkedHashMap<String, String>();
        // adds system props
        supportedProps.putAll(getSystemProps());
        // adds convenience props
        supportedProps.putAll(getUtilProps());
        // adds instance props, including defaults
        supportedProps.putAll(properties);
        // resolve crossreference props
        builder.replaceParams(supportedProps);
    }
    return builder.toString();
}

From source file:com.exalttech.trex.util.Util.java

/**
 * Clone and return Map// w w  w  .  ja  va2  s.c om
 *
 * @param mapToClone
 * @return
 */
public static Map<String, Object> getClonedMap(Map<String, Object> mapToClone) {
    Map<String, Object> clonedMap = new HashMap<>();
    clonedMap.putAll(mapToClone);
    return clonedMap;
}

From source file:com.netflix.spinnaker.clouddriver.google.controllers.GoogleNamedImageLookupController.java

@VisibleForTesting
public static Map<String, String> buildTagsMap(Image image) {
    Map<String, String> tags = new HashMap<>();

    String description = image.getDescription();
    // For a description of the form:
    // key1: value1, key2: value2, key3: value3
    // we'll build a map associating each key with
    // its associated value
    if (description != null) {
        tags = Arrays.stream(description.split(",")).filter(token -> token.contains(": "))
                .map(token -> token.split(": ", 2))
                .collect(Collectors.toMap(token -> token[0].trim(), token -> token[1].trim(), (a, b) -> b));
    }/* w  w  w  . ja  v  a 2s .  c om*/

    Map<String, String> labels = image.getLabels();
    if (labels != null) {
        tags.putAll(labels);
    }

    return tags;
}

From source file:com.github.strawberry.redis.RedisLoader.java

private static Map<?, ?> mapOf(Field field, Jedis jedis, String key) {
    Map map = mapImplementationOf(field.getType());
    JedisType jedisType = JedisType.valueOf(jedis.type(key).toUpperCase());
    switch (jedisType) {
    case STRING: {
        map.put(key, jedis.get(key));/*from  ww w  .j  a v  a2s . co  m*/
    }
        break;
    case HASH: {
        Option<Type> valueType = genericTypeOf(field, 1);
        if (valueType.exists(isAssignableTo(Map.class)) || valueType.exists(isEqualTo(Object.class))) {
            map.put(key, jedis.hgetAll(key));
        } else {
            map.putAll(jedis.hgetAll(key));
        }
    }
        break;
    case LIST: {
        map.put(key, jedis.lrange(key, 0, -1));
    }
        break;
    case SET: {
        map.put(key, jedis.smembers(key));
    }
        break;
    case ZSET: {
        map.put(key, jedis.zrange(key, 0, -1));
    }
        break;
    }
    return map;
}