03-09-2013 07:38 PM - edited 03-14-2019 11:22 AM
Hi All
In a 'do' or 'set' step, I can happily create various objects, for example:
DO Step:
{
java.util.ArrayList = new java.util.ArrayList();
}
However, if I try to create an object with a type parameter, it fails:
DO Step:
{
java.util.ArrayList = new java.util.ArrayList<Integer>();
}
Error:
Expression Lexical Error
Unable to parse expression; missing '.' at class: java.util.ArrayList (line: 2, col: 1)
Is there a trick to getting this to work, or does UCCX just not support this type of thing?
Thanks
Aaron
03-09-2013 08:41 PM
Yeah. This has been an issue some time.
No workaround other than avoiding generics as far as I know.
Sent from Cisco Technical Support iPhone App
03-10-2013 04:23 AM
Hi Steve
I'm not sure if my brain is big enough to do what I want to do without generics! ... back to the drawing board :-)
Thanks for the response.
Aaron
03-10-2013 05:59 PM
Hey Aaron,
What are you trying to do?
Sent from Cisco Technical Support iPhone App
03-11-2013 12:57 AM
Hi, yes, what are you trying to do?
Type params are mainly used at compile time to check element type validity (so the compiler would bark at you, preventing unhandled exceptions during runtime, when it's too late).
Fyi I tried to jump out from the UCCX script to both Ecmascript and Groovy, just to create an AreayList
Did you consider creating a custom class that wraps a parametrized ArrayList? There would be a local private var, and two methods, a getter and a setter.
G.
Sent from Cisco Technical Support iPhone App
03-11-2013 10:34 AM
Hi All
I was (ahem) trying to implement a custom comparator as an anonymous inner class, so that I could sort two related arrays (which contain linked values, e.g. arrayA[4] is related to arrayB[4]) using a third 'index' array. Like so :
http://stackoverflow.com/questions/112234/sorting-matched-arrays-in-java
Yep, I know that's generally bad practice (should be an object etc etc) but I needed to do this to improve the functionality of a script without reinventing the whole thing, and I wanted to avoid using custom jars as I use this script a lot, and don't want to have to go around restarting CCX engines to load my custom code. It's basically my 'management' script that allows management of opening hours/holidays/prompts etc etc from the TUI and web browser.
My workaround in the end was to implement some horrible code. Basically to copy the array I want to sort on, sort the copy, and use that sorted copy for display/TUI purposes. When I want the values related to it, I use the value from the copied array as a key to search the original array and find the related values in the 'other' array based on that. It basically only works as the values in the sorted array are guaranteed to be unique.
So that's OK for now, but I will have to redesign this thing when I have more time... :-)
Thanks for the responses.
Aaron
11-18-2013 02:30 PM
Bumping this again as from what I see the use of Generics is really a compiler understood "thing" if you know what is going into your List (which we should) then just use a Cast when pulling the data back out when you need to utilize it?
String getStrng = (String) List.get(index);
And going back to my List of Lists...
java.util.List getList = (java.util.List) List.get(index);
And pulling Data back out of my getList...
Integer myInt = (Integer) getList.get(index);
05-21-2013 12:24 PM
Bumping this topic, the Application I need to use ArrayList
05-21-2013 12:39 PM
Hi,
can you give a more specific example? This looks like a List of Lists to me.
G.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide