You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/11/14 15:41:44 UTC

logging-log4j2 git commit: LOG4J2-1683, LOG4J2-1677, LOG4J2-1678, LOG4J2-1679 added method indexOfKey to IndexedReadOnlyStringMap interface

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 12d9c1b7f -> 8341eaa50


LOG4J2-1683, LOG4J2-1677, LOG4J2-1678, LOG4J2-1679  added method indexOfKey to IndexedReadOnlyStringMap interface


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8341eaa5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8341eaa5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8341eaa5

Branch: refs/heads/master
Commit: 8341eaa50513f6b87606703105d3b6add2381e8c
Parents: 12d9c1b
Author: rpopma <rp...@apache.org>
Authored: Tue Nov 15 00:41:36 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Tue Nov 15 00:41:36 2016 +0900

----------------------------------------------------------------------
 .../log4j/util/IndexedReadOnlyStringMap.java     | 19 ++++++++++++++++++-
 .../logging/log4j/util/IndexedStringMap.java     |  7 ++++++-
 .../logging/log4j/util/SortedArrayStringMap.java |  5 ++++-
 3 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8341eaa5/log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedReadOnlyStringMap.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedReadOnlyStringMap.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedReadOnlyStringMap.java
index b06ab34..5c67b01 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedReadOnlyStringMap.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedReadOnlyStringMap.java
@@ -17,8 +17,13 @@
 package org.apache.logging.log4j.util;
 
 /**
- * An extension of {@code ReadOnlyStringMap} that views all key-value pairs as a sequence ordered by key, and allows
+ * An extension of {@code ReadOnlyStringMap} that imposes a total ordering on its keys.
+ * The map is ordered according to the natural ordering of its keys. This order is reflected when
+ * {@link #forEach(BiConsumer) consuming} the key-value pairs with a {@link BiConsumer} or a {@link TriConsumer}.
+ * <p>
+ * This interface views all key-value pairs as a sequence ordered by key, and allows
  * keys and values to be accessed by their index in the sequence.
+ * </p>
  *
  * @see ReadOnlyStringMap
  * @since 2.8
@@ -43,4 +48,16 @@ public interface IndexedReadOnlyStringMap extends ReadOnlyStringMap {
      */
     <V> V getValueAt(final int index);
 
+    /**
+     * Viewing all key-value pairs as a sequence sorted by key, this method returns the index of the specified key in
+     * that sequence. If the specified key is not found, this method returns {@code (-(insertion point) - 1)}.
+     *
+     * @param key the key whose index in the ordered sequence of keys to return
+     * @return the index of the specified key or {@code (-(insertion point) - 1)} if the key is not found.
+     *          The insertion point is defined as the point at which the key would be inserted into the array:
+     *          the index of the first element in the range greater than the key, or {@code size()} if all elements
+     *          are less than the specified key. Note that this guarantees that the return value will be &gt;= 0
+     *          if and only if the key is found.
+     */
+    int indexOfKey(final String key);
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8341eaa5/log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedStringMap.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedStringMap.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedStringMap.java
index 99c27a0..9b1bfbb 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedStringMap.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedStringMap.java
@@ -17,8 +17,13 @@
 package org.apache.logging.log4j.util;
 
 /**
- * An extension of {@code StringMap} that views all key-value pairs as a sequence ordered by key, and allows
+ * An extension of {@code StringMap} that imposes a total ordering on its keys.
+ * The map is ordered according to the natural ordering of its keys. This order is reflected when
+ * {@link #forEach(BiConsumer) consuming} the key-value pairs with a {@link BiConsumer} or a {@link TriConsumer}.
+ * <p>
+ * This interface views all key-value pairs as a sequence ordered by key, and allows
  * keys and values to be accessed by their index in the sequence.
+ * </p>
  *
  * @see IndexedReadOnlyStringMap
  * @see StringMap

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8341eaa5/log4j-api/src/main/java/org/apache/logging/log4j/util/SortedArrayStringMap.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/SortedArrayStringMap.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/SortedArrayStringMap.java
index 24df831..af9ede0 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/SortedArrayStringMap.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/SortedArrayStringMap.java
@@ -175,7 +175,8 @@ public class SortedArrayStringMap implements IndexedStringMap {
         return size == 0;
     }
 
-    int indexOfKey(final String key) {
+    @Override
+    public int indexOfKey(final String key) {
         if (keys == EMPTY) {
             return -1;
         }
@@ -341,6 +342,7 @@ public class SortedArrayStringMap implements IndexedStringMap {
         }
     }
 
+    @Override
     public String getKeyAt(final int index) {
         if (index < 0 || index >= size) {
             return null;
@@ -349,6 +351,7 @@ public class SortedArrayStringMap implements IndexedStringMap {
     }
 
     @SuppressWarnings("unchecked")
+    @Override
     public <V> V getValueAt(final int index) {
         if (index < 0 || index >= size) {
             return null;