[slf4j-dev] svn commit: r688 - in slf4j/trunk/slf4j-api/src/main/java/org/slf4j: . impl

seb at slf4j.org seb at slf4j.org
Wed Jan 24 20:05:35 CET 2007


Author: seb
Date: Wed Jan 24 20:05:35 2007
New Revision: 688

Modified:
   slf4j/trunk/slf4j-api/src/main/java/org/slf4j/Marker.java
   slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/BasicMarker.java
   slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/BasicMarkerFactory.java

Log:
Markers are now Serializable.
They do not need the MarkerFactory anymore.

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	Wed Jan 24 20:05:35 2007
@@ -33,6 +33,7 @@
 
 package org.slf4j;
 
+import java.io.Serializable;
 import java.util.Iterator;
 
 /**
@@ -46,7 +47,7 @@
  *
  * @author Ceki Gülcü
  */
-public interface Marker {
+public interface Marker extends Serializable {
  
   /**
    * This constant represents any marker, including a null marker.

Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/BasicMarker.java
==============================================================================
--- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/BasicMarker.java	(original)
+++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/BasicMarker.java	Wed Jan 24 20:05:35 2007
@@ -38,7 +38,6 @@
 import java.util.List;
 import java.util.Vector;
 
-import org.slf4j.IMarkerFactory;
 import org.slf4j.Marker;
 
 
@@ -55,13 +54,14 @@
  * @author Ceki Gülcü
  */
 public class BasicMarker implements Marker {
+
+  private static final long serialVersionUID = 1803952589649545191L;
+
   final String name;
   List children;
-  final IMarkerFactory factory;
   
-  BasicMarker(String name, IMarkerFactory factory) {
+  BasicMarker(String name) {
     this.name = name;
-    this.factory = factory;
   }
 
   public String getName() {
@@ -127,16 +127,28 @@
     return false;
   }
   
+  /**
+   * This method is mainly used with Expression Evaluators.
+   */
   public boolean contains(String name) {
     if(name == null) {
-      return false;
+      throw new IllegalArgumentException("Other cannot be null");
     }
-    if(factory.exists(name)) {
-      Marker other = factory.getMarker(name);
-      return contains(other);     
-    } else {
-      return false;
+    
+    if (this.name.equals(name)) {
+      return true;
     }
+    
+    if (hasChildren()) {
+      for(int i = 0; i < children.size(); i++) {
+        Marker child = (Marker) children.get(i);
+        if(child.contains(name)) {
+          return true;
+        }
+      }     
+    }
+    
+    return false;
   }
 
 }

Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/BasicMarkerFactory.java
==============================================================================
--- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/BasicMarkerFactory.java	(original)
+++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/BasicMarkerFactory.java	Wed Jan 24 20:05:35 2007
@@ -75,7 +75,7 @@
 
     Marker marker = (Marker) markerMap.get(name);
     if (marker == null) {
-      marker = new BasicMarker(name, this);
+      marker = new BasicMarker(name);
       markerMap.put(name, marker);
     }
     return marker;



More information about the slf4j-dev mailing list