Top Description Inners Fields Constructors Methods
org.apache.logging.log4j

public final Class MarkerManager

extends Object
Class Inheritance
Imports
com.google.errorprone.annotations.InlineMe, java.util.Arrays, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, org.apache.logging.log4j.util.PerformanceSensitive, .StringBuilderFormattable

Applications create Markers by using the Marker Manager. All Markers created by this Manager are immutable.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
MarkerManager.Log4jMarker

Consider this class private, it is only public to satisfy Jackson for XML and JSON IO.

Field Summary

Modifier and TypeField and Description
private static final ConcurrentMap<String, Marker>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
clear()

Clears all markers.

public static boolean

Returns:

true if the marker exists.
exists
(final String
the marker name
key
)

Tests existence of the given marker.

public static Marker

Returns:

The Marker with the specified name.
getMarker
(final String
The name of the Marker.
name
)

Retrieves a Marker or create a Marker that has no parent.

public static Marker

Returns:

The Marker with the specified name.
getMarker
(final String
The name of the Marker.
name
,
final String
The name of the parent Marker.
parent
)
Deprecated Use the Marker add or set methods to add parent Markers. Will be removed by final GA release.

Retrieves or creates a Marker with the specified parent.

public static Marker

Returns:

The Marker with the specified name.
getMarker
(final String
The name of the Marker.
name
,
final Marker
The parent Marker.
parent
)
Deprecated Use the Marker add or set methods to add parent Markers. Will be removed by final GA release.

Retrieves or creates a Marker with the specified parent.

private static void
requireNonNull(final Object obj, final String message)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MARKERSback to summary
private static final ConcurrentMap<String, Marker> MARKERS

Constructor Detail

MarkerManagerback to summary
private MarkerManager()

Method Detail

clearback to summary
public static void clear()

Clears all markers.

existsback to summary
public static boolean exists(final String key)

Tests existence of the given marker.

Parameters
key:String

the marker name

Returns:boolean

true if the marker exists.

Since
2.4
getMarkerback to summary
public static Marker getMarker(final String name)

Retrieves a Marker or create a Marker that has no parent.

Parameters
name:String

The name of the Marker.

Returns:Marker

The Marker with the specified name.

Exceptions
IllegalArgumentException:
if the argument is null
getMarkerback to summary
public static Marker getMarker(final String name, final String parent)

Deprecated

Use the Marker add or set methods to add parent Markers. Will be removed by final GA release.

Retrieves or creates a Marker with the specified parent. The parent must have been previously created.

Parameters
name:String

The name of the Marker.

parent:String

The name of the parent Marker.

Returns:Marker

The Marker with the specified name.

Annotations
@Deprecated
Exceptions
IllegalArgumentException:
if the parent Marker does not exist.
getMarkerback to summary
public static Marker getMarker(final String name, final Marker parent)

Deprecated

Use the Marker add or set methods to add parent Markers. Will be removed by final GA release.

Retrieves or creates a Marker with the specified parent.

Parameters
name:String

The name of the Marker.

parent:Marker

The parent Marker.

Returns:Marker

The Marker with the specified name.

Annotations
@InlineMe
replacement:MarkerManager.getMarker(name).addParents(parent)
imports:MarkerManager
@Deprecated
Exceptions
IllegalArgumentException:
if any argument is null
requireNonNullback to summary
private static void requireNonNull(final Object obj, final String message)
org.apache.logging.log4j back to summary

public Class MarkerManager.Log4jMarker

extends Object
implements Marker, StringBuilderFormattable
Class Inheritance
All Implemented Interfaces
org.apache.logging.log4j.util.StringBuilderFormattable, org.apache.logging.log4j.Marker, java.io.Serializable

Consider this class private, it is only public to satisfy Jackson for XML and JSON IO.

The actual Marker implementation.

Internal Note

We could make this class package private instead of public if the class org.apache.logging.log4j.core.jackson.MarkerMixIn is moved to this package and would of course stay in its current module.

Field Summary

Modifier and TypeField and Description
private final String
private volatile Marker[]
private static final long

Constructor Summary

AccessConstructor and Description
private
Log4jMarker()

Required by JAXB and Jackson for XML and JSON IO.

public
Log4jMarker(final String
the name of the Marker.
name
)

Constructs a new Marker.

Method Summary

Modifier and TypeMethod and Description
private static void
addParentInfo(final StringBuilder sb, final Marker... parents)

public synchronized Marker
addParents(final Marker...
The parent markers to add.
parentMarkers
)

Implements org.apache.logging.log4j.Marker.addParents.

Adds a Marker as a parent to this Marker.

private static boolean
checkParent(final Marker parent, final Marker marker)

private static boolean
contains(final Marker parent, final Marker... localParents)

public boolean
equals(final Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Implements org.apache.logging.log4j.Marker.equals.

Returns true if the given marker has the same name as this marker.

public void
formatTo(final StringBuilder
the StringBuilder to write into
sb
)

Implements org.apache.logging.log4j.util.StringBuilderFormattable.formatTo.

Writes a text representation of this object into the specified StringBuilder, ideally without allocating temporary objects.

public String
getName()

Implements org.apache.logging.log4j.Marker.getName.

Returns the name of this Marker.

public Marker[]
getParents()

Implements org.apache.logging.log4j.Marker.getParents.

Returns a list of parents of this Marker.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements org.apache.logging.log4j.Marker.hashCode.

Returns a hash code value based on the name of this marker.

public boolean
hasParents()

Implements org.apache.logging.log4j.Marker.hasParents.

Indicates whether this Marker has references to any other Markers.

public boolean
isInstanceOf(final Marker
The Marker to check.
marker
)

Implements org.apache.logging.log4j.Marker.isInstanceOf.

Checks whether this Marker is an instance of the specified Marker.

public boolean
isInstanceOf(final String
The name of the Marker.
markerName
)

Implements org.apache.logging.log4j.Marker.isInstanceOf.

Checks whether this Marker is an instance of the specified Marker.

public synchronized boolean
remove(final Marker
The marker to remove.
parent
)

Implements org.apache.logging.log4j.Marker.remove.

Removes the specified Marker as a parent of this Marker.

public Marker
setParents(final Marker...
The new set of parent Markers or null to clear the parents.
markers
)

Implements org.apache.logging.log4j.Marker.setParents.

Replaces the set of parent Markers with the provided Markers.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

nameback to summary
private final String name
parentsback to summary
private volatile Marker[] parents
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

Log4jMarkerback to summary
private Log4jMarker()

Required by JAXB and Jackson for XML and JSON IO.

Annotations
@SuppressWarnings:unused
Log4jMarkerback to summary
public Log4jMarker(final String name)

Constructs a new Marker.

Parameters
name:String

the name of the Marker.

Exceptions
IllegalArgumentException:
if the argument is null

Method Detail

addParentInfoback to summary
private static void addParentInfo(final StringBuilder sb, final Marker... parents)
Annotations
@PerformanceSensitive:allocation
addParentsback to summary
public synchronized Marker addParents(final Marker... parentMarkers)

Implements org.apache.logging.log4j.Marker.addParents.

Doc from org.apache.logging.log4j.Marker.addParents.

Adds a Marker as a parent to this Marker.

Parameters
parentMarkers:Marker[]

The parent markers to add.

Returns:Marker

The current Marker object, thus allowing multiple adds to be concatenated.

Annotations
@Override
checkParentback to summary
private static boolean checkParent(final Marker parent, final Marker marker)
Annotations
@PerformanceSensitive:allocation, unrolled
containsback to summary
private static boolean contains(final Marker parent, final Marker... localParents)
Annotations
@PerformanceSensitive:allocation
equalsback to summary
public boolean equals(final Object o)

Overrides java.lang.Object.equals.

Implements org.apache.logging.log4j.Marker.equals.

Doc from org.apache.logging.log4j.Marker.equals.

Returns true if the given marker has the same name as this marker.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if the given marker has the same name as this marker.

Annotations
@Override
formatToback to summary
public void formatTo(final StringBuilder sb)

Implements org.apache.logging.log4j.util.StringBuilderFormattable.formatTo.

Doc from org.apache.logging.log4j.util.StringBuilderFormattable.formatTo.

Writes a text representation of this object into the specified StringBuilder, ideally without allocating temporary objects.

Parameters
sb:StringBuilder

the StringBuilder to write into

Annotations
@Override
getNameback to summary
public String getName()

Implements org.apache.logging.log4j.Marker.getName.

Doc from org.apache.logging.log4j.Marker.getName.

Returns the name of this Marker.

Returns:String

The name of the Marker.

Annotations
@Override
getParentsback to summary
public Marker[] getParents()

Implements org.apache.logging.log4j.Marker.getParents.

Doc from org.apache.logging.log4j.Marker.getParents.

Returns a list of parents of this Marker.

Returns:Marker[]

The parent Markers or null if this Marker has no parents.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements org.apache.logging.log4j.Marker.hashCode.

Doc from org.apache.logging.log4j.Marker.hashCode.

Returns a hash code value based on the name of this marker. Markers are equal if they have the same name.

Returns:int

the computed hash code

Annotations
@Override
hasParentsback to summary
public boolean hasParents()

Implements org.apache.logging.log4j.Marker.hasParents.

Doc from org.apache.logging.log4j.Marker.hasParents.

Indicates whether this Marker has references to any other Markers.

Returns:boolean

true if the Marker has parent Markers

Annotations
@Override
isInstanceOfback to summary
public boolean isInstanceOf(final Marker marker)

Implements org.apache.logging.log4j.Marker.isInstanceOf.

Doc from org.apache.logging.log4j.Marker.isInstanceOf.

Checks whether this Marker is an instance of the specified Marker.

Parameters
marker:Marker

The Marker to check.

Returns:boolean

true if this Marker or one of its ancestors is the specified Marker, false otherwise.

Annotations
@Override
@PerformanceSensitive:allocation, unrolled
isInstanceOfback to summary
public boolean isInstanceOf(final String markerName)

Implements org.apache.logging.log4j.Marker.isInstanceOf.

Doc from org.apache.logging.log4j.Marker.isInstanceOf.

Checks whether this Marker is an instance of the specified Marker.

Parameters
markerName:String

The name of the Marker.

Returns:boolean

true if this Marker or one of its ancestors matches the specified name, false otherwise.

Annotations
@Override
@PerformanceSensitive:allocation, unrolled
removeback to summary
public synchronized boolean remove(final Marker parent)

Implements org.apache.logging.log4j.Marker.remove.

Doc from org.apache.logging.log4j.Marker.remove.

Removes the specified Marker as a parent of this Marker.

Parameters
parent:Marker

The marker to remove.

Returns:boolean

true if the marker was removed.

Annotations
@Override
setParentsback to summary
public Marker setParents(final Marker... markers)

Implements org.apache.logging.log4j.Marker.setParents.

Doc from org.apache.logging.log4j.Marker.setParents.

Replaces the set of parent Markers with the provided Markers.

Parameters
markers:Marker[]

The new set of parent Markers or null to clear the parents.

Returns:Marker

The current Marker object.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override