/** * <p>Gets the package name of a <code>Class</code>.</p> * * @param cls the class to get the package name for, may be <code>null</code>. * @return the package name or an empty string */ public static String getPackageName(Class cls) { if (cls == null) { return StringUtils.EMPTY; } return getPackageName(cls.getName()); }
/** * <p>Gets the package name of an <code>Object</code>.</p> * * @param object the class to get the package name for, may be null * @param valueIfNull the value to return if null * @return the package name of the object, or the null value */ public static String getPackageName(Object object, String valueIfNull) { if (object == null) { return valueIfNull; } return getPackageName(object.getClass()); }
/** * <p>Gets the package name from the canonical name. </p> * * <p>The string passed in is assumed to be a canonical name - it is not checked.</p> * <p>If the class is unpackaged, return an empty string.</p> * * @param canonicalName the canonical name to get the package name for, may be <code>null</code> * @return the package name or an empty string * @since 2.4 */ public static String getPackageCanonicalName(String canonicalName) { return ClassUtils.getPackageName(getCanonicalName(canonicalName)); }
/** * <p>Gets the package name of a <code>Class</code>.</p> * * @param cls the class to get the package name for, may be <code>null</code>. * @return the package name or an empty string */ public static String getPackageName(Class cls) { if (cls == null) { return StringUtils.EMPTY; } return getPackageName(cls.getName()); }
/** * <p>Gets the package name of a <code>Class</code>.</p> * * @param cls the class to get the package name for, may be <code>null</code>. * @return the package name or an empty string */ public static String getPackageName(Class cls) { if (cls == null) { return StringUtils.EMPTY; } return getPackageName(cls.getName()); }
/** * <p>Gets the package name of an <code>Object</code>.</p> * * @param object the class to get the package name for, may be null * @param valueIfNull the value to return if null * @return the package name of the object, or the null value */ public static String getPackageName(Object object, String valueIfNull) { if (object == null) { return valueIfNull; } return getPackageName(object.getClass()); }
/** * <p>Gets the package name of a <code>Class</code>.</p> * * @param cls the class to get the package name for, may be <code>null</code>. * @return the package name or an empty string */ public static String getPackageName(Class cls) { if (cls == null) { return StringUtils.EMPTY; } return getPackageName(cls.getName()); }
/** * <p>Gets the package name of a <code>Class</code>.</p> * * @param cls the class to get the package name for, may be <code>null</code>. * @return the package name or an empty string */ public static String getPackageName(Class cls) { if (cls == null) { return StringUtils.EMPTY; } return getPackageName(cls.getName()); }
/** * <p>Gets the package name of a <code>Class</code>.</p> * * @param cls the class to get the package name for, may be <code>null</code>. * @return the package name or an empty string */ public static String getPackageName(Class cls) { if (cls == null) { return StringUtils.EMPTY; } return getPackageName(cls.getName()); }
/** * <p>Gets the package name of an <code>Object</code>.</p> * * @param object the class to get the package name for, may be null * @param valueIfNull the value to return if null * @return the package name of the object, or the null value */ public static String getPackageName(Object object, String valueIfNull) { if (object == null) { return valueIfNull; } return getPackageName(object.getClass()); }
/** * <p>Gets the package name of an <code>Object</code>.</p> * * @param object the class to get the package name for, may be null * @param valueIfNull the value to return if null * @return the package name of the object, or the null value */ public static String getPackageName(Object object, String valueIfNull) { if (object == null) { return valueIfNull; } return getPackageName(object.getClass()); }
/** * <p>Gets the package name of an <code>Object</code>.</p> * * @param object the class to get the package name for, may be null * @param valueIfNull the value to return if null * @return the package name of the object, or the null value */ public static String getPackageName(Object object, String valueIfNull) { if (object == null) { return valueIfNull; } return getPackageName(object.getClass()); }
/** * <p>Gets the package name of an <code>Object</code>.</p> * * @param object the class to get the package name for, may be null * @param valueIfNull the value to return if null * @return the package name of the object, or the null value */ public static String getPackageName(Object object, String valueIfNull) { if (object == null) { return valueIfNull; } return getPackageName(object.getClass()); }
/** * <p>Gets the package name from the canonical name. </p> * * <p>The string passed in is assumed to be a canonical name - it is not checked.</p> * <p>If the class is unpackaged, return an empty string.</p> * * @param canonicalName the canonical name to get the package name for, may be <code>null</code> * @return the package name or an empty string * @since 2.4 */ public static String getPackageCanonicalName(String canonicalName) { return ClassUtils.getPackageName(getCanonicalName(canonicalName)); }
/** * <p>Gets the package name from the canonical name. </p> * * <p>The string passed in is assumed to be a canonical name - it is not checked.</p> * <p>If the class is unpackaged, return an empty string.</p> * * @param canonicalName the canonical name to get the package name for, may be <code>null</code> * @return the package name or an empty string * @since 2.4 */ public static String getPackageCanonicalName(String canonicalName) { return ClassUtils.getPackageName(getCanonicalName(canonicalName)); }
/** * <p>Gets the package name from the canonical name. </p> * * <p>The string passed in is assumed to be a canonical name - it is not checked.</p> * <p>If the class is unpackaged, return an empty string.</p> * * @param canonicalName the canonical name to get the package name for, may be <code>null</code> * @return the package name or an empty string * @since 2.4 */ public static String getPackageCanonicalName(String canonicalName) { return ClassUtils.getPackageName(getCanonicalName(canonicalName)); }
/** * <p>Gets the package name from the canonical name. </p> * * <p>The string passed in is assumed to be a canonical name - it is not checked.</p> * <p>If the class is unpackaged, return an empty string.</p> * * @param canonicalName the canonical name to get the package name for, may be <code>null</code> * @return the package name or an empty string * @since 2.4 */ public static String getPackageCanonicalName(String canonicalName) { return ClassUtils.getPackageName(getCanonicalName(canonicalName)); }
/** * <p>Gets the package name from the canonical name. </p> * * <p>The string passed in is assumed to be a canonical name - it is not checked.</p> * <p>If the class is unpackaged, return an empty string.</p> * * @param canonicalName the canonical name to get the package name for, may be <code>null</code> * @return the package name or an empty string * @since 2.4 */ public static String getPackageCanonicalName(String canonicalName) { return ClassUtils.getPackageName(getCanonicalName(canonicalName)); }
@Override public ClassLoaderLookupStrategy getLookupStrategy(String className) { final String packageName = getPackageName(className); ClassLoaderLookupStrategy lookupStrategy = lookupStrategies.get(packageName); if (lookupStrategy == null) { synchronized (this) { lookupStrategy = lookupStrategies.get(packageName); if (lookupStrategy == null) { if (isSystemPackage(packageName)) { lookupStrategy = PARENT_ONLY; } else { lookupStrategy = CHILD_FIRST; } lookupStrategies.put(packageName, lookupStrategy); } } } return lookupStrategy; }
private boolean imported(List<ImportDeclaration> imports, String fullyQualifiedName) { final String packageName = ClassUtils.getPackageName(fullyQualifiedName); for (final ImportDeclaration i : imports) { if (!i.isStatic()) { final String importName = i.getName().toString(); if (i.isAsterisk()) { if (packageName.equals(importName)) { if ( LOG.isDebugEnabled() ) { LOG.debug("found import " + packageName + ".* on " + getTypeNameForMsg(i) + "."); } return true; } } else { if (fullyQualifiedName.equals(importName)) { if ( LOG.isDebugEnabled() ) { LOG.debug("found import " + fullyQualifiedName + " on " + getTypeNameForMsg(i) + "."); } return true; } } } } return false; }