[slf4j-dev] svn commit: r515 - in slf4j/trunk/src/java/org/slf4j: . impl
ceki at slf4j.org
ceki at slf4j.org
Mon Jan 23 17:50:03 CET 2006
Author: ceki
Date: Mon Jan 23 17:50:02 2006
New Revision: 515
Modified:
slf4j/trunk/src/java/org/slf4j/Marker.java
slf4j/trunk/src/java/org/slf4j/impl/BasicMarker.java
Log:
- added contains(Marker) method to the Marker interface
- Implementation of contains(Marker) in BasicMarker
Modified: slf4j/trunk/src/java/org/slf4j/Marker.java
==============================================================================
--- slf4j/trunk/src/java/org/slf4j/Marker.java (original)
+++ slf4j/trunk/src/java/org/slf4j/Marker.java Mon Jan 23 17:50:02 2006
@@ -93,6 +93,16 @@
*/
public Iterator iterator();
+ /**
+ * Does this marker contain the 'other' marker? Marker A is defined to
+ * contain marker B, if A == B or if B is a child of A.
+ *
+ * @param other The marker to test for inclusion.
+ * @throws IllegalArgumentException if 'other' is null
+ * @return Whether this marker contains the other marker.
+ */
+ public boolean contains(Marker other);
+
// void makeImmutable();
// public boolean isImmutable();
}
Modified: slf4j/trunk/src/java/org/slf4j/impl/BasicMarker.java
==============================================================================
--- slf4j/trunk/src/java/org/slf4j/impl/BasicMarker.java (original)
+++ slf4j/trunk/src/java/org/slf4j/impl/BasicMarker.java Mon Jan 23 17:50:02 2006
@@ -103,4 +103,24 @@
// could not find markerToRemove
return false;
}
+
+ public boolean contains(Marker other) {
+ if(other == null) {
+ throw new IllegalArgumentException("Other cannot be null");
+ }
+
+ if(this == other) {
+ return true;
+ }
+
+ if (hasChildren()) {
+ for(int i = 0; i < children.size(); i++) {
+ Marker child = (Marker) children.get(i);
+ if(child.contains(other)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}
More information about the slf4j-dev
mailing list