001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.core.pattern;
015
016import ch.qos.logback.core.Layout;
017import ch.qos.logback.core.encoder.LayoutWrappingEncoder;
018
019public class PatternLayoutEncoderBase<E> extends LayoutWrappingEncoder<E> {
020
021    String pattern;
022
023    // due to popular demand outputPatternAsHeader is set to false by default
024    protected boolean outputPatternAsHeader = false;
025
026    public String getPattern() {
027        return pattern;
028    }
029
030    public void setPattern(String pattern) {
031        this.pattern = pattern;
032    }
033
034    public boolean isOutputPatternAsHeader() {
035        return outputPatternAsHeader;
036    }
037
038    /**
039     * Print the pattern string as a header in log files
040     *
041     * @param outputPatternAsHeader
042     * @since 1.0.3
043     */
044    public void setOutputPatternAsHeader(boolean outputPatternAsHeader) {
045        this.outputPatternAsHeader = outputPatternAsHeader;
046    }
047
048    public boolean isOutputPatternAsPresentationHeader() {
049        return outputPatternAsHeader;
050    }
051
052    /**
053     * @deprecated replaced by {@link #setOutputPatternAsHeader(boolean)}
054     */
055    public void setOutputPatternAsPresentationHeader(boolean outputPatternAsHeader) {
056        addWarn("[outputPatternAsPresentationHeader] property is deprecated. Please use [outputPatternAsHeader] option instead.");
057        this.outputPatternAsHeader = outputPatternAsHeader;
058    }
059
060    @Override
061    public void setLayout(Layout<E> layout) {
062        throw new UnsupportedOperationException("one cannot set the layout of " + this.getClass().getName());
063    }
064
065}