Dao記述のファクトリを作成します。

@param packageName パッケージ名
@param suffix サフィックス
@param configClassName 設定クラス名
@return Dao記述のファクトリ
@since 1.7.0
357152
public DaoDescFactory createDaoDescFactory(
      String packageName, String suffix, String configClassName) {
    return new DaoDescFactory(packageName, suffix, configClassName);
  }
844117
public static Set<Class<?>> getClassSet(String packageName) {
        try {
            Set<Class<?>> classSet = new HashSet<>();
            Enumeration<URL> urls = getClassLoader().getResources(packageName.replace(".", "/"));
            while (urls.hasMoreElements()) {
                URL url = urls.nextElement();
                if (Objects.isNull(url)) {
                    continue;
                }
                // 获取此 URL 的协议名称。
                String protocol = url.getProtocol();
                if ("file".equals(protocol)) {
                    // %20 表示file协议?
                    String packagePath = url.getPath().replaceAll("%20", " ");
                    addClass(classSet, packagePath, packageName);
                } else if ("jar".equals(protocol)) {
                    JarURLConnection jarURLConnection = (JarURLConnection) url.openConnection();
                    if (Objects.isNull(jarURLConnection)) {
                        continue;
                    }
                    JarFile jarFile = jarURLConnection.getJarFile();
                    if (Objects.isNull(jarFile)) {
                        continue;
                    }
                    Enumeration<JarEntry> jarEntries = jarFile.entries();
                    while (jarEntries.hasMoreElements()) {
                        JarEntry jarEntry = jarEntries.nextElement();
                        String jarEntryName = jarEntry.getName();
                        if (jarEntryName.endsWith(".class")) {
                            String className = jarEntryName.substring(0, jarEntryName.lastIndexOf(".")).replaceAll("/",
                                    ".");
                            doAddClass(classSet, className);
                        }
                    }
                }
            }
            return classSet;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
1204462
public static String getUniqueLegalName(final String packageName,
                                            final String name,
                                            final int seed,
                                            final String ext,
                                            final String prefix,
                                            final ResourceReader src) {
        // replaces all non alphanumeric or $ chars with _
        final String newName = prefix + "_" + normalizeRuleName( name );
        if (ext.equals("java")) {
            return newName + Math.abs(seed);
        }

        final String fileName = packageName.replace('.', '/') + "/" + newName;

        if (src == null || !src.isAvailable(fileName + "." + ext)) return newName;

        // make sure the class name does not exist, if it does increase the counter
        int counter = -1;
        while (true) {

            counter++;
            final String actualName = fileName + "_" + counter + "." + ext;

            //MVEL:test null to Fix failing test on MVELConsequenceBuilderTest.testImperativeCodeError()
            if (!src.isAvailable(actualName)) break;
        }
        // we have duplicate file names so append counter
        return newName + "_" + counter;
    }
598927
public DaoDesc createDaoDesc(EntityDesc entityDesc) {
    DaoDesc daoDesc = new DaoDesc();
    daoDesc.setPackageName(packageName);
    String entityPrefix = StringUtil.defaultString(entityDesc.getEntityPrefix(), "");
    String entitySuffix = StringUtil.defaultString(entityDesc.getEntitySuffix(), "");
    String simpleName = entityPrefix + entityDesc.getSimpleName() + entitySuffix + suffix;
    daoDesc.setSimpleName(simpleName);
    if (configClassName != null) {
      daoDesc.setConfigClassSimpleName(ClassUtil.getSimpleName(configClassName));
    }
    daoDesc.setEntityDesc(entityDesc);
    daoDesc.setTemplateName(Constants.DAO_TEMPLATE);
    handleImportName(daoDesc, entityDesc);
    return daoDesc;
  }
330135
public static String canonicalClassName(Class<?> c, Package pkg) {
    String name = c.getName();
    if(pkg != null) {
      final String pkgname = pkg.getName();
      if(name.length() > pkgname.length() && name.startsWith(pkgname) && name.charAt(pkgname.length()) == '.') {
        name = name.substring(pkgname.length() + 1);
      }
    }
    if(name.endsWith(ELKIServiceRegistry.FACTORY_POSTFIX)) {
      name = name.substring(0, name.length() - ELKIServiceRegistry.FACTORY_POSTFIX.length());
    }
    return name;
  }
873766
def getClassInPackageFromName(className, pkg):
    
    # TODO: more efficiency!
    n = getAvClassNamesInPackage(pkg)
    i = n.index(className)
    c = getAvailableClassesInPackage(pkg)
    return c[i]
610371
public String getCauseStackTraceAsString(final List<String> packages, final String suffix) {
        return getCauseStackTraceAsString(packages, PlainTextRenderer.getInstance(), suffix);
    }
178920
public static Set<String> getFileNameByPackageName(Context context, final String packageName) throws PackageManager.NameNotFoundException, IOException, InterruptedException {
        final Set<String> classNames = new HashSet<>();

        List<String> paths = getSourcePaths(context);
        final CountDownLatch parserCtl = new CountDownLatch(paths.size());

        for (final String path : paths) {
            DefaultPoolExecutor.getInstance().execute(new Runnable() {
                @Override
                public void run() {
                    DexFile dexfile = null;

                    try {
                        if (path.endsWith(EXTRACTED_SUFFIX)) {
                            //NOT use new DexFile(path), because it will throw "permission error in /data/dalvik-cache"
                            dexfile = DexFile.loadDex(path, path + ".tmp", 0);
                        } else {
                            dexfile = new DexFile(path);
                        }

                        Enumeration<String> dexEntries = dexfile.entries();
                        while (dexEntries.hasMoreElements()) {
                            String className = dexEntries.nextElement();
                            if (className.startsWith(packageName)) {
                                classNames.add(className);
                            }
                        }
                    } catch (Throwable ignore) {
                        Log.e("ARouter", "Scan map file in dex files made error.", ignore);
                    } finally {
                        if (null != dexfile) {
                            try {
                                dexfile.close();
                            } catch (Throwable ignore) {
                            }
                        }

                        parserCtl.countDown();
                    }
                }
            });
        }

        parserCtl.await();

        Log.d(Consts.TAG, "Filter " + classNames.size() + " classes by packageName <" + packageName + ">");
        return classNames;
    }
319176
private void definePackageForFindClass(final String name, final String packageName) {
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                @Override
                public Object run() {
                    String path = name.replace('.', '/').concat(".class");
                    for (URL url : getURLs()) {
                        try {
                            if (url.getContent() instanceof JarFile) {
                                JarFile jarFile = (JarFile) url.getContent();
                                // Check the jar entry data before needlessly creating the
                                // manifest
                                if (jarFile.getJarEntryData(path) != null
                                        && jarFile.getManifest() != null) {
                                    definePackage(packageName, jarFile.getManifest(),
                                            url);
                                    return null;
                                }

                            }
                        } catch (IOException ex) {
                            // Ignore
                        }
                    }
                    return null;
                }
            }, AccessController.getContext());
        } catch (java.security.PrivilegedActionException ex) {
            // Ignore
        }
    }
1144270
public String autoDetectPackageName(final File file) {
        try {
            final Set<String> packageNames = new HashSet<>();
            try (JarFile jarFile = new JarFile(file)) {
                final Enumeration<JarEntry> entries = jarFile.entries();
                while (entries.hasMoreElements()) {
                    final JarEntry entry = entries.nextElement();
                    String name = entry.getName();
                    if (name.endsWith(".class")) {
                        logger.debug("Considering package of entry '{}'", name);

                        final int lastIndexOfSlash = name.lastIndexOf('/');
                        if (lastIndexOfSlash != -1) {
                            name = name.substring(0, lastIndexOfSlash);
                            packageNames.add(name);
                        }

                    }
                }
            }

            if (packageNames.isEmpty()) {
                return null;
            }

            logger.info("Found {} packages in extension jar: {}", packageNames.size(), packageNames);

            // find the longest common prefix of all the package names
            String packageName = StringUtils.getLongestCommonToken(packageNames, '/');
            if (packageName == "") {
                logger.debug("No common package prefix");
                return null;
            }

            packageName = packageName.replace('/', '.');
            return packageName;
        } catch (final Exception e) {
            logger.warn("Error occurred while auto detecting package name", e);
            return null;
        }
    }
380335
public static String getPackage(Class<?> clazz) {
		if (clazz == null) {
			return StrUtil.EMPTY;
		}
		final String className = clazz.getName();
		int packageEndIndex = className.lastIndexOf(StrUtil.DOT);
		if (packageEndIndex == -1) {
			return StrUtil.EMPTY;
		}
		return className.substring(0, packageEndIndex);
	}
592683
@Override
    public Class<?> fromComponentNameToClass(final String componentName) { // *important
        if (LdiStringUtil.isEmpty(componentName)) {
            throw new EmptyRuntimeException("componentName");
        }
        final String suffix = fromComponentNameToSuffix(componentName);
        if (suffix == null) {
            return null;
        }
        final String middlePackageName = fromSuffixToPackageName(suffix);
        final String partOfClassName = fromComponentNameToPartOfClassName(componentName);
        final boolean subAppSuffix = isSubAppSuffix(suffix);
        final boolean webAppSufix = isWebAppSuffix(suffix);
        final boolean jobAppSufix = isJobAppSuffix(suffix);
        for (int i = 0; i < rootPackageNames.length; ++i) {
            final String rootPackageName = rootPackageNames[i];
            if (subAppSuffix) { // first search sub application package
                Class<?> clazz = null;
                if (webAppSufix) {
                    clazz = findWebClass(rootPackageName, partOfClassName);
                } else if (jobAppSufix) {
                    clazz = findJobClass(rootPackageName, partOfClassName);
                }
                if (clazz != null) {
                    return clazz;
                }
                clazz = findClass(rootPackageName, middlePackageName, partOfClassName);
                if (clazz != null) {
                    return clazz;
                }
            } else {
                Class<?> clazz = findClass(rootPackageName, middlePackageName, partOfClassName);
                if (clazz != null) {
                    return clazz;
                }
                if (webAppSufix) {
                    clazz = findWebClass(rootPackageName, partOfClassName);
                } else if (jobAppSufix) {
                    clazz = findJobClass(rootPackageName, partOfClassName);
                } else { // e.g. base_login_harborLoginAssist (by "pickup" method)
                    clazz = findWebClass(rootPackageName, partOfClassName); // find as web at first
                    if (clazz == null) {
                        clazz = findJobClass(rootPackageName, partOfClassName); // and job as next
                    }
                }
                if (clazz != null) {
                    return clazz;
                }
            }
        }
        return null;
    }
1246391
@Pure
	public static Collection<Class<?>> getPackageClasses(String packageName) {
		final Collection<Class<?>> classes = new ArrayList<>();

		final String[] entries = System.getProperty("java.class.path") //$NON-NLS-1$
				.split(Pattern.quote(System.getProperty("path.separator"))); //$NON-NLS-1$
		String lentry;

		for (final String path : entries) {
			lentry = path.toLowerCase();
			if (lentry.endsWith(".jar") || lentry.endsWith(".war")) { //$NON-NLS-1$ //$NON-NLS-2$
				getPackageClassesFromJar(classes, path, packageName);
			} else {
				getPackageClassesFromFileSystem(classes, path, packageName);
			}

		}

		return classes;
	}
783989
public static ClassName tableClassName(SQLiteDaoDefinition dao, SQLiteEntity entity) {
		String entityName = BindDataSourceSubProcessor.generateEntityQualifiedName(dao, entity);

		return TypeUtility.className(entityName + SUFFIX);

	}
665257
public static String getPackageName(Class< ? > clazz,
                                        Package pkg) {
        String pkgName = "";
        if ( pkg == null ) {
            int index = clazz.getName().lastIndexOf( '.' );
            if ( index != -1 ) pkgName = clazz.getName().substring( 0,
                                                                    index );
        } else {
            pkgName = pkg.getName();
        }
        return pkgName;

    }
365017
public final Package<NotDependsOn> findForbiddenByName(final String packageName) {
        final List<Package<NotDependsOn>> list = getForbidden();
        for (final Package<NotDependsOn> pkg : list) {
            if (pkg.getName().equals(packageName)) {
                return pkg;
            }
        }
        return null;
    }
872830
public static String newQualifiedClassName(final String packageName, final String className)
	{
		if (StringUtils.isBlank(packageName))
		{
			return className;
		}
		return new StringBuilder().append(packageName).append(SeparatorConstants.DOT)
			.append(className).toString();
	}