Returns package name of a class

@param clazz
the class
@return
the package name of the class
760538
public static String packageNameOf(Class<?> clazz) {
        String name = clazz.getName();
        int pos = name.lastIndexOf('.');
        E.unexpectedIf(pos < 0, "Class does not have package: " + name);
        return name.substring(0, pos);
    }
263131
public static String getQualifiedName(Class<?> clazz) {
		Assert.notNull(clazz, "Class must not be null");
		if (clazz.isArray()) {
			return getQualifiedNameForArray(clazz);
		}
		else {
			return clazz.getName();
		}
	}
883505
public static @DottedClassName
    String extractPackageName(@DottedClassName String className) {
        int i = className.lastIndexOf('.');
        if (i < 0) {
            return "";
        }
        return className.substring(0, i);
    }
1178859
public static String getCommandName(Class<?> clazz) {
    String name = clazz.getName();
    return Strings.uncapitalize(name.substring(name.lastIndexOf('.') + 1));
  }
952226
public static ClassLoader getClassLoader(final Class<?> clazz) {
        // Context class loader can be null
        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        if (contextClassLoader != null) {
            return contextClassLoader;
        }
        if (clazz != null) {
            // The class loader for a specific class can also be null
            final ClassLoader clazzClassLoader = clazz.getClassLoader();
            if (clazzClassLoader != null) {
                return clazzClassLoader;
            }
        }
        // The only class loader we can rely on for not being null is the system
        // one
        return ClassLoader.getSystemClassLoader();
    }
673482
public static <T> ObjectName getObjectName(final Class<T> clazz)
        {
        final String domain = clazz.getPackage().getName();
        final String className = clazz.getSimpleName();
        final String objectName = domain+":type="+className;
        LOG.debug("Returning object name: {}", objectName);
        try
            {
            return new ObjectName(objectName);
            }
        catch (final MalformedObjectNameException e)
            {
            // This should never, ever happen.
            LOG.error("Invalid ObjectName: "+objectName, e);
            throw new RuntimeException("Could not create ObjectName?", e);
            }
        }
728510
private Class getClassForElementName(String name) {
		Class clazz = (Class) nameToClass.get(name);
		if (clazz != null) {
			return clazz;
		}
		
		if (defaultPackage != null) {
			try {
				return Class.forName(defaultPackage+"."+name);
			} catch (ClassNotFoundException e) {
				// ignore, it's just not there
			}
		}
		
		return null;
	}
282258
public String getFullPackageName(String classProjectID, String classPackageName)
    {
        if (classProjectID == null)
            return DBConstants.BLANK;
        String packageName = classProjectPackages.get(classProjectID);
        if (packageName == null)
            return null;    // This class is not accessible
        if (packageName.startsWith("."))
            packageName = Constants.ROOT_PACKAGE.substring(0, Constants.ROOT_PACKAGE.length() - 1) + packageName;
        if (classPackageName == null)
            classPackageName = DBConstants.BLANK;
        if (classPackageName.startsWith("."))
            packageName = packageName + classPackageName;
        else if (classPackageName.length() > 0)
            packageName = classPackageName;
        return packageName;
    }
678103
@ObjectiveCName("getSignature:")
    public static String getSignature(Class<?> clazz) {
        String primitiveSignature = PRIMITIVE_TO_SIGNATURE.get(clazz);
        if (primitiveSignature != null) {
            return primitiveSignature;
        } else if (clazz.isArray()) {
            return "[" + getSignature(clazz.getComponentType());
        } else {
            // TODO: this separates packages with '.' rather than '/'
            return "L" + clazz.getName() + ";";
        }
    }
413946
public static String getPackagePath(Class<?> clazz) {
		return getPackage(clazz).replace(StrUtil.C_DOT, StrUtil.C_SLASH);
	}
1023472
public static String simpleClassName(Class<?> clazz) {
        if (!clazz.isAnonymousClass()) {
            return clazz.getSimpleName();
        }
        // Simple name of anonymous class is empty
        String name = clazz.getName();
        int lastDot = name.lastIndexOf('.');
        if (lastDot <= 0) {
            return name;
        }
        return name.substring(lastDot + 1);
    }
19573
protected Class<?> loadClass(String clazz) throws ClassNotFoundException {
		if (this.classLoader == null){
			return Class.forName(clazz);
		}

		return Class.forName(clazz, true, this.classLoader);

	}
1364896
public static ClassLoader getClassLoader(Class clazz){
        ClassLoader classLoader = clazz.getClassLoader();
        return classLoader==null ? ClassLoader.getSystemClassLoader() : classLoader;
    }
317448
private String getResourceNameOfClass(final Class<?> clazz) throws IllegalArgumentException {
        // Build the name
        final String fqn = clazz.getName();
        final String nameAsResourcePath = fqn.replace(DELIMITER_CLASS_NAME_PATH, DELIMITER_RESOURCE_PATH);
        final String resourceName = nameAsResourcePath + EXTENSION_CLASS;

        // Return
        return resourceName;
    }
861781
public static String generatedNameOf(Class<?> clazz, Class<? extends Annotation> annotationClass)
    {
        return builder(clazz, annotationClass).build();
    }
1161940
@Nullable
  public static String getClassPackageName (@Nullable final String sClassName)
  {
    if (sClassName == null)
      return null;

    final int nIndex = sClassName.lastIndexOf ('.');
    return nIndex == -1 ? "" : sClassName.substring (0, nIndex);
  }
389519
public static String getClassName( final Class<?> clazz ) {
        final String fullName = clazz.getName();
        final int fullNameLength = fullName.length();

        // Check for array ('[') or the class/interface marker ('L') ...
        int numArrayDimensions = 0;
        while (numArrayDimensions < fullNameLength) {
            final char c = fullName.charAt(numArrayDimensions);
            if (c != '[') {
                String name = null;
                // Not an array, so it must be one of the other markers ...
                switch (c) {
                    case 'L': {
                        name = fullName.subSequence(numArrayDimensions + 1, fullNameLength).toString();
                        break;
                    }
                    case 'B': {
                        name = "byte";
                        break;
                    }
                    case 'C': {
                        name = "char";
                        break;
                    }
                    case 'D': {
                        name = "double";
                        break;
                    }
                    case 'F': {
                        name = "float";
                        break;
                    }
                    case 'I': {
                        name = "int";
                        break;
                    }
                    case 'J': {
                        name = "long";
                        break;
                    }
                    case 'S': {
                        name = "short";
                        break;
                    }
                    case 'Z': {
                        name = "boolean";
                        break;
                    }
                    case 'V': {
                        name = "void";
                        break;
                    }
                    default: {
                        name = fullName.subSequence(numArrayDimensions, fullNameLength).toString();
                    }
                }
                if (numArrayDimensions == 0) {
                    // No array markers, so just return the name ...
                    return name;
                }
                // Otherwise, add the array markers and the name ...
                if (numArrayDimensions < BRACKETS_PAIR.length) {
                    name = name + BRACKETS_PAIR[numArrayDimensions];
                } else {
                    for (int i = 0; i < numArrayDimensions; i++) {
                        name = name + BRACKETS_PAIR[1];
                    }
                }
                return name;
            }
            ++numArrayDimensions;
        }

        return fullName;
    }