You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/12/06 08:31:56 UTC
[2/4] httpcomponents-core git commit: [HTTPCORE-496] Add API
org.apache.http.protocol.UriPatternMatcher.entrySet()
[HTTPCORE-496] Add API org.apache.http.protocol.UriPatternMatcher.entrySet()
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/21a1bf45
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/21a1bf45
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/21a1bf45
Branch: refs/heads/4.4.x
Commit: 21a1bf45faaf4e1ff374439fd79f6ca29e6a84a7
Parents: 462d136
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Dec 5 14:22:12 2017 -0700
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Wed Dec 6 09:26:47 2017 +0100
----------------------------------------------------------------------
RELEASE_NOTES.txt | 3 +++
.../org/apache/http/protocol/UriPatternMatcher.java | 16 +++++++++++++++-
.../apache/http/protocol/TestUriPatternMatcher.java | 16 ++++++++++++++++
3 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/21a1bf45/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index db6d1a1..58880cb 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -8,6 +8,9 @@ Changelog
* HTTPCORE-494: Add image constants to ContentType.
Contributed by Gary Gregory <ggregory at apache.org>
+
+* HTTPCORE-496: Add API org.apache.http.protocol.UriPatternMatcher.entrySet().
+ Contributed by Gary Gregory <ggregory at apache.org>
Release 4.4.8
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/21a1bf45/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java b/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
index 13a71ed..9925cb9 100644
--- a/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
+++ b/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
@@ -29,9 +29,11 @@ package org.apache.http.protocol;
import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
-import org.apache.http.annotation.ThreadingBehavior;
import org.apache.http.annotation.Contract;
+import org.apache.http.annotation.ThreadingBehavior;
import org.apache.http.util.Args;
/**
@@ -61,6 +63,18 @@ public class UriPatternMatcher<T> {
}
/**
+ * Returns a {@link Set} view of the mappings contained in this matcher.
+ *
+ * @return a set view of the mappings contained in this matcher.
+ *
+ * @see Map#entrySet()
+ * @since 4.4.9
+ */
+ public Set<Entry<String, T>> entrySet() {
+ return map.entrySet();
+ }
+
+ /**
* Registers the given object for URIs matching the given pattern.
*
* @param pattern the pattern to register the handler for.
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/21a1bf45/httpcore/src/test/java/org/apache/http/protocol/TestUriPatternMatcher.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/protocol/TestUriPatternMatcher.java b/httpcore/src/test/java/org/apache/http/protocol/TestUriPatternMatcher.java
index 4a56763..7d23423 100644
--- a/httpcore/src/test/java/org/apache/http/protocol/TestUriPatternMatcher.java
+++ b/httpcore/src/test/java/org/apache/http/protocol/TestUriPatternMatcher.java
@@ -33,6 +33,22 @@ import org.junit.Test;
public class TestUriPatternMatcher {
@Test
+ public void testEntrySet() throws Exception {
+ final Object h1 = new Object();
+ final Object h2 = new Object();
+ final Object h3 = new Object();
+
+ final UriPatternMatcher<Object> matcher = new UriPatternMatcher<Object>();
+ Assert.assertEquals(0, matcher.entrySet().size());
+ matcher.register("/h1", h1);
+ Assert.assertEquals(1, matcher.entrySet().size());
+ matcher.register("/h2", h2);
+ Assert.assertEquals(2, matcher.entrySet().size());
+ matcher.register("/h3", h3);
+ Assert.assertEquals(3, matcher.entrySet().size());
+ }
+
+ @Test
public void testRegisterUnregister() throws Exception {
final Object h1 = new Object();
final Object h2 = new Object();