Пример #1
0
  public static Entry fromMap(Map<?, ?> map) {
    entry e = new entry(entry.data_type.dictionary_t);

    string_entry_map d = e.dict();
    for (Map.Entry<?, ?> kv : map.entrySet()) {
      String k = kv.getKey().toString();
      Object v = kv.getValue();

      if (v instanceof String) {
        d.set(k, new entry((String) v));
      } else if (v instanceof Integer) {
        d.set(k, new entry((Integer) v));
      } else if (v instanceof Entry) {
        d.set(k, ((Entry) v).getSwig());
      } else if (v instanceof entry) {
        d.set(k, (entry) v);
      } else if (v instanceof List) {
        d.set(k, fromList((List<?>) v).getSwig());
      } else if (v instanceof Map) {
        d.set(k, fromMap((Map<?, ?>) v).getSwig());
      } else {
        d.set(k, new entry(v.toString()));
      }
    }

    return new Entry(e);
  }
Пример #2
0
  public Map<String, Entry> dictionary() {
    string_entry_map dict = e.dict();
    string_vector keys = dict.keys();
    int size = (int) keys.size();

    Map<String, Entry> map = new HashMap<String, Entry>(size);

    for (int i = 0; i < size; i++) {
      String key = keys.get(i);
      Entry value = new Entry(dict.get(key));
      map.put(key, value);
    }

    return map;
  }