File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to retrieve a sequence from a Java Collection

 
Mathew Kuruvilla
Ranch Hand
Posts: 141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the following code:

function updateChartData() {
var test: LineChart.Data[] = [];
for (x in [0..10 step 1]) {
insert LineChart.Data { xValue: x yValue: Math.sin(x)*100 - x } into test
}
var a: HashMap = new HashMap();
a.put(0, test);
delete test;
var retest: LineChart.Data[] = a.get(0) as LineChart.Data[];
println("size of retest is: {sizeof retest}");
println(retest);
}

I get the following exception:

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: com.sun.javafx.runtime.sequence.ObjectArraySequence cannot be cast to javafx.scene.chart.LineChart$Data
at com.sasken.vas.application.Main.updateChartdata(Main.fx:263)

Any suggestions will be appreciated
 
Philippe Lhoste
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, I will point to another thread... :-) (I love hyperlinking/cross-references...) :-D

In What am I doing wrong??? -- HashMap containing Sequences... the OP have found a solution by wrapping the sequence. Not super elegant but if it works...
 
Mathew Kuruvilla
Ranch Hand
Posts: 141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lovely! That worked fine! Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic