org.apache.commons.collections.MultiMap.put()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中org.apache.commons.collections.MultiMap.put()方法的一些代码示例,展示了MultiMap.put()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MultiMap.put()方法的具体详情如下:
包路径:org.apache.commons.collections.MultiMap
类名称:MultiMap
方法名:put

MultiMap.put介绍

[英]Adds the value to the collection associated with the specified key.

Unlike a normal Map the previous value is not replaced. Instead the new value is added to the collection stored against the key. The collection may be a List, Set or other collection dependent on implementation.
[中]将值添加到与指定键关联的集合中。
与正常的Map不同,之前的值不会被替换。而是将新值添加到存储在密钥上的集合中。集合可以是ListSet或其他依赖于实现的集合。

代码示例

代码示例来源:origin: apache/flume

Set<Long> eventPointers = inflightPuts.get(txnID);
for (Long eventPointer : eventPointers) {
 transactionMap.put(txnID, FlumeEventPointer.fromLong(eventPointer));
    putCount++;
    ptr = new FlumeEventPointer(fileId, offset);
    transactionMap.put(trans, ptr);
   } else if (type == TransactionEventRecord.Type.TAKE.get()) {
    takeCount++;
    Take take = (Take) record;
    ptr = new FlumeEventPointer(take.getFileID(), take.getOffset());
    transactionMap.put(trans, ptr);
   } else if (type == TransactionEventRecord.Type.ROLLBACK.get()) {
    rollbackCount++;

代码示例来源:origin: apache/flume

Set<Long> eventPointers = inflightPuts.get(txnID);
for (Long eventPointer : eventPointers) {
 transactionMap.put(txnID, FlumeEventPointer.fromLong(eventPointer));
   putCount++;
   ptr = new FlumeEventPointer(fileId, offset);
   transactionMap.put(trans, ptr);
  } else if (type == TransactionEventRecord.Type.TAKE.get()) {
   takeCount++;
   Take take = (Take) record;
   ptr = new FlumeEventPointer(take.getFileID(), take.getOffset());
   transactionMap.put(trans, ptr);
  } else if (type == TransactionEventRecord.Type.ROLLBACK.get()) {
   rollbackCount++;

代码示例来源:origin: commons-collections/commons-collections

public void testPutAll_Map1() {
  MultiMap original = new MultiHashMap();
  original.put("key", "object1");
  original.put("key", "object2");
  MultiHashMap test = new MultiHashMap();
  test.put("keyA", "objectA");
  test.put("key", "object0");
  test.putAll(original);
  assertEquals(2, test.size());
  assertEquals(4, test.totalSize());
  assertEquals(1, test.getCollection("keyA").size());
  assertEquals(3, test.getCollection("key").size());
  assertEquals(true, test.containsValue("objectA"));
  assertEquals(true, test.containsValue("object0"));
  assertEquals(true, test.containsValue("object1"));
  assertEquals(true, test.containsValue("object2"));
}

代码示例来源:origin: commons-collections/commons-collections

public void testPutAll_Map1() {
  MultiMap original = new MultiValueMap();
  original.put("key", "object1");
  original.put("key", "object2");
  MultiValueMap test = new MultiValueMap();
  test.put("keyA", "objectA");
  test.put("key", "object0");
  test.putAll(original);
  assertEquals(2, test.size());
  assertEquals(4, test.totalSize());
  assertEquals(1, test.getCollection("keyA").size());
  assertEquals(3, test.getCollection("key").size());
  assertEquals(true, test.containsValue("objectA"));
  assertEquals(true, test.containsValue("object0"));
  assertEquals(true, test.containsValue("object1"));
  assertEquals(true, test.containsValue("object2"));
}

代码示例来源:origin: openmrs/openmrs-core

private MultiMap getAsPropertiesKeyValueMultiMap(List<String> fileLines) {
  MultiMap multiMap = new MultiValueMap();
  for (String line : fileLines) {
    if (isCorectKeyValueLine(line)) {
      Map.Entry<String, String> tuple = extractKeyValue(line);
      multiMap.put(tuple.getKey(), tuple.getValue());
    }
  }
  return multiMap;
}

代码示例来源:origin: org.mule.modules/mule-module-http

public HttpResponseBuilder addHeader(String name, Object value)
{
  headers.put(name, value);
  return this;
}

代码示例来源:origin: jadler-mocking/jadler

/**
 * Adds a new header to this stub response. If there already exists a header with this name
 * in this stub response, multiple values will be sent.
 * @param name header name
 * @param value header value
 */
void addHeader(final String name, final String value) {
  this.headers.put(name, value);
}

代码示例来源:origin: com.atlassian.jira/jira-tests

public ParameterMapBuilder add(String paramName, String paramValue)
{
  map.put(paramName, paramValue);
  return this;
}

代码示例来源:origin: net.jadler/jadler-core

/**
 * Adds a new header to this stub response. If there already exists a header with this name
 * in this stub response, multiple values will be sent.
 * @param name header name
 * @param value header value
 */
void addHeader(final String name, final String value) {
  this.headers.put(name, value);
}

代码示例来源:origin: org.jsmiparser/jsmiparser-util

public List<V> put(K key, Collection<V> value) {
  List<V> result = new ArrayList<V>();
  for (V v : value) {
    Object insertedObject = m_impl.put(key, v);
    if (insertedObject != null) {
      result.add((V) insertedObject);
    }
  }
  return result;
}

代码示例来源:origin: com.atlassian.jira.plugin.labels/jira-labels-plugin

private void addAllToBucket(String lastBucket, List lastBucketContents)
{
  for (Iterator it = lastBucketContents.iterator(); it.hasNext();)
  {
    alphabetBuckets.put(lastBucket, it.next());
  }
}

代码示例来源:origin: com.atlassian.jira/jira-api

public void flagValueAsRequired(final String oldId, final String oldIssueTypeId)
{
  if ((oldId != null) && (oldIssueTypeId != null))
  {
    super.flagValueAsRequired(oldId);
    requiredOldIds.put(oldId, oldIssueTypeId);
  }
}

代码示例来源:origin: info.magnolia/magnolia-module-cache

private void appendHeader(String name, Object value) {
  if (responseExpirationCalculator == null || !responseExpirationCalculator.addHeader(name, value)) {
    headers.put(name, value);
  }
}

代码示例来源:origin: info.magnolia/magnolia-module-cache

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  in.defaultReadObject();
  headers = new MultiValueMap();
  Iterator iter = serializableHeadersBackingList.entrySet().iterator();
  while (iter.hasNext()) {
    Map.Entry entry = (Entry) iter.next();
    Collection c = (Collection) entry.getValue();
    for (Iterator ic = c.iterator(); ic.hasNext();) {
      headers.put(entry.getKey(), ic.next());
    }
  }
  serializableHeadersBackingList = null;
}

代码示例来源:origin: jadler-mocking/jadler

/**
 * Adds a default header to be added to every stub http response.
 * @param name header name (cannot be empty)
 * @param value header value (cannot be <tt>null</tt>)
 */
public void addDefaultHeader(final String name, final String value) {
  Validate.notEmpty(name, "header name cannot be empty");
  Validate.notNull(value, "header value cannot be null, use an empty string instead");
  this.checkConfigurable();
  this.defaultHeaders.put(name, value);
}

代码示例来源:origin: net.jadler/jadler-core

/**
 * Adds a default header to be added to every stub http response.
 * @param name header name (cannot be empty)
 * @param value header value (cannot be <tt>null</tt>)
 */
public void addDefaultHeader(final String name, final String value) {
  Validate.notEmpty(name, "header name cannot be empty");
  Validate.notNull(value, "header value cannot be null, use an empty string instead");
  this.checkConfigurable();
  this.defaultHeaders.put(name, value);
}

代码示例来源:origin: qcadoo/mes

private MultiMap groupProductionCountingQuantitiesByField(final List<Entity> productionCountingQuantities, final String field) {
  MultiMap map = new MultiHashMap();
  for (Entity pcq : productionCountingQuantities) {
    Entity entity = pcq.getBelongsToField(field);
    map.put(entity, pcq);
  }
  return map;
}

代码示例来源:origin: info.magnolia/magnolia-module-cache

private void replaceHeader(String name, Object value) {
  if (responseExpirationCalculator == null || !responseExpirationCalculator.addHeader(name, value)) {
    headers.remove(name);
    headers.put(name, value);
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-expression-language-impl

public Object put(Object key, Object value) {
  modified = true;
  if (!localContexts.empty()) {
    ((ArrayStack) localContexts.peek()).push(new DefaultKeyValue(key, value));
  }
  singleValueMap.put(key, value);
  multiValueMap.put(key, value);
  return value;
}

代码示例来源:origin: org.integratedmodelling/klab-common

public static void addRole(IConcept role, IConcept subject, /* @Nullable */ IConcept targetSubject, IConcept restricted, INamespace namespace) {
  RoleDescriptor rd = new RoleDescriptor();
  rd.role = role;
  rd.target = subject;
  rd.targetSubject = targetSubject;
  rd.within = restricted;
  // rd.property = restrictingProperty;
  rd.namespaceId = namespace.getId();
  rd.scenario = namespace.isScenario() ? namespace.getId() : null;
  roles.put(role, rd);
}

相关文章