Example #1
0
 public void setLang(String lang) {
   if (general == null || general.size() == 0) {
     loadConfig();
   }
   ConfigItem item = general.getInstance(0);
   item.setProperty("language", lang);
 }
Example #2
0
 public void setGeneralValue(String name, String value) {
   if (general == null || general.size() == 0) {
     loadConfig();
   }
   ConfigItem item = general.getInstance(0);
   item.setProperty(name, value);
 }
Example #3
0
 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);
 }
Example #4
0
 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;
 }
Example #5
0
 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;
 }
Example #6
0
 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;
 }
Example #7
0
  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;
  }