Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
 
 package ch.qos.logback.core.pattern;
 
 
 import java.util.Map;
 
 
 abstract public class PatternLayoutBase<E> extends LayoutBase<E> {
 
   Converter<E> head;
 
 
   protected boolean outputPatternAsHeader = false;

  
Concrete implementations of this class are responsible for elaborating the mapping between pattern words and converters.

Returns:
A map associating pattern words to the names of converter classes
 
   abstract public Map<StringStringgetDefaultConverterMap();

  
Returns a map where the default converter map is merged with the map contained in the context.
 
     Map<StringStringeffectiveMap = new HashMap<StringString>();
 
     // add the least specific map fist
     Map<StringStringdefaultMap = getDefaultConverterMap();
     if (defaultMap != null) {
       effectiveMap.putAll(defaultMap);
     }
 
     // contextMap is more specific than the default map
     Context context = getContext();
     if (context != null) {
       @SuppressWarnings("unchecked")
       Map<StringStringcontextMap = (Map<StringString>) context
       if (contextMap != null) {
         effectiveMap.putAll(contextMap);
       }
     }
     // set the most specific map last
     effectiveMap.putAll();
     return effectiveMap;
   }
 
   public void start() {
     if( == null || .length() == 0) {
       addError("Empty or null pattern.");
       return;
     }
     try { 
       Parser<E> p = new Parser<E>();
       if (getContext() != null) {
         p.setContext(getContext());
       }
       Node t = p.parse();
       this. = p.compile(tgetEffectiveConverterMap());
       if ( != null) {
         .process();
       }
       ConverterUtil.setContextForConverters(getContext(), );
       ConverterUtil.startConverters(this.);
       super.start();
     } catch (ScanException sce) {
       StatusManager sm = getContext().getStatusManager();
       sm.add(new ErrorStatus("Failed to parse pattern \"" + getPattern()
           + "\"."thissce));
     }
   }
 
  public void setPostCompileProcessor(
      PostCompileProcessor<E> postCompileProcessor) {
    this. = postCompileProcessor;
  }

  

Deprecated:
Use ConverterUtil.setContextForConverters(ch.qos.logback.core.Context,ch.qos.logback.core.pattern.Converter) instead. This method will be removed in future releases.
Parameters:
head
  protected void setContextForConverters(Converter<E> head) {
    ConverterUtil.setContextForConverters(getContext(), head);
  }
  protected String writeLoopOnConverters(E event) {
    StringBuilder buf = new StringBuilder(128);
    Converter<E> c = ;
    while (c != null) {
      c.write(bufevent);
      c = c.getNext();
    }
    return buf.toString();
  }
  public String getPattern() {
    return ;
  }
  public void setPattern(String pattern) {
    this. = pattern;
  }
  public String toString() {
    return this.getClass().getName() + "(\"" + getPattern() + "\")";
  }
    return ;
  }
  
  }
  public boolean isOutputPatternAsHeader() {
    return ;
  }
  public void setOutputPatternAsHeader(boolean outputPatternAsHeader) {
    this. = outputPatternAsHeader;
  }
    else
      return super.getPresentationHeader();
  }
New to GrepCode? Check out our FAQ X