@Override @SuppressWarnings("unchecked") public Map toMap() { Map m = new HashMap(); Iterator i = this.keySet().iterator(); while (i.hasNext()) { Object s = i.next(); m.put(s, this.get(String.valueOf(s))); } return m; }
/** * Converts a BSONObject to a map. * * @return the Map Object */ @SuppressWarnings("unchecked") public Map toMap() { Map m = new HashMap(); Iterator i = this.keySet().iterator(); while (i.hasNext()) { Object s = i.next(); m.put(s, this.get(String.valueOf(s))); } return m; }
/** * Get all the BSON values. * @return All the BSON values by "java.util#Collection<Object>". * @throws Exception IllegalArgumentException when the type of BSON value is not supported. */ public Object asList() { Collection<Object> colletion = new LinkedList<Object>(); for (String key : this.keySet()) { Object v = this.get(key); if (v == null) { continue; } else if (BSON.IsBasicType(v)) { colletion.add(v); } else if (v instanceof BasicBSONList) { colletion.add(((BasicBSONList) v).asList()); } else if (v instanceof BasicBSONObject) { colletion.add(((BasicBSONObject) v).asMap()); } else { throw new IllegalArgumentException( "can't support in list. value_type=" + v.getClass()); } } return colletion; } }
for (String key : this.keySet()) { eleObj = this.get(key);