Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
SLF4J API Source Code
SLF4J API is a simple API that allows to plug in any desired logging library
at deployment time.
Here is the source code for SLF4J API 2.0.4. You can download its pre-compiled version slf4j-api-2.0.4.jar at SLF4J Download Website.
✍: FYIcenter.com
⏎ org/slf4j/helpers/ThreadLocalMapOfStacks.java
package org.slf4j.helpers;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
/**
* A simple implementation of ThreadLocal backed Map containing values of type
* Deque<String>.
*
* @author Ceki Guuml;cü
* @since 2.0.0
*/
public class ThreadLocalMapOfStacks {
// BEWARE: Keys or values placed in a ThreadLocal should not be of a type/class
// not included in the JDK. See also https://jira.qos.ch/browse/LOGBACK-450
final ThreadLocal<Map<String, Deque<String>>> tlMapOfStacks = new ThreadLocal<>();
public void pushByKey(String key, String value) {
if (key == null)
return;
Map<String, Deque<String>> map = tlMapOfStacks.get();
if (map == null) {
map = new HashMap<>();
tlMapOfStacks.set(map);
}
Deque<String> deque = map.get(key);
if (deque == null) {
deque = new ArrayDeque<>();
}
deque.push(value);
map.put(key, deque);
}
public String popByKey(String key) {
if (key == null)
return null;
Map<String, Deque<String>> map = tlMapOfStacks.get();
if (map == null)
return null;
Deque<String> deque = map.get(key);
if (deque == null)
return null;
return deque.pop();
}
public Deque<String> getCopyOfDequeByKey(String key) {
if (key == null)
return null;
Map<String, Deque<String>> map = tlMapOfStacks.get();
if (map == null)
return null;
Deque<String> deque = map.get(key);
if (deque == null)
return null;
return new ArrayDeque<String>(deque);
}
/**
* Clear the deque(stack) referenced by 'key'.
*
* @param key identifies the stack
*
* @since 2.0.0
*/
public void clearDequeByKey(String key) {
if (key == null)
return;
Map<String, Deque<String>> map = tlMapOfStacks.get();
if (map == null)
return;
Deque<String> deque = map.get(key);
if (deque == null)
return;
deque.clear();
}
}
⏎ org/slf4j/helpers/ThreadLocalMapOfStacks.java
Or download all of them as a single archive file:
File name: slf4j-api-2.0.4-sources.jar File size: 70304 bytes Release date: 2022-11-17 Download
⇒ Source Code for SLF4J Simple Logging
⇐ Downloading SLF4J Components
2020-02-13, ≈41🔥, 2💬
Popular Posts:
JDK 17 jdk.jdeps.jmod is the JMOD file for JDK 17 JDeps tool, which can be invoked by the "jdeps" co...
What JAR files are required to run sax\Counter.java provided in the Apache Xerces package? You can f...
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java"....
Java Architecture for XML Binding (JAXB) is a Java API that allows Java developers to map Java class...
JDK 11 jdk.jdeps.jmod is the JMOD file for JDK 11 JDeps tool, which can be invoked by the "jdeps" co...