1 24 25 package org.slf4j.helpers; 26 27 import java.util.HashMap ; 28 import java.util.Map ; 29 30 import org.slf4j.IMarkerFactory; 31 import org.slf4j.Marker; 32 33 42 public class BasicMarkerFactory implements IMarkerFactory { 43 44 Map markerMap = new HashMap (); 45 46 52 public BasicMarkerFactory() { 53 } 54 55 62 public synchronized Marker getMarker(String name) { 63 if (name == null) { 64 throw new IllegalArgumentException ("Marker name cannot be null"); 65 } 66 67 Marker marker = (Marker) markerMap.get(name); 68 if (marker == null) { 69 marker = new BasicMarker(name); 70 markerMap.put(name, marker); 71 } 72 return marker; 73 } 74 75 78 public synchronized boolean exists(String name) { 79 if (name == null) { 80 return false; 81 } 82 return markerMap.containsKey(name); 83 } 84 85 public boolean detachMarker(String name) { 86 if(name == null) { 87 return false; 88 } 89 return (markerMap.remove(name) != null); 90 } 91 92 } 93 | Popular Tags |