@Test public void testMapEntryToString() throws Exception { MultiMap mmap = newMultiMap(); mmap.add("Header", "value"); assertEquals("Header: value", mmap.iterator().next().toString()); }
@Test public void testIteratorTest1() throws Exception { MultiMap mmap = newMultiMap(); Iterator<Map.Entry<String, String>> result = mmap.iterator(); assertNotNull(result); assertFalse(result.hasNext()); }
@Test public void testIteratorTest2() throws Exception { MultiMap mmap = newMultiMap(); mmap.add("a", "b"); Iterator<Map.Entry<String, String>> result = mmap.iterator(); assertNotNull(result); assertTrue(result.hasNext()); }
@Override public Iterator<Entry<String, Collection<String>>> iterator() { final Iterator<Entry<String, String>> iterator = vertxMap.iterator(); return new Iterator<Entry<String, Collection<String>>>() { @Override public boolean hasNext() { return iterator.hasNext(); } @Override public Entry<String, Collection<String>> next() { final Entry<String, String> next = iterator.next(); return new Entry<String, Collection<String>>() { @Override public String getKey() { return next.getKey(); } @Override public Collection<String> getValue() { return (Collection<String>) MultiMapWrapper.this.getAll(next.getKey()); } @Override public Collection<String> setValue(Collection<String> value) { return null; } }; } }; }
@Test public void testMapEntryToString() throws Exception { MultiMap mmap = newMultiMap(); mmap.add("Header", "value"); assertEquals("Header: value", mmap.iterator().next().toString()); }
@Test public void testIteratorTest1() throws Exception { MultiMap mmap = newMultiMap(); Iterator<Map.Entry<String, String>> result = mmap.iterator(); assertNotNull(result); assertFalse(result.hasNext()); }
@Test public void testIteratorTest2() throws Exception { MultiMap mmap = newMultiMap(); mmap.add("a", "b"); Iterator<Map.Entry<String, String>> result = mmap.iterator(); assertNotNull(result); assertTrue(result.hasNext()); }
@Override public Iterator<Entry<String, String>> iterator() { return multiMap.iterator(); }
@Override public Iterator<Entry<String, Collection<String>>> iterator() { final Iterator<Entry<String, String>> iterator = vertxMap.iterator(); return new Iterator<Entry<String, Collection<String>>>() { @Override public boolean hasNext() { return iterator.hasNext(); } @Override public Entry<String, Collection<String>> next() { final Entry<String, String> next = iterator.next(); return new Entry<String, Collection<String>>() { @Override public String getKey() { return next.getKey(); } @Override public Collection<String> getValue() { return (Collection<String>) MultiMapWrapper.this.getAll(next.getKey()); } @Override public Collection<String> setValue(Collection<String> value) { return null; } }; } }; }
/** * Convert http request parameters to a map. */ @SuppressWarnings("unchecked") Map<String, String> convertParams(HttpServerRequest request) { Map<String, String> map = new HashMap<>(); Iterator<Map.Entry<String, String>> iterator = request.params().iterator(); while (iterator.hasNext()) { Map.Entry<String, String> entry = iterator.next(); map.put(entry.getKey(), entry.getValue()); } return map; }
/** * @param startKey * @param map * @param attrs */ private void extractPropertiesFromMap(String startKey, Map<String, String> map, MultiMap attrs) { Iterator<Entry<String, String>> it = attrs.iterator(); while (it.hasNext()) { Entry<String, String> entry = it.next(); String key = entry.getKey().toLowerCase(); if (key.startsWith(startKey)) { String pureKey = key.substring(startKey.length()); String value = entry.getValue(); map.put(pureKey, value); } } }
@Override public Map<String, List<String>> headers() { Map<String, List<String>> result = new HashMap<>(); context.request().headers().iterator().forEachRemaining(e -> result.computeIfAbsent(e.getKey(), k -> new LinkedList<>()).add(e.getValue())); return result; }
public static String encodeBody(final MultiMap formAttributes, Charset charset) { if (formAttributes == null || formAttributes.isEmpty()) { return StringUtils.EMPTY; } else { Iterator<Entry<String, String>> entryIt = formAttributes .getDelegate() .iterator(); StringBuilder sb = new StringBuilder(128); while (entryIt.hasNext()) { Entry<String, String> entry = entryIt.next(); sb.append(encodeComponent(entry.getKey(), charset)); if (entry.getValue() != null) { sb.append('='); sb.append(encodeComponent(entry.getValue(), charset)); } if (entryIt.hasNext()) { sb.append('&'); } } return sb.toString(); } }
void extract(RoutingContext context, int position) { searchValue = context.request().getParam("sSearch_" + position); Iterator<Map.Entry<String, String>> it = context.request().params().iterator(); while (it.hasNext()) { Map.Entry<String, String> entry = it.next(); if (entry.getKey().startsWith("iSortCol_") && entry.getValue().equals(String.valueOf(position))) { this.sortable = true; String dirProp = "sSortDir_" + entry.getKey().substring("iSortCol_".length()); String dir = context.request().getParam(dirProp); if (dir != null && "desc".equals(dir)) { this.asc = false; } break; } } }
public static String encodeBody(final MultiMap formAttributes, Charset charset) { if (formAttributes == null || formAttributes.isEmpty()) { return StringUtils.EMPTY; } else { Iterator<Entry<String, String>> entryIt = formAttributes .getDelegate() .iterator(); StringBuilder sb = new StringBuilder(128); while (entryIt.hasNext()) { Entry<String, String> entry = entryIt.next(); sb.append(encodeComponent(entry.getKey(), charset)); if (entry.getValue() != null) { sb.append('='); sb.append(encodeComponent(entry.getValue(), charset)); } if (entryIt.hasNext()) { sb.append('&'); } } return sb.toString(); } }
handler.handle(Future.failedFuture(ise)); } catch (Exception e) { String paramName = routingContext.request().params().iterator().next().getKey(); handleParseError(paramName, e, routingContext); handler.handle(Future.failedFuture(e));