我在地图中有地图和列表,并且想从数据库中获取此地图对象的数据,谁能建议我请我以正确的方式在此代码上获取两个地图的键和值,我有一个对象 A它包含一个带有 C 值列表的对象 B,我正在获取 A 对象的数据,但是 B 和 C 对象的数据在所有 A 对象中都是相似的,并且 C 对象仅指向一个点而不呈现所有值,其中我错了吗?:
void getData(int dataNo) {
AsyncCallback<Map<A, Map<B,List<C>>>> callback = new AsyncCallback<Map<A, Map<B,List<C>>>>() {
public void onFailure(Throwable caught) {
}
public void onSuccess(Map<A, Map<B,List<C>>> result) {
panel.clear();
for (Map.Entry<A, Map<B,List<C>>> entry : result.entrySet()) {
A a = entry.getKey();
Map<B, List<C>> bc = entry.getValue();
chart = new Chart().setType(Series.Type.LINE)
.setLegend(new Legend()
.setLayout(Legend.Layout.VERTICAL)
.setAlign(Legend.Align.RIGHT)
.setVerticalAlign(Legend.VerticalAlign.TOP)
.setX(-10).setY(100)
.setBorderWidth(0))
.setZoomType(Chart.ZoomType.X_AND_Y);
chart.setChartTitleText(a.getL());
for(Map.Entry<B, List<C>> in : bc.entrySet()){
B b = in.getKey();
List<C> c=in.getValue();
bc.containsKey(b);
bc.containsValue(c);
serie = chart.createSeries().setName(b.getF());
C[] ac=c.toArray(new C[c.size()]);
for (C cd: ac) {
serie.setPoints(new Number[] { cd.getS()});
}
chart.addSeries(serie);
}
panel.add(chart);
}
}
};
编辑填充地图:
public Map<A, Map<B, List<C>>> getL(int dataNo) {
Map<A, Map<B, List<C>>> outermap = new HashMap<A, Map<B, List<C>>>();
Map<B,List<C>> innermap=new HashMap<B,List<C>>();
List<A> a= DB.getL(dataNo);
for (A aa: a) {
outermap.put(aa, innermap);
List<B> b=DB.getK(aa.getId());
for(B bb: b){
innermap.put(bb, DB.getD(bb.getId()));
}
}
return outermap;
}