Here you can find the source of simpleClassName(Class cl)
public static String simpleClassName(Class cl)
//package com.java2s; /*/*w ww . j a v a 2 s. co m*/ * Distributed as part of c3p0 v.0.9.1.2 * * Copyright (C) 2005 Machinery For Change, Inc. * * Author: Steve Waldman <swaldman@mchange.com> * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 2.1, as * published by the Free Software Foundation. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this software; see the file LICENSE. If not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */ public class Main { public static String simpleClassName(Class cl) { String scn; int array_level = 0; while (cl.isArray()) { ++array_level; cl = cl.getComponentType(); } scn = simpleClassName(cl.getName()); if (array_level > 0) { StringBuffer sb = new StringBuffer(16); sb.append(scn); for (int i = 0; i < array_level; ++i) sb.append("[]"); return sb.toString(); } else return scn; } private static String simpleClassName(String fqcn) { int pkgdot = fqcn.lastIndexOf('.'); if (pkgdot < 0) return fqcn; String scn = fqcn.substring(pkgdot + 1); if (scn.indexOf('$') >= 0) { StringBuffer sb = new StringBuffer(scn); for (int i = 0, len = sb.length(); i < len; ++i) { if (sb.charAt(i) == '$') sb.setCharAt(i, '.'); } return sb.toString(); } else return scn; } }