⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resourcelibloader.java

📁 这个是使用java开发的一个平台
💻 JAVA
字号:
package com.exp.fcl.configs.loaders;

import java.io.File;
import java.util.Locale;
import java.util.Vector;

import com.exp.fcl.configs.ConfigLoaderSupport;
import com.exp.fcl.syscfg.ResourceLib;
import com.exp.fcl.syscfg.SystemConfig;

public class ResourceLibLoader extends ConfigLoaderSupport {
    public Object load(String baseName) {
        Locale realLocale = SystemConfig.getTargetLocale();
        if (realLocale == null) {
            realLocale = Locale.getDefault();
        }
        ResourceLib temp = null;
        ResourceLib current = null;
        ResourceLib parent = null;
        Vector factors = initFactors(baseName, realLocale);
        int nCount = factors.size();
        String filePath = SystemConfig.getResourcePath() + File.separator;
        String fileName = "";
        for (int i = 0; i < nCount; i++) {
            fileName = filePath + getFileName(factors, i + 1) + ".xml";
            File fTemp = new File(fileName);
            if (fTemp.exists()) {
                temp = new ResourceLib(realLocale);
                try {
                    temp.loadResource(fileName);
                    if (current == null && parent == null) {
                        current = temp;
                        parent = temp;
                    } else {
                        current = temp;
                        current.setParent(parent);
                        parent = temp;
                    }
                } catch (Exception e) {
                    return null;
                }
            }
        }
        return current;
    }

    private static Vector initFactors(String baseName, Locale locale) {
        String languageName = locale.getLanguage();
        String countryName = locale.getCountry();
        String variantName = locale.getVariant();
        Vector factors = new Vector();
        if (!baseName.equals("")) {
            factors.add(baseName);
        }
        if (!languageName.equals("")) {
            factors.add(languageName);
        }
        if (!countryName.equals("")) {
            factors.add(countryName);
        }
        if (!variantName.equals("")) {
            factors.add(variantName);
        }
        return factors;
    }

    private static String getFileName(Vector factors, int count) {
        String temp = "";
        for (int i = 0; i < count; i++) {
            temp += factors.get(i).toString();
            if (i < count - 1) {
                temp += "_";
            }
        }
        return temp;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -