This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JavaFX and the fly likes Unable to retrieve a sequence from a Java Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JavaFX
Bookmark "Unable to retrieve a sequence from a Java Collection" Watch "Unable to retrieve a sequence from a Java Collection" New topic
Author

Unable to retrieve a sequence from a Java Collection

Mathew Kuruvilla
Ranch Hand

Joined: Nov 27, 2001
Posts: 135
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

Joined: Oct 23, 2009
Posts: 28
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

Joined: Nov 27, 2001
Posts: 135
Lovely! That worked fine! Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to retrieve a sequence from a Java Collection
 
Similar Threads
How to cast an Object to a HashMap with out getting unchecked cast warning
incrementation of variable
output
try-catch problem
args[] and ==