Java Class Name Extract extractClassNameFromArray(final String arrayName)

Here you can find the source of extractClassNameFromArray(final String arrayName)

Description

Extract a class name from an array.

License

Open Source License

Parameter

Parameter Description
arrayName The array declaration

Return

The name of the class

Declaration

public static String extractClassNameFromArray(final String arrayName) 

Method Source Code

//package com.java2s;
/**/*www  .j a va 2  s.c  o  m*/
 * This file is part of the Harmony package.
 *
 * (c) Mickael Gaillard <mickael.gaillard@tactfactory.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

public class Main {
    /** Extract a class name from an array.
     * @param arrayName The array declaration
     * @return The name of the class
     */
    public static String extractClassNameFromArray(final String arrayName) {
        String cName = arrayName;
        if (arrayName.contains("<")) {
            cName = arrayName.substring(arrayName.indexOf('<') + 1, arrayName.indexOf('>'));
        } else if (arrayName.contains("[]")) {
            cName = arrayName.substring(0, arrayName.indexOf('['));
        }

        return cName;
    }
}

Related

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