[slf4j-dev] svn commit: r108 - slf4j/branches/marker-experiment/src/java/org/slf4j

ceki at slf4j.org ceki at slf4j.org
Mon Jul 4 20:51:43 CEST 2005


Author: ceki
Date: Mon Jul  4 20:51:42 2005
New Revision: 108

Added:
   slf4j/branches/marker-experiment/src/java/org/slf4j/CompositeMarker.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/Marker.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/StarMarker.java
Log:
added Marker classes

Added: slf4j/branches/marker-experiment/src/java/org/slf4j/CompositeMarker.java
==============================================================================
--- (empty file)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/CompositeMarker.java	Mon Jul  4 20:51:42 2005
@@ -0,0 +1,102 @@
+/* 
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ * 
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+
+package org.slf4j;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+
+class CompositeMarker extends Marker {
+  static Map markerMap = new HashMap();
+  List children;
+  boolean immutable = false;
+
+  CompositeMarker(String name) {
+    super(name);
+  }
+
+  
+  public boolean matches(Marker marker) {
+    if (this == marker) {
+      return true;
+    }
+    if (children != null) {
+      for (int i = 0; i < children.size(); i++) {
+        Marker child = (Marker) children.get(i);
+        if (child.matches(marker)) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  public boolean matches(String name) {
+    if (this.name.equals(name)) {
+      return true;
+    }
+    if (children != null) {
+      for (int i = 0; i < children.size(); i++) {
+        Marker child = (Marker) children.get(i);
+        if (child.matches(name)) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  public void add(Marker child) {
+    if (immutable) {
+      throw new IllegalStateException(
+        "Cannot add child [" + child.getName()
+        + "] to immutable Marker named [" + name + "].");
+    }
+    if (children == null) {
+      children = new Vector();
+    }
+    children.add(child);
+  }
+
+  void makeImmutable() {
+    immutable = true;
+  }
+
+  public boolean isImmutable() {
+    return immutable;
+  }
+}

Added: slf4j/branches/marker-experiment/src/java/org/slf4j/Marker.java
==============================================================================
--- (empty file)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/Marker.java	Mon Jul  4 20:51:42 2005
@@ -0,0 +1,116 @@
+/* 
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ * 
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+
+public class Marker {
+  public static final Marker STAR = new StarMarker();
+  static Map markerMap = new Hashtable();
+  String name;
+
+  Marker(String name) {
+    this.name = name;
+  }
+
+  public static final Marker getMarker(String name) {
+    if (name == null) {
+      throw new IllegalArgumentException("Marker name cannot be null");
+    }
+    if (name.equals(StarMarker.STAR_STR)) {
+      return STAR;
+    }
+
+    Marker marker = (Marker) markerMap.get(name);
+    if (marker == null) {
+      marker = new Marker(name);
+      markerMap.put(name, marker);
+    }
+
+    return marker;
+  }
+
+  //  public final static Marker getCompositeMarker(String name) {
+  //    if (name == null) {
+  //      throw new IllegalArgumentException("Marker name cannot be null");
+  //    }
+  //    Marker marker = (Marker) markerMap.get(name);
+  //    if (marker == null) {
+  //      marker = new CompositeMarker(name);
+  //      markerMap.put(name, marker);
+  //    }
+  //
+  //    return marker;
+  //  }
+  public String getName() {
+    return name;
+  }
+
+  public boolean matches(Marker marker) {
+    if ((this == marker) || (STAR == marker)) {
+      return true;
+    }
+
+    return false;
+  }
+
+  public boolean matches(String name) {
+    if (this.name.equals(name)) {
+      return true;
+    }
+
+    // Every marker matches "*"
+    if (StarMarker.STAR_STR.equals(name)) {
+      return true;
+    }
+    return false;
+  }
+
+  //  public void add(Marker child) {
+  //      throw new IllegalStateException(
+  //        "Cannot add child [" + child.getName()
+  //        + "] to immutable Marker named [" + name + "].");
+  //    
+  //  }
+  //
+  //  void makeImmutable() {
+  //      // primitive marker is always immutable
+  //  }
+  //
+  //  public boolean isImmutable() {
+  //    return true;
+  //  }
+}

Added: slf4j/branches/marker-experiment/src/java/org/slf4j/StarMarker.java
==============================================================================
--- (empty file)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/StarMarker.java	Mon Jul  4 20:51:42 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+package org.slf4j;
+
+class StarMarker extends Marker {
+  static final String STAR_STR = "*";
+
+  StarMarker() {
+    super(STAR_STR);
+  }
+
+  public boolean matches(Marker marker) {
+    return true;
+  }
+
+  public boolean matches(String name) {
+    return true;
+  }
+}



More information about the slf4j-dev mailing list