cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2136
Views
15
Helpful
8
Replies

UCCX - Java Generics (Type Parameter) Support

Aaron Harrison
VIP Alumni
VIP Alumni

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

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!
8 Replies 8

Steve Earl
Level 1
Level 1

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

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

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!

Hey Aaron,

What are you trying to do?

Sent from Cisco Technical Support iPhone App

Gergely Szabo
VIP Alumni
VIP Alumni

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, but the UCCX script refused to handle it. I will try harder, there must be a way.

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

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

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!

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);

Bumping this topic, the Application I need to use ArrayList for pulls the Amount of Accounts [FirstDimension] and Number of Loans are in that Account [Second Dimension]..There Might be Multiple Accounts and the Number of Loans (Second Dimension) isn't always the Same once the Lists are filled I then have to fill Prompts with Generated Messages from the Data I pulled (or in some cases use the Data that was pulled as Incrementors etc etc)

Hi,

can you give a more specific example? This looks like a List of Lists to me.

G.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: