1 /** 2 * Logback: the generic, reliable, fast and flexible logging framework. 3 * 4 * Copyright (C) 2000-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 package ch.qos.logback.classic.pattern; 11 12 import ch.qos.logback.core.CoreConstants; 13 14 /** 15 * This abbreviator returns the class name from a fully qualified class name, 16 * removing the leading package name. 17 * 18 * @author Ceki Gülcü 19 */ 20 public class ClassNameOnlyAbbreviator implements Abbreviator { 21 22 public String abbreviate(String fqClassName) { 23 int lastIndex = fqClassName.lastIndexOf(CoreConstants.DOT); 24 if (lastIndex != -1) { 25 return fqClassName.substring(lastIndex + 1, fqClassName.length()); 26 } else { 27 return fqClassName; 28 } 29 } 30 }