當前位置: 首頁>>代碼示例>>Java>>正文


Java Entry.setValue方法代碼示例

本文整理匯總了Java中java.util.Map.Entry.setValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Entry.setValue方法的具體用法?Java Entry.setValue怎麽用?Java Entry.setValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Map.Entry的用法示例。


在下文中一共展示了Entry.setValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadProperties

import java.util.Map.Entry; //導入方法依賴的package包/類
/**
 * Loads the properties file into properties, with added functionality of
 * loading the files itself for values of the properties mentioned in the file
 * <p>
 * i.e. if file=/home/hello.properties which contains
 * key1=val1,,val2,,file::test.properties,val3
 * key2=a,,b,,c,,file::test.properties and test.properties contains - x y z..
 * <p>
 * then effecive properties returned will be - key1=val1,,val2,,x,,y,,z,,val3
 * key2=a,,b,,c,,x,,y,,z
 *
 * @param file
 * @param fileValueIndicator
 * @param valueSeparator
 * @return
 */
public static Properties loadProperties(String file, String fileValueIndicator, String valueSeparator)
{
    Properties props = loadFileIntoProperties(file);
    Set<Entry<Object, Object>> entrySet = props.entrySet();
    for (Entry<Object, Object> entry : entrySet)
    {
        String value = (String) entry.getValue();
        if (value.contains(fileValueIndicator))
        {
            // the value might have multiple file urls, load each of them append,
            // and remove these file urls on the go
            String[] allValues = value.split(valueSeparator);
            for (String each : allValues)
            {
                if (each.contains(fileValueIndicator))
                {
                    String fileToBeLoaded = each.split(fileValueIndicator)[1];
                    String newValue = getValueListFormatted(fileToBeLoaded, valueSeparator);
                    entry.setValue(value.replace(each, newValue));
                }
            }
        }
    }
    return props;
}
 
開發者ID:basavaraj1985,項目名稱:DolphinNG,代碼行數:42,代碼來源:IOUtil.java

示例2: constrainedEntry

import java.util.Map.Entry; //導入方法依賴的package包/類
/**
 * Returns a constrained view of the specified entry, using the specified
 * constraint. The {@link Entry#setValue} operation will be verified with the
 * constraint.
 *
 * @param entry the entry to constrain
 * @param constraint the constraint for the entry
 * @return a constrained view of the specified entry
 */
private static <K, V> Entry<K, V> constrainedEntry(
    final Entry<K, V> entry,
    final MapConstraint<? super K, ? super V> constraint) {
  checkNotNull(entry);
  checkNotNull(constraint);
  return new ForwardingMapEntry<K, V>() {
    @Override protected Entry<K, V> delegate() {
      return entry;
    }
    @Override public V setValue(V value) {
      constraint.checkKeyValue(getKey(), value);
      return entry.setValue(value);
    }
  };
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:25,代碼來源:MapConstraints.java

示例3: testEntrySetSetValueSameValue

import java.util.Map.Entry; //導入方法依賴的package包/類
public void testEntrySetSetValueSameValue() {
  // TODO: Investigate the extent to which, in practice, maps that support
  // put() also support Entry.setValue().
  if (!supportsPut) {
    return;
  }

  final Map<K, V> map;
  try {
    map = makePopulatedMap();
  } 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(oldValue);
  assertEquals(oldValue, returnedValue);
  assertTrue(entrySet.contains(mapEntry(entry.getKey(), oldValue)));
  assertEquals(oldValue, map.get(entry.getKey()));
  assertInvariants(map);
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:24,代碼來源:MapInterfaceTest.java

示例4: writeAnnotations

import java.util.Map.Entry; //導入方法依賴的package包/類
private void writeAnnotations(@Nonnull DexDataWriter writer) throws IOException {
    InternalEncodedValueWriter encodedValueWriter = new InternalEncodedValueWriter(writer);

    annotationSectionOffset = writer.getPosition();
    for (Entry<? extends AnnotationKey, Integer> entry: annotationSection.getItems()) {
        entry.setValue(writer.getPosition());

        AnnotationKey key = entry.getKey();

        writer.writeUbyte(annotationSection.getVisibility(key));
        writer.writeUleb128(typeSection.getItemIndex(annotationSection.getType(key)));

        Collection<? extends AnnotationElement> elements = Ordering.from(BaseAnnotationElement.BY_NAME)
                .immutableSortedCopy(annotationSection.getElements(key));

        writer.writeUleb128(elements.size());

        for (AnnotationElement element: elements) {
            writer.writeUleb128(stringSection.getItemIndex(annotationSection.getElementName(element)));
            writeEncodedValue(encodedValueWriter, annotationSection.getElementValue(element));
        }
    }
}
 
開發者ID:CvvT,項目名稱:andbg,代碼行數:24,代碼來源:DexWriter.java

示例5: tick

import java.util.Map.Entry; //導入方法依賴的package包/類
public void tick(double time) {
  if (trainsLeaving.size() > 1) {
    throw new IllegalStateException("This shouldn't be possible!");
  }
  for (Entry<Train, Double> trainElement : trains.entrySet()) {
    Train t = trainElement.getKey();
    SignalController signalController = nextBlockSignalController
        .get(t.getEcu().getJourneyPlan().getJourneyPath().getTrackAfterStation(this));
    if (signalController == null) {
      if (t.getEcu().getJourneyPlan().getJourneyPath().getLast() != this) {
        logger.error("SignallController is null (shouldn't be)");
      }
      continue;
    }
    double delay = trainElement.getValue();
    if (trainsLeaving.contains(t)) {
      if (t.getEngine().getObjective() != TrainObjective.PROCEED) {
        t.signalChange(SignalType.GREEN);
      }
      continue; // ignore them, they're leaving
    }
    if (trainsLeaving.size() > 0) {
      // if there are other trains leaving, wait for them to leave
      continue;
    }
    if (signalController.getStatus() == GREEN) {
      delay -= time;
      if (delay <= 0) {
        t.signalChange(SignalType.GREEN);
        trainsLeaving.add(t);
      }
    } else {
      break;
    }

    trainElement.setValue(delay);
    break; // Only do this for one train
  }
}
 
開發者ID:sinaa,項目名稱:train-simulator,代碼行數:40,代碼來源:Station.java

示例6: unwrapBsonable

import java.util.Map.Entry; //導入方法依賴的package包/類
public static Object unwrapBsonable(Object value) {
  if (value instanceof Document) {
    for (Entry<String, Object> entry : ((Document) value).entrySet()) {
      entry.setValue(unwrapBsonable(entry.getValue()));
    }
    return value;
  }

  if (value instanceof Iterable<?>) {
    return ImmutableList.copyOf(unwrapBsonableIterable((Iterable<?>) value));
  }

  if (value instanceof Constraints.ConstraintHost) {
    return convertToBson((Constraints.ConstraintHost) value);
  }

  if (value == null
      || value instanceof Number
      || value instanceof Boolean
      || value instanceof String) {
    return value;
  }

  if (value instanceof Adapted<?>) {
    return ((Adapted) value).toBson();
  }

  return String.valueOf(value);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:30,代碼來源:Support.java

示例7: writeTypes

import java.util.Map.Entry; //導入方法依賴的package包/類
private void writeTypes(@Nonnull DexDataWriter writer) throws IOException {
    typeSectionOffset = writer.getPosition();
    int index = 0;

    List<Entry<? extends TypeKey, Integer>> typeEntries = Lists.newArrayList(typeSection.getItems());
    Collections.sort(typeEntries, toStringKeyComparator);

    for (Entry<? extends TypeKey, Integer> entry : typeEntries) {
        entry.setValue(index++);
        writer.writeInt(stringSection.getItemIndex(typeSection.getString(entry.getKey())));
    }
}
 
開發者ID:CvvT,項目名稱:andbg,代碼行數:13,代碼來源:DexWriter.java

示例8: namedParameters

import java.util.Map.Entry; //導入方法依賴的package包/類
/**
 * 將Map中的primitive類型數組轉換為對象數組,以支持In操作
 *
 * @param map
 * @return
 */
public static Map namedParameters(Map map) {
    for (Object o : map.entrySet()) {
        Entry en = (Entry) o;
        en.setValue(handle(en.getValue()));
    }
    return map;
}
 
開發者ID:wolfboys,項目名稱:opencron,代碼行數:14,代碼來源:HibernateDao.java

示例9: writeProtos

import java.util.Map.Entry; //導入方法依賴的package包/類
private void writeProtos(@Nonnull DexDataWriter writer) throws IOException {
    protoSectionOffset = writer.getPosition();
    int index = 0;

    List<Entry<? extends ProtoKey, Integer>> protoEntries = Lists.newArrayList(protoSection.getItems());
    Collections.sort(protoEntries, DexWriter.<ProtoKey>comparableKeyComparator());

    for (Entry<? extends ProtoKey, Integer> entry: protoEntries) {
        entry.setValue(index++);
        ProtoKey key = entry.getKey();
        writer.writeInt(stringSection.getItemIndex(protoSection.getShorty(key)));
        writer.writeInt(typeSection.getItemIndex(protoSection.getReturnType(key)));
        writer.writeInt(typeListSection.getNullableItemOffset(protoSection.getParameters(key)));
    }
}
 
開發者ID:CvvT,項目名稱:andbg,代碼行數:16,代碼來源:DexWriter.java

示例10: testFilteredValuesIllegalSetValue

import java.util.Map.Entry; //導入方法依賴的package包/類
public void testFilteredValuesIllegalSetValue() {
  Map<String, Integer> unfiltered = createUnfiltered();
  Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
  filtered.put("a", 2);
  filtered.put("b", 4);
  assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);

  Entry<String, Integer> entry = filtered.entrySet().iterator().next();
  try {
    entry.setValue(5);
    fail();
  } catch (IllegalArgumentException expected) {}

  assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:16,代碼來源:MapsTest.java

示例11: testBashIt

import java.util.Map.Entry; //導入方法依賴的package包/類
public void testBashIt() throws Exception {
  BiMap<Integer, Integer> bimap = HashBiMap.create(N);
  BiMap<Integer, Integer> inverse = bimap.inverse();

  for (int i = 0; i < N; i++) {
    assertNull(bimap.put(2 * i, 2 * i + 1));
  }
  for (int i = 0; i < N; i++) {
    assertEquals(2 * i + 1, (int) bimap.get(2 * i));
  }
  for (int i = 0; i < N; i++) {
    assertEquals(2 * i, (int) inverse.get(2 * i + 1));
  }
  for (int i = 0; i < N; i++) {
    int oldValue = bimap.get(2 * i);
    assertEquals(2 * i + 1, (int) bimap.put(2 * i, oldValue - 2));
  }
  for (int i = 0; i < N; i++) {
    assertEquals(2 * i - 1, (int) bimap.get(2 * i));
  }
  for (int i = 0; i < N; i++) {
    assertEquals(2 * i, (int) inverse.get(2 * i - 1));
  }
  Set<Entry<Integer, Integer>> entries = bimap.entrySet();
  for (Entry<Integer, Integer> entry : entries) {
    entry.setValue(entry.getValue() + 2 * N);
  }
  for (int i = 0; i < N; i++) {
    assertEquals(2 * N + 2 * i - 1, (int) bimap.get(2 * i));
  }
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:32,代碼來源:HashBiMapTest.java

示例12: testEntrySet

import java.util.Map.Entry; //導入方法依賴的package包/類
@Test public void testEntrySet()
{
    _map.putAll(KEY1, Arrays.asList(VALUES));
    _map.put(KEY2, VALUE2);
    _map.put(KEY3, VALUE3);
    Set<Entry<String, String>> set = _map.entrySet();

    assertNotNull(set);
    assertEquals(3, set.size());
    for (Entry<String, String> e : set)
    {
        if (e.getKey().equals(KEY1))
        {
            assertEquals(VALUES[2], e.getValue());
            e.setValue(VALUES[1]);
        }
        else if (e.getKey().equals(KEY2))
        {
            assertEquals(VALUE2, e.getValue());
            e.setValue(VALUE3);
        }
        else if (e.getKey().equals(KEY3))
        {
            assertEquals(VALUE3, e.getValue());
            e.setValue(VALUE2);
        }
    }

    assertEquals(VALUES[1], _map.get(KEY1));
    assertEquals(VALUES.length, _map.length(KEY1));
    assertEquals(VALUE3, _map.get(KEY2));
    assertEquals(VALUE2, _map.get(KEY3));
}
 
開發者ID:JetBrains,項目名稱:intellij-deps-ini4j,代碼行數:34,代碼來源:BasicMultiMapTest.java

示例13: testEntrySetToArrayMutationThrows

import java.util.Map.Entry; //導入方法依賴的package包/類
public void testEntrySetToArrayMutationThrows() {
  map.putInstance(String.class, "test");
  @SuppressWarnings("unchecked") // Should get a CCE later if cast is wrong
  Entry<Object, Object> entry = (Entry<Object, Object>) map.entrySet().toArray()[0];
  assertEquals(TypeToken.of(String.class), entry.getKey());
  assertEquals("test", entry.getValue());
  try {
    entry.setValue(1);
    fail();
  } catch (UnsupportedOperationException expected) {}
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:12,代碼來源:MutableTypeToInstanceMapTest.java

示例14: writeTypeLists

import java.util.Map.Entry; //導入方法依賴的package包/類
private void writeTypeLists(@Nonnull DexDataWriter writer) throws IOException {
    writer.align();
    typeListSectionOffset = writer.getPosition();
    for (Entry<? extends TypeListKey, Integer> entry: typeListSection.getItems()) {
        writer.align();
        entry.setValue(writer.getPosition());

        Collection<? extends TypeKey> types = typeListSection.getTypes(entry.getKey());
        writer.writeInt(types.size());
        for (TypeKey typeKey: types) {
            writer.writeUshort(typeSection.getItemIndex(typeKey));
        }
    }
}
 
開發者ID:CvvT,項目名稱:andbg,代碼行數:15,代碼來源:DexWriter.java

示例15: writeMethods

import java.util.Map.Entry; //導入方法依賴的package包/類
private void writeMethods(@Nonnull DexDataWriter writer) throws IOException {
    methodSectionOffset = writer.getPosition();
    int index = 0;

    List<Entry<? extends MethodRefKey, Integer>> methodEntries = Lists.newArrayList(methodSection.getItems());
    Collections.sort(methodEntries, DexWriter.<MethodRefKey>comparableKeyComparator());
    
    for (Entry<? extends MethodRefKey, Integer> entry: methodEntries) {
        entry.setValue(index++);
        MethodRefKey key = entry.getKey();
        writer.writeUshort(typeSection.getItemIndex(methodSection.getDefiningClass(key)));
        writer.writeUshort(protoSection.getItemIndex(methodSection.getPrototype(key)));
        writer.writeInt(stringSection.getItemIndex(methodSection.getName(key)));
    }
}
 
開發者ID:CvvT,項目名稱:andbg,代碼行數:16,代碼來源:DexWriter.java


注:本文中的java.util.Map.Entry.setValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。