📄 home.java
字号:
package com.redmoon.forum.ui;import java.net.*;import cn.js.fan.util.*;import org.apache.log4j.*;import cn.js.fan.cache.jcs.RMCache;public class Home { final String HOTIDS = "FORUM_HOME_HOTIDS"; final String FLASHIMAGES = "FORUM_HOME_FLASHIMAGES"; final String group = "FORUM_HOME_CACHE"; private XMLProperties properties; private final String CONFIG_FILENAME = "config_forum_home.xml"; private String cfgpath; Logger logger; public static Home home = null; private static Object initLock = new Object(); public Home() { } public void init() { logger = Logger.getLogger(Home.class.getName()); URL cfgURL = getClass().getClassLoader().getResource( "/" + CONFIG_FILENAME); cfgpath = cfgURL.getFile(); cfgpath = URLDecoder.decode(cfgpath); properties = new XMLProperties(cfgpath); } public static Home getInstance() { if (home == null) { synchronized (initLock) { home = new Home(); home.init(); } } return home; } public String getProperty(String name) { return StrUtil.getNullStr(properties.getProperty(name)); } public int getIntProperty(String name) { String p = getProperty(name); if (StrUtil.isNumeric(p)) { return Integer.parseInt(p); } else return -65536; } public boolean getBooleanProperty(String name) { String p = getProperty(name); return p.equals("true"); } public void setProperty(String name, String value) { properties.setProperty(name, value); refresh(); } public String getProperty(String name, String childAttributeName, String childAttributeValue) { return StrUtil.getNullStr(properties.getProperty(name, childAttributeName, childAttributeValue)); } public String getProperty(String name, String childAttributeName, String childAttributeValue, String subChildName) { return StrUtil.getNullStr(properties.getProperty(name, childAttributeName, childAttributeValue, subChildName)); } public void setProperty(String name, String childAttributeName, String childAttributeValue, String value) { properties.setProperty(name, childAttributeName, childAttributeValue, value); refresh(); } public void setProperty(String name, String childAttributeName, String childAttributeValue, String subChildName, String value) { properties.setProperty(name, childAttributeName, childAttributeValue, subChildName, value); refresh(); } public int[] getHotIds() { int[] v = new int[0]; try { v = (int[]) RMCache.getInstance().getFromGroup(HOTIDS, group); } catch (Exception e) { logger.error(e.getMessage()); } if (v != null) { return v; } else { String ids = StrUtil.getNullString(home.getProperty("hot")); if (!ids.equals("")) { ids = ids.replaceAll(",", ","); String[] sv = ids.split(","); int len = sv.length; v = new int[len]; for (int i = 0; i < len; i++) { v[i] = StrUtil.toInt(sv[i], -1); } if (v.length > 0) { try { RMCache.getInstance().putInGroup(HOTIDS, group, v); } catch (Exception e) { logger.error(e.getMessage()); } } } } if (v == null) return new int[0]; else return v; } public String[][] getFlashImages() { String[][] v = null; try { v = (String[][]) RMCache.getInstance().getFromGroup(FLASHIMAGES, group); } catch (Exception e) { logger.error(e.getMessage()); } if (v != null) { return v; } else { v = new String[5][3]; for (int i = 1; i <= 5; i++) { String url = StrUtil.getNullString(home.getProperty("flash", "id", "" + i, "url")); String link = StrUtil.getNullString(home.getProperty("flash", "id", "" + i, "link")); String text = StrUtil.getNullString(home.getProperty("flash", "id", "" + i, "text")); if (!url.equals("")) { v[i - 1][0] = url; v[i - 1][1] = link; v[i - 1][2] = text; } } if (v.length > 0) { try { RMCache.getInstance().putInGroup(FLASHIMAGES, group, v); } catch (Exception e) { logger.error(e.getMessage()); } } } return v; } public void refresh() { try { RMCache.getInstance().invalidateGroup(group); } catch (Exception e) { logger.error(e.getMessage()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -