文字列と tupleList を含むマップがあります。tupleList を double 配列に取得しようとしていますが、型キャスト例外が発生しています。私のコードは -
Map<String, TupleList> results = null; -- Some data in it and TupleList has int or double value.
public void drawGraph(){
Object[] test = new Object[results.size()];
int index = 0;
for (Entry<String, TupleList> mapEntry : results.entrySet()) {
test[index] = mapEntry.getValue();
index++;
}
BarChart chart = new BarChart();
chart.setSampleCount(4);
String[] values = new String[test.length];
for(int i = 0; i < test.length; i++)
{
values[i] = (String) test[i];
}
// double[] values = new double[] {32,32,65,65};
String[] sampleLabels = new String[] {"deny\nstatus", "TCP\nrequest", "UPD\nrequest", "ICMP\nrequest"};
String[] barLabels = new String[] {"STATUS", "TCP", "UDP", "PING"};
//chart.setSampleValues(0, values);
chart.setSampleColor(0, new Color(0xFFA000));
chart.setRange(0, 88);
chart.setFont("rangeLabelFont", new Font("Arial", Font.BOLD, 13));
エラー - -
java.lang.ClassCastException: somePackagename.datamodel.TupleList cannot be cast to java.lang.String
at com.ibm.biginsights.ExampleAPI.drawGraph(ExampleAPI.java:177)
at com.ibm.biginsights.ExampleAPI.main(ExampleAPI.java:95)
私は例外@を取得しています
String[] values = new String[test.length];
for(int i = 0; i < test.length; i++)
{
values[i] = (String) test[i];
ありがとう