Skip to content

Apache Lucene open-source search software

LUCENE-5275: Change AttributeSource.toString to display the current state of attributes

Robert Muir96380e912935
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index cb23cc4df8b..c873b832fdc 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -143,6 +143,9 @@ API Changes:
with IndexSearcher when an ExecutorService is specified.
(Ryan Ernst, Mike McCandless, Robert Muir)
+* LUCENE-5275: Change AttributeSource.toString() to display the current
+ state of attributes. (Robert Muir)
+
Optimizations
* LUCENE-5225: The ToParentBlockJoinQuery only keeps tracks of the the child
diff --git a/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java b/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java
index e35ea383dab..30575cc1699 100644
--- a/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java
+++ b/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java
@@ -501,4 +501,13 @@ public class AttributeSource {
}
}
+ /**
+ * Returns a string consisting of the class's simple name, the hex representation of the identity hash code,
+ * and the current reflection of all attributes.
+ * @see #reflectAsString(boolean)
+ */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + '@' + Integer.toHexString(System.identityHashCode(this)) + " " + reflectAsString(false);
+ }
}