View Javadoc

1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 1999-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  
11  package ch.qos.logback.core.pattern;
12  
13  public class ConverterUtil {
14  
15    /**
16     * Start converters in the chain of converters.
17     * @param head
18     */
19    public static void startConverters(Converter head) {
20      Converter c = head;
21      while (c != null) {
22        if (c instanceof DynamicConverter) {
23          DynamicConverter dc = (DynamicConverter) c;
24          dc.start();
25        } else if(c instanceof CompositeConverter){
26          CompositeConverter cc = (CompositeConverter) c;
27          Converter childConverter = cc.childConverter;
28          startConverters(childConverter);
29        }
30        c = c.getNext();
31      }
32    }
33  
34    
35    public static<E> Converter<E> findTail(Converter<E> head) {
36      Converter<E> c = head;
37      while (c != null) {
38        Converter<E> next = c.getNext();
39        if (next == null) {
40          break;
41        } else {
42          c = next;
43        }
44      }
45      return c;
46    }
47  }