Java Class Name Extract extractClassName(String qualifiedName)

Here you can find the source of extractClassName(String qualifiedName)

Description

Extracts the name of a class from the qualified class name.

License

Open Source License

Declaration

public static String extractClassName(String qualifiedName) 

Method Source Code

//package com.java2s;
/*/*w w  w .j  ava2  s .  c  om*/
 This file is part of the Greenfoot program. 
 Copyright (C) 2005-2009  Poul Henriksen and Michael Kolling 
    
 This program is free software; you can redistribute it and/or 
 modify it under the terms of the GNU General Public License 
 as published by the Free Software Foundation; either version 2 
 of the License, or (at your option) any later version. 
    
 This program 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 General Public License for more details. 
    
 You should have received a copy of the GNU General Public License 
 along with this program; if not, write to the Free Software 
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
    
 This file is subject to the Classpath exception as provided in the  
 LICENSE.txt file that accompanied this code.
 */

public class Main {
    /**
     * Extracts the name of a class from the qualified class name.
     */
    public static String extractClassName(String qualifiedName) {
        int index = qualifiedName.lastIndexOf('.');
        String name = qualifiedName;
        if (index >= 0) {
            name = qualifiedName.substring(index + 1);
        }
        return name;
    }
}

Related

  1. extractClassName(String fullClassName)
  2. extractClassName(String fullElement)
  3. extractClassName(String fullyQualifiedClassName)
  4. extractClassName(String javaSource)
  5. extractClassName(String methodName)
  6. extractClassNameFromArray(final String arrayName)
  7. extractClassNames(Class[] classArray)
  8. extractClassNameWithoutPackage(String className)
  9. extractClassNameWithParent(String fullClassName)