Esempio n. 1
0
  private static void _removeFromValueList(String keyName, String item) {
    Key key = root.getSubKey(keyName);

    if (key == null) {
      key = root.createSubKey(keyName);
    }

    String oldValue = key.value;
    String[] oldValueList = _getValueList(keyName);
    fireChanging(keyName, _isList(keyName), oldValue, null, oldValueList, null);

    if (key.value != null) {
      key.value = null;
    }

    if (key.valueList == null) {
      key.valueList = new java.util.ArrayList();
    } else {
      if (item != null) {
        key.valueList.remove(item);
      }
    }

    fireChanged(keyName, _isList(keyName), oldValue, null, oldValueList, _getValueList(keyName));
  }
Esempio n. 2
0
  private static void _setValueList(String keyName, String[] values) {
    Key key = root.getSubKey(keyName);

    if (key == null) {
      key = root.createSubKey(keyName);
    }

    String oldValue = key.value;
    String[] oldValueList = _getValueList(keyName);
    fireChanging(keyName, _isList(keyName), oldValue, null, oldValueList, values);

    if (key.value != null) {
      key.value = null;
    }

    if (key.valueList == null) {
      key.valueList = new java.util.ArrayList((values == null) ? 0 : values.length);
    } else {
      key.valueList.clear();
    }
    if (values != null) {
      for (int i = 0; i < values.length; i++) {
        key.valueList.add(values[i]);
      }
    }

    fireChanged(keyName, _isList(keyName), oldValue, null, oldValueList, values);
  }
Esempio n. 3
0
  private static void _setValue(String keyName, String value) {
    Key key = root.getSubKey(keyName);

    if (key == null) {
      key = root.createSubKey(keyName);
    }

    String oldValue = key.value;
    String[] oldValueList = _getValueList(keyName);
    fireChanging(keyName, _isList(keyName), oldValue, value, oldValueList, null);

    if (key.valueList != null) {
      key.valueList = null;
    }
    key.value = value;

    fireChanged(keyName, _isList(keyName), oldValue, value, oldValueList, null);
  }
Esempio n. 4
0
    public Key createSubKey(String name) {
      if (subKeys == null) {
        subKeys = new java.util.HashMap();
      }

      int i = name.indexOf('.');
      if (i == -1) {
        Key subKey = (Key) subKeys.get(name);
        if (subKey == null) {
          subKey = new Key();
          subKey.name = name;
          subKeys.put(name, subKey);
        }
        return subKey;
      } else {
        Key subKey = (Key) subKeys.get(name.substring(0, i));
        if (subKey == null) {
          subKey = new Key();
          subKey.name = name.substring(0, i);
          subKeys.put(subKey.name, subKey);
        }
        return subKey.createSubKey(name.substring(i + 1));
      }
    }