Class RendererMap
ObjectRenderer.- Since:
- version 1.0
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static ObjectRenderer(package private) Hashtable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddRenderer(RendererSupport repository, String renderedClassName, String renderingClassName) Add a renderer to a hierarchy passed as parameter.voidclear()Find the appropriate renderer for the class type of theoparameter.Search the parents ofclazzfor a renderer.Syntactic sugar method that callsget(Class)with the class of the object parameter.voidput(Class clazz, ObjectRenderer or) Register anObjectRendererforclazz.(package private) ObjectRenderer
-
Field Details
-
map
Hashtable map -
defaultRenderer
-
-
Constructor Details
-
RendererMap
public RendererMap()
-
-
Method Details
-
addRenderer
public static void addRenderer(RendererSupport repository, String renderedClassName, String renderingClassName) Add a renderer to a hierarchy passed as parameter. -
findAndRender
Find the appropriate renderer for the class type of theoparameter. This is accomplished by calling theget(Class)method. Once a renderer is found, it is applied on the objectoand the result is returned as aString. -
get
Syntactic sugar method that callsget(Class)with the class of the object parameter. -
get
Search the parents ofclazzfor a renderer. The renderer closest in the hierarchy will be returned. If no renderers could be found, then the default renderer is returned.The search first looks for a renderer configured for
clazz. If a renderer could not be found, then the search continues by looking at all the interfaces implemented byclazzincluding the super-interfaces of each interface. If a renderer cannot be found, then the search looks for a renderer defined for the parent (superclass) ofclazz. If that fails, then all the interfaces implemented by the parent ofclazzare searched and so on.For example, if A0, A1, A2 are classes and X0, X1, X2, Y0, Y1 are interfaces where A2 extends A1 which in turn extends A0 and similarly X2 extends X1 which extends X0 and Y1 extends Y0. Let us also assume that A1 implements the Y0 interface and that A2 implements the X2 interface.
The table below shows the results returned by the
get(A2.class)method depending on the renderers added to the map.Added renderers Value returned by get(A2.class)A0RendererA0RendererA0Renderer, A1RendererA1RendererX0RendererX0RendererA1Renderer, X0RendererX0RendererThis search algorithm is not the most natural, although it is particularly easy to implement. Future log4j versions may implement a more intuitive search algorithm. However, the present algorithm should be acceptable in the vast majority of circumstances.
-
searchInterfaces
-
getDefaultRenderer
-
clear
public void clear() -
put
Register anObjectRendererforclazz.
-