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;
abstract public class FormattingConverter<E> extends Converter<E> {
  static final int INITIAL_BUF_SIZE = 256;
  static final int MAX_CAPACITY = 1024;
  
  final public FormatInfo getFormattingInfo() {
    return ;
  }
  final public void setFormattingInfo(FormatInfo formattingInfo) {
    if (this. != null) {
      throw new IllegalStateException("FormattingInfo has been already set");
    }
    this. = formattingInfo;
  }
  final public void write(StringBuilder buf, E event) {
    String s = convert(event);
    
    if( == null) {
      buf.append(s);
      return;
    }
    
    int min = .getMin();
    int max = .getMax();
    if (s == null) {
      if (0 < min)
        SpacePadder.spacePad(bufmin);
      return;
    }
    int len = s.length();
    if (len > max) {
      if(.isLeftTruncate()) {
        buf.append(s.substring(len - max));
      } else {
        buf.append(s.substring(0, max));
      }
    } else if (len < min) {
      if (.isLeftPad()) {
       SpacePadder.leftPad(bufsmin);
      } else {
        SpacePadder.rightPad(bufsmin);
      }
    } else {
      buf.append(s);
    }
  }
New to GrepCode? Check out our FAQ X