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

📄 beanhelper.java

📁 java写的qq代码实现qq的部分功能
💻 JAVA
字号:
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 luma <stubma@163.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package edu.tsinghua.lumaqq.ui.helper;

import edu.tsinghua.lumaqq.LumaQQ;
import edu.tsinghua.lumaqq.qq.Util;

/**
 * 保存一些固定的数据
 * 
 * @author luma
 */
public class BeanHelper {
    private static String[] EMPTY = new String[0];
    
    public static String[] GENDER = new String[] {
        LumaQQ.getString("x"),
        LumaQQ.getString("gender.gg"),
        LumaQQ.getString("gender.mm")
    };
    
    public static String[] AGE;    
    public static String[] PROVINCE;
    public static Object[] CITY;
    
    static {
        // 载入年龄
        int n = Util.getInt(LumaQQ.getString("user.info.basic.age.number"), 0);
        AGE = new String[n + 1];
        AGE[0] = LumaQQ.getString("x");
        for(int i = 1; i <= n; i++)
            AGE[i] = LumaQQ.getString("user.info.basic.age." + i);
        
        // 载入省名称列表
        n = Util.getInt(LumaQQ.getString("user.info.contact.province.number"), 0);
        PROVINCE = new String[n + 1];
        CITY = new Object[n + 1];
        CITY[0] = new String[] { LumaQQ.getString("x") };
        PROVINCE[0] = LumaQQ.getString("x");
        for(int i = 1; i <= n; i++) {
            PROVINCE[i] = LumaQQ.getString("user.info.contact.province." + i);
            
            // 载入城市列表
            String prefix = "user.info.contact.city." + i + ".";
            int cityNum = Util.getInt(LumaQQ.getString(prefix + "number"), 0);
            String[] c = new String[cityNum + 1];
            c[0] = LumaQQ.getString("x");
            for(int j = 1; j <= cityNum; j++)
                c[j] = LumaQQ.getString(prefix + j);
            CITY[i] = c;
        }
    }
    
    /**
     * 得到性别字符串
     * 
     * @param index
     * @return
     */
    public static String getGender(int index) {
        if(index < 0 || index >= GENDER.length)
            return "";
        return GENDER[index];
    }
    
    /**
     * 得到省份名称
     * 
     * @param index
     * 		省份索引
     * @return
     * 		省份名称
     */
    public static String getProvince(int index) {
        index--;
        if(index < 0 || index >= PROVINCE.length)
            return "";
        return PROVINCE[index];
    }
    
    /**
     * 得到城市名称
     * 
     * @param provinceIndex
     * 		省份索引
     * @param cityIndex
     * 		城市索引
     * @return
     * 		城市名称
     */
    public static String getCity(int provinceIndex, int cityIndex) {
        String[] c = getCitys(provinceIndex);
        if(cityIndex < 0 || cityIndex >= c.length)
            return "";
        return c[cityIndex];
    }
    
    /**
     * 得到城市列表
     * 
     * @param provinceIndex
     * @return
     */
    public static String[] getCitys(int provinceIndex) {
        provinceIndex--;
        if(provinceIndex < 0 || provinceIndex >= PROVINCE.length)
            return EMPTY;
        
        return (String[])CITY[provinceIndex];
    }
}

⌨️ 快捷键说明

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