001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017 package org.apache.logging.log4j.spi; 018 019 import java.util.Map; 020 021 /** 022 * 023 */ 024 public interface ThreadContextMap { 025 /** 026 * Put a context value (the <code>o</code> parameter) as identified 027 * with the <code>key</code> parameter into the current thread's 028 * context map. 029 * <p/> 030 * <p>If the current thread does not have a context map it is 031 * created as a side effect. 032 * @param key The key name. 033 * @param value The key value. 034 */ 035 void put(final String key, final String value); 036 037 /** 038 * Get the context identified by the <code>key</code> parameter. 039 * <p/> 040 * <p>This method has no side effects. 041 * @param key The key to locate. 042 * @return The value associated with the key or null. 043 */ 044 String get(final String key); 045 046 /** 047 * Remove the the context identified by the <code>key</code> 048 * parameter. 049 * @param key The key to remove. 050 */ 051 void remove(final String key); 052 053 /** 054 * Clear the context. 055 */ 056 void clear(); 057 058 /** 059 * Determine if the key is in the context. 060 * @param key The key to locate. 061 * @return True if the key is in the context, false otherwise. 062 */ 063 boolean containsKey(final String key); 064 065 /** 066 * Get a copy of current thread's context Map. 067 * @return a copy of the context. 068 */ 069 Map<String, String> getContext(); 070 071 /** 072 * Return the actual context Map. 073 * @return the actual context Map. 074 */ 075 Map<String, String> get(); 076 077 /** 078 * Returns true if the Map is empty. 079 * @return true if the Map is empty, false otherwise. 080 */ 081 boolean isEmpty(); 082 }