Java Code Examples for java.util.AbstractMap#entrySet()

The following examples show how to use java.util.AbstractMap#entrySet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OperationLogTestBase.java    From pravega with Apache License 2.0 6 votes vote down vote up
void performReadIndexChecks(Collection<OperationWithCompletion> operations, ReadIndex readIndex) throws Exception {
    AbstractMap<Long, Integer> expectedLengths = getExpectedLengths(operations);
    AbstractMap<Long, InputStream> expectedData = getExpectedContents(operations);
    for (Map.Entry<Long, InputStream> e : expectedData.entrySet()) {
        int expectedLength = expectedLengths.getOrDefault(e.getKey(), -1);
        @Cleanup
        ReadResult readResult = readIndex.read(e.getKey(), 0, expectedLength, TIMEOUT);
        int readLength = 0;
        while (readResult.hasNext()) {
            BufferView entry = readResult.next().getContent().join();
            int length = entry.getLength();
            readLength += length;
            int streamSegmentOffset = expectedLengths.getOrDefault(e.getKey(), 0);
            expectedLengths.put(e.getKey(), streamSegmentOffset + length);
            AssertExtensions.assertStreamEquals(String.format("Unexpected data returned from ReadIndex. StreamSegmentId = %d, Offset = %d.",
                    e.getKey(), streamSegmentOffset), e.getValue(), entry.getReader(), length);
        }

        Assert.assertEquals("Not enough bytes were read from the ReadIndex for StreamSegment " + e.getKey(), expectedLength, readLength);
    }
}
 
Example 2
Source File: WSRequestCodec.java    From SI with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {

            AbstractMap map = (AbstractMap) value;
            for (Object obj : map.entrySet()) {
                Map.Entry entry = (Map.Entry) obj;
                writer.startNode(entry.getKey().toString());
                Object val = entry.getValue();
                if ( null != val ) {
                    writer.setValue(val.toString());
                }
                writer.endNode();
            }

        }
 
Example 3
Source File: OlapUtils.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
      	
          AbstractMap map = (AbstractMap) value;
          for (Object obj : map.entrySet()) {
              Map.Entry entry = (Map.Entry) obj;
              writer.startNode(entry.getKey().toString());
              Object val = entry.getValue();
              if ( null != val ) {
                  writer.setValue(val.toString());
              }
              writer.endNode();
          }

      }
 
Example 4
Source File: WSRequestCodec.java    From SI with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {

            AbstractMap map = (AbstractMap) value;
            for (Object obj : map.entrySet()) {
                Map.Entry entry = (Map.Entry) obj;
                writer.startNode(entry.getKey().toString());
                Object val = entry.getValue();
                if ( null != val ) {
                    writer.setValue(val.toString());
                }
                writer.endNode();
            }

        }
 
Example 5
Source File: MapKeyValueCustomXstreamConverter.java    From gatf with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void marshal(final Object value, final HierarchicalStreamWriter writer, final MarshallingContext context)
   {
       final AbstractMap<String, String> map = (AbstractMap<String, String>) value;
       for (final Entry<String, String> entry : map.entrySet())
       {
           writer.startNode(entry.getKey().toString());
           writer.setValue(entry.getValue().toString());
           writer.endNode();
       }
   }
 
Example 6
Source File: MapEntryConverter.java    From ZenQuery with Apache License 2.0 5 votes vote down vote up
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
    AbstractMap map = (AbstractMap) value;
    for (Object obj : map.entrySet()) {
        Map.Entry entry = (Map.Entry) obj;
        writer.startNode(entry.getKey().toString());
        writer.setValue(entry.getValue() != null ? entry.getValue().toString() : "");
        writer.endNode();
    }
}