Java String Shorten shorten(String clazz)

Here you can find the source of shorten(String clazz)

Description

shorten

License

Open Source License

Parameter

Parameter Description
clazz A class name (with possible package and trailing semicolon)

Return

The short name for the class

Declaration

private static String shorten(String clazz) 

Method Source Code

//package com.java2s;
/*/*from   ww w.  ja v a2  s .  c  o m*/
 * $Id$
 * --------------------------------------------------------------------------------------
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

public class Main {
    /**
     * @param clazz A class name (with possible package and trailing semicolon)
     * @return The short name for the class
     */
    private static String shorten(String clazz) {
        if (null != clazz && clazz.endsWith(";")) {
            clazz = clazz.substring(0, clazz.length() - 1);
        }
        if (null != clazz && clazz.lastIndexOf(".") > -1) {
            clazz = clazz.substring(clazz.lastIndexOf(".") + 1, clazz.length());
        }
        return clazz;
    }
}

Related

  1. shorten(byte[] array, int length)
  2. shorten(String className)
  3. shorten(String className)
  4. shorten(String fullClassName)
  5. shorten(String in)
  6. shorten(String input)
  7. shorten(String input, int length, boolean wholeWord)