public void setLang(String lang) { if (general == null || general.size() == 0) { loadConfig(); } ConfigItem item = general.getInstance(0); item.setProperty("language", lang); }
public void setGeneralValue(String name, String value) { if (general == null || general.size() == 0) { loadConfig(); } ConfigItem item = general.getInstance(0); item.setProperty(name, value); }
public BookItem getBookmark(int index) { assertBook(); if (index < 0 || index >= bookmarks.size()) { return null; } ConfigItem item = bookmarks.getInstance(index); String word = (String) item.getProperty("word"); return new BookItem(word); }
public String getLang() { String lang = "default"; if (general == null || general.size() == 0) { loadConfig(); } ConfigItem item = general.getInstance(0); lang = item.getString("language", lang); item.setProperty("language", lang); return lang; }
public String getGeneralValue(String name, String defaultValue) { String value = defaultValue; if (general == null || general.size() == 0) { loadConfig(); } ConfigItem item = general.getInstance(0); value = item.getString(name, value); item.setProperty(name, value); return value; }
public int getGeneralValue(String name, int defaultValue) { int value = defaultValue; if (general == null || general.size() == 0) { loadConfig(); } ConfigItem item = general.getInstance(0); value = item.getInt(name, value); item.setProperty(name, String.valueOf(value)); return value; }
public void addBookmark(String word) { assertBook(); for (int i = 0; i < bookmarks.size(); ++i) { String oldWord = (String) bookmarks.getInstance(i).getProperty("word"); oldWord = oldWord.toLowerCase(); if (oldWord != null && oldWord.equals(word.toLowerCase())) { return; } } ConfigItem newItem = new ConfigItem(null, null); newItem.setProperty("word", word); bookmarks.addInstance(newItem); }
/** * create batch {@link ConfigItem} instances by name and value. * * @param configItem batch name and value * @return {@link ConfigItem} instances */ public List<ConfigItem> newItems(Map<String, String> configItem) { if (MapUtils.isEmpty(configItem)) { return Collections.emptyList(); } Date createDate = new Date(); List<ConfigItem> ret = new ArrayList<ConfigItem>(configItem.size()); Iterator<Entry<String, String>> iter = configItem.entrySet().iterator(); while (iter.hasNext()) { Entry<String, String> entry = iter.next(); ConfigItem item = new ConfigItem(); item.setName(entry.getKey()); item.setVal(entry.getValue()); item.setRef(false); item.setCreateTime(createDate); item.setGroupId(getId()); item.setShareable(false); item.setVersionId(getVersionId()); ret.add(item); } return ret; }