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.util;
015
016import ch.qos.logback.core.CoreConstants;
017import ch.qos.logback.core.rolling.helper.FileNamePattern;
018
019/**
020 * This implementation is intended for use in {@link FileNamePattern}.
021 * 
022 * @author Ceki Gülcü
023 */
024public class AlmostAsIsEscapeUtil extends RestrictedEscapeUtil {
025
026    /**
027     * Do not perform any character escaping, except for '%', and ')'.
028     * 
029     * <p>
030     * Here is the rationale. First, filename patterns do not include escape
031     * combinations such as \r or \n. Moreover, characters which have special
032     * meaning in logback parsers, such as '{', or '}' cannot be part of file names
033     * (so me thinks). The left parenthesis character has special meaning only if it
034     * is preceded by %. Thus, the only characters that needs escaping are '%' and
035     * ')'.
036     * 
037     * <p>
038     * Note that this method assumes that it is called after the escape character
039     * has been consumed.
040     */
041    public void escape(String escapeChars, StringBuffer buf, char next, int pointer) {
042        super.escape("" + CoreConstants.PERCENT_CHAR + CoreConstants.RIGHT_PARENTHESIS_CHAR, buf, next, pointer);
043    }
044}