SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-19-2006, 06:20 PM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
List constructor ?

Is there an easy way to create a List (instead of a set) ?

The DataUnion respects the order, but it doesnt seem to allow duplicates, a list = DataUnion(1,2,3,2,1) only results in [1,2,3]

I know that I could use

Code:
list = new_java_util_ArrayList()
java_util_List_add(list, "1")
java_util_List_add(list, "2")
java_util_List_add(list, "1")
but I wonder if there is an easier way to initialize a list.
Also, the above java code only works with strings, but not with integer ...

I probably could find something in one of the various imports, but maybe someone can point me to an example more quickly ...

Thanks,
Dirk
Reply With Quote
  #2  
Old 02-20-2006, 11:29 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
I don't know of a more concise way to do what you want, short of writing your own constructor function in Java.

That would also solve your string-v.-int problem by letting you declare the argument types explicit as int. (I've noticed that Sage has trouble passing ints where Objects are expected.)
__________________
-- Greg
Reply With Quote
  #3  
Old 02-20-2006, 01:48 PM
malore's Avatar
malore malore is offline
Sage Fanatic
 
Join Date: Aug 2003
Location: Iowa
Posts: 877
Something like this might meet your needs.
list = java_lang_String_split("1,2,3,2,1",",")
Reply With Quote
  #4  
Old 02-20-2006, 10:25 PM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Quote:
Originally Posted by malore
Something like this might meet your needs.
list = java_lang_String_split("1,2,3,2,1",",")
Yeah, this seems to be the best way to do it. Would still require some conversion in case I need Integer, but that's probably the best you can do without external java ...


Thanks for all answers,

Dirk
Reply With Quote
  #5  
Old 02-20-2006, 11:15 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
I won't claim to be a list expert (and once created a DataUnion of a fixed length of numbers 1-10 just to get an array that size, which I could then fill with the real data at set locations), but SageTV will usually automatically convert from one data type to another. If you have "3" as a string, you can multiple it by the number 2 in order to get 6 as a result. In fact, I use this in various places when I need to use a property as a numerical value -- multiply it by 1 to get a number instead of a string.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #6  
Old 02-21-2006, 06:58 AM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Quote:
Originally Posted by Opus4
I won't claim to be a list expert (and once created a DataUnion of a fixed length of numbers 1-10 just to get an array that size, which I could then fill with the real data at set locations), but SageTV will usually automatically convert from one data type to another. If you have "3" as a string, you can multiple it by the number 2 in order to get 6 as a result. In fact, I use this in various places when I need to use a property as a numerical value -- multiply it by 1 to get a number instead of a string.

- Andy
Yeah true, that's what I meant with 'still requires conversion'. I have seen this technique many times in existing code (first wondered 'what the hell is this supposed to do ...' ) Just wanted to point out that you have to remember to explicitly convert, otherwise GetElement(list, 0) + GetElement(list, 1) will not really add some numbers ...

Dirk
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 02:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.