001/** 002 * Copyright (c) 2004-2011 QOS.ch 003 * All rights reserved. 004 * 005 * Permission is hereby granted, free of charge, to any person obtaining 006 * a copy of this software and associated documentation files (the 007 * "Software"), to deal in the Software without restriction, including 008 * without limitation the rights to use, copy, modify, merge, publish, 009 * distribute, sublicense, and/or sell copies of the Software, and to 010 * permit persons to whom the Software is furnished to do so, subject to 011 * the following conditions: 012 * 013 * The above copyright notice and this permission notice shall be 014 * included in all copies or substantial portions of the Software. 015 * 016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 017 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 019 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 020 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 021 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 022 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 023 * 024 */ 025package org.slf4j; 026 027import java.io.Serializable; 028import java.util.Iterator; 029 030/** 031 * Markers are named objects used to enrich log statements. Conforming logging 032 * system implementations of SLF4J should determine how information conveyed by 033 * any markers are used, if at all. Many conforming logging systems ignore marker 034 * data entirely. 035 * 036 * <p>Markers can contain references to nested markers, which in turn may 037 * contain references of their own. Note that the fluent API (new in 2.0) allows adding 038 * multiple markers to a logging statement. It is often preferable to use 039 * multiple markers instead of nested markers. 040 * </p> 041 * 042 * @author Ceki Gülcü 043 */ 044public interface Marker extends Serializable { 045 046 /** 047 * This constant represents any marker, including a null marker. 048 */ 049 public final String ANY_MARKER = "*"; 050 051 /** 052 * This constant represents any non-null marker. 053 */ 054 public final String ANY_NON_NULL_MARKER = "+"; 055 056 /** 057 * Get the name of this Marker. 058 * 059 * @return name of marker 060 */ 061 public String getName(); 062 063 /** 064 * Add a reference to another Marker. 065 * 066 * <p>Note that the fluent API allows adding multiple markers to a logging statement. 067 * It is often preferable to use multiple markers instead of nested markers. 068 * </p> 069 * 070 * @param reference 071 * a reference to another marker 072 * @throws IllegalArgumentException 073 * if 'reference' is null 074 * 075 * @deprecated Markers are now immutable and no longer support children. 076 */ 077 public void add(Marker reference); 078 079 /** 080 * Remove a marker reference. 081 * 082 * @param reference 083 * the marker reference to remove 084 * @return true if reference could be found and removed, false otherwise. 085 * 086 * @deprecated Markers are now immutable and no longer support children. 087 */ 088 public boolean remove(Marker reference); 089 090 /** 091 * @deprecated Markers are now immutable and no longer support children. 092 */ 093 @Deprecated 094 public boolean hasChildren(); 095 096 /** 097 * Does this marker have any references? 098 * 099 * @return true if this marker has one or more references, false otherwise. 100 * @deprecated Markers are now immutable and no longer support children. 101 */ 102 public boolean hasReferences(); 103 104 /** 105 * Returns an Iterator which can be used to iterate over the references of this 106 * marker. An empty iterator is returned when this marker has no references. 107 * 108 * @return Iterator over the references of this marker 109 * @deprecated Markers are now immutable and no longer support children. 110 */ 111 public Iterator<Marker> iterator(); 112 113 /** 114 * Does this marker contain a reference to the 'other' marker? Marker A is defined 115 * to contain marker B, if A == B or if B is referenced by A, or if B is referenced 116 * by any one of A's references (recursively). 117 * 118 * @param other 119 * The marker to test for inclusion. 120 * @throws IllegalArgumentException 121 * if 'other' is null 122 * @return Whether this marker contains the other marker. 123 * @deprecated Markers are now immutable and no longer support children. 124 */ 125 public boolean contains(Marker other); 126 127 /** 128 * Does this marker contain the marker named 'name'? 129 * 130 * If 'name' is null the returned value is always false. 131 * 132 * @param name The marker name to test for inclusion. 133 * @return Whether this marker contains the other marker. 134 * @deprecated Markers are now immutable and no longer support children. 135 */ 136 public boolean contains(String name); 137 138 /** 139 * Markers are considered equal if they have the same name. 140 * 141 * @param o 142 * @return true, if this.name equals o.name 143 * 144 * @since 1.5.1 145 */ 146 public boolean equals(Object o); 147 148 /** 149 * Compute the hash code based on the name of this marker. 150 * Note that markers are considered equal if they have the same name. 151 * 152 * @return the computed hashCode 153 * @since 1.5.1 154 */ 155 public int hashCode(); 156 157}