[slf4j-dev] svn commit: r1144 - in slf4j/trunk/slf4j-api/src/main/java/org/slf4j: . helpers impl
ceki at slf4j.org
ceki at slf4j.org
Tue Sep 23 20:18:36 CEST 2008
Author: ceki
Date: Tue Sep 23 20:18:36 2008
New Revision: 1144
Modified:
slf4j/trunk/slf4j-api/src/main/java/org/slf4j/Marker.java
slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarker.java
slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
Log:
Markers contains "references" to other markers. We no longer mention child markers.
This fixes bug 100:
http://bugzilla.slf4j.org/show_bug.cgi?id=100
Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/Marker.java
==============================================================================
--- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/Marker.java (original)
+++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/Marker.java Tue Sep 23 20:18:36 2008
@@ -34,8 +34,8 @@
* marker data.
*
* <p>
- * Markers can contain child markers, which in turn can contain children of
- * their own.
+ * Markers can contain references to other markers, which in turn may contain
+ * references of their own.
*
* @author Ceki Gülcü
*/
@@ -59,42 +59,48 @@
public String getName();
/**
- * Add a child Marker to this Marker.
+ * Add a reference to another Marker.
*
- * @param child
- * a child marker
+ * @param reference
+ * a reference to another marker
* @throws IllegalArgumentException
- * if 'child' is null
+ * if 'reference' is null
*/
- public void add(Marker child);
+ public void add(Marker reference);
/**
- * Remove a child Marker.
+ * Remove a marker reference.
*
- * @param child
- * the child Marker to remove
- * @return true if child could be found and removed, false otherwise.
+ * @param reference
+ * the marker reference to remove
+ * @return true if reference could be found and removed, false otherwise.
*/
- public boolean remove(Marker child);
+ public boolean remove(Marker reference);
/**
- * Does this marker have children?
- *
- * @return true if this marker has children, false otherwise.
+ * @deprecated Replaced by {@link #hasReferences()}.
*/
public boolean hasChildren();
-
+
+ /**
+ * Does this marker have any references?
+ *
+ * @return true if this marker has one or more references, false otherwise.
+ */
+ public boolean hasReferences();
+
/**
- * Returns an Iterator which can be used to iterate over the children of this
- * marker. An empty iterator is returned when this marker has no children.
+ * Returns an Iterator which can be used to iterate over the references of this
+ * marker. An empty iterator is returned when this marker has no references.
*
- * @return Iterator over the children of this marker
+ * @return Iterator over the references of this marker
*/
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.
+ * Does this marker contain a reference to the 'other' marker? Marker A is defined
+ * to contain marker B, if A == B or if B is referenced by A, or if B is referenced
+ * by any one of A's references (recursively).
*
* @param other
* The marker to test for inclusion.
Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarker.java
==============================================================================
--- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarker.java (original)
+++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarker.java Tue Sep 23 20:18:36 2008
@@ -32,7 +32,7 @@
import org.slf4j.Marker;
/**
- * An simple implementation of the {@link Marker} interface.
+ * A simple implementation of the {@link Marker} interface.
*
* @author Ceki Gülcü
* @author Joern Huxhorn
@@ -42,7 +42,7 @@
private static final long serialVersionUID = 1803952589649545191L;
private final String name;
- private List children;
+ private List refereceList;
BasicMarker(String name) {
if (name == null) {
@@ -55,55 +55,58 @@
return name;
}
- public synchronized void add(Marker markerToAddAsChild) {
- if (markerToAddAsChild == null) {
+ public synchronized void add(Marker reference) {
+ if (reference == null) {
throw new IllegalArgumentException(
- "A null value cannot be added to a Marker as child.");
+ "A null value cannot be added to a Marker as reference.");
}
- // no point in adding the child multiple times
- if (this.contains(markerToAddAsChild)) {
+ // no point in adding the reference multiple times
+ if (this.contains(reference)) {
return;
- } else if (markerToAddAsChild.contains(this)) { // avoid recursion
- // a potential child should not its future parent as a child
+ } else if (reference.contains(this)) { // avoid recursion
+ // a potential reference should not its future "parent" as a reference
return;
} else {
- // let's add the child
- if (children == null) {
- children = new Vector();
+ // let's add the reference
+ if (refereceList == null) {
+ refereceList = new Vector();
}
- children.add(markerToAddAsChild);
+ refereceList.add(reference);
}
}
- public synchronized boolean hasChildren() {
- return ((children != null) && (children.size() > 0));
+ public synchronized boolean hasReferences() {
+ return ((refereceList != null) && (refereceList.size() > 0));
+ }
+
+ public boolean hasChildren() {
+ return hasReferences();
}
public synchronized Iterator iterator() {
- if (children != null) {
- return children.iterator();
+ if (refereceList != null) {
+ return refereceList.iterator();
} else {
return Collections.EMPTY_LIST.iterator();
}
}
- public synchronized boolean remove(Marker markerToRemove) {
- if (children == null) {
+ public synchronized boolean remove(Marker referenceToRemove) {
+ if (refereceList == null) {
return false;
}
- int size = children.size();
+ int size = refereceList.size();
for (int i = 0; i < size; i++) {
- Marker m = (Marker) children.get(i);
- if (markerToRemove.equals(m)) {
- children.remove(i);
+ Marker m = (Marker) refereceList.get(i);
+ if (referenceToRemove.equals(m)) {
+ refereceList.remove(i);
return true;
}
}
- // could not find markerToRemove
return false;
}
@@ -116,10 +119,10 @@
return true;
}
- if (hasChildren()) {
- for (int i = 0; i < children.size(); i++) {
- Marker child = (Marker) children.get(i);
- if (child.contains(other)) {
+ if (hasReferences()) {
+ for (int i = 0; i < refereceList.size(); i++) {
+ Marker ref = (Marker) refereceList.get(i);
+ if (ref.contains(other)) {
return true;
}
}
@@ -139,10 +142,10 @@
return true;
}
- if (hasChildren()) {
- for (int i = 0; i < children.size(); i++) {
- Marker child = (Marker) children.get(i);
- if (child.contains(name)) {
+ if (hasReferences()) {
+ for (int i = 0; i < refereceList.size(); i++) {
+ Marker ref = (Marker) refereceList.get(i);
+ if (ref.contains(name)) {
return true;
}
}
@@ -172,16 +175,16 @@
}
public String toString() {
- if (!this.hasChildren()) {
+ if (!this.hasReferences()) {
return this.getName();
}
Iterator it = this.iterator();
- Marker child;
+ Marker reference;
StringBuffer sb = new StringBuffer(this.getName());
sb.append(' ').append(OPEN);
while (it.hasNext()) {
- child = (Marker) it.next();
- sb.append(child.getName());
+ reference = (Marker) it.next();
+ sb.append(reference.getName());
if (it.hasNext()) {
sb.append(SEP);
}
Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
==============================================================================
--- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java (original)
+++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java Tue Sep 23 20:18:36 2008
@@ -46,7 +46,7 @@
* The unique instance of this class.
*/
public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
-
+
private StaticMarkerBinder() {
throw new UnsupportedOperationException("This code should never make it into the jar");
}
More information about the slf4j-dev
mailing list