Java Class Name Get className(Object o)

Here you can find the source of className(Object o)

Description

class Name

License

Open Source License

Declaration

public static String className(Object o) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 BSI Business Systems Integration AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*  w ww. j av  a2s  . com*/
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

public class Main {
    public static String className(Object o) {
        if (o == null) {
            return "";
        }
        String s = o.getClass().getName();
        int i = s.lastIndexOf('.');
        if (i >= 0) {
            return s.substring(i + 1);
        } else {
            return s;
        }
    }

    public static String substring(String s, int start) {
        if (s == null || start >= s.length()) {
            return "";
        }
        return s.substring(start);
    }

    public static String substring(String s, int start, int len) {
        if (s == null || start >= s.length()) {
            return "";
        }
        len = Math.min(s.length() - start, len);
        return s.substring(start, start + len);
    }

    public static int length(String s) {
        if (s == null) {
            return 0;
        } else {
            return s.length();
        }
    }
}

Related

  1. classname(Class javaClass)
  2. className(Class type)
  3. className(Class aClass)
  4. className(final Class c)
  5. className(final Object object)
  6. className(Object o)
  7. classname(Object obj)
  8. className(Object obj)
  9. className(Object object)