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 12-12-2009, 12:42 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Unknown Method in SOME STVs?

Gents,

I've run into a problem that I just can't figure out. I'm using one of pluckyhd's methods that is in his flux.jar file. (flux_api_HasPropertyElement()) When I use the method from one STV it works just fine. When I use it in another STV I get an unknown method error.

I checked spelling numerous times, I deleted the action widget and rekeyed it, and I even copied the action widget from the working STV to the non-working STV. Nothing helped.

Why, on the same server, would I get an unknown widget error from one STV but not another? I just don't know what else to try at this point.

Thanks,

Tom
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #2  
Old 12-12-2009, 12:57 PM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
Are you passing the same parameter types in both cases? If for example a method is setup as method(String) and you call it with method(int), you will get a method not found.

Thanks,
Jeff
Reply With Quote
  #3  
Old 12-12-2009, 01:48 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Jeff,

I looked at the parameters and they are the same

Tom
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #4  
Old 12-12-2009, 02:15 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Jeff,

I looked at this again and you are correct. The method was expecting a string and I passed it an int. I thought the int would be converted but it was not.

How do I convert an int to a string? java_lang_String_toString() does not seem to be the answer.

Tom
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #5  
Old 12-12-2009, 02:41 PM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
Try

Int + ""

This will convert the Int to a string.

Aloha,
Mike
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)
Reply With Quote
  #6  
Old 12-12-2009, 02:47 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by tmiranda View Post
Jeff,

How do I convert an int to a string? java_lang_String_toString() does not seem to be the answer.
You can also use, java_lang_String_valueOf(), which will convert a value (int, float, etc) to a string.... but Mike's way is a lot less typing
Reply With Quote
  #7  
Old 12-12-2009, 03:24 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by stuckless View Post
...but Mike's way is a lot less typing
Less typing is not the point. Good programming strives for clarity, not minimal keystrokes. A line of code gets typed just once, but read many times. So it's worth a little extra effort to make sure the meaning will be clear to the reader. The + "" shortcut does not (in my opinion) serve this goal, since you have to know how the trick works to understand what's going on.

The clearest and most direct way to convert an int to a String is with java_lang_Integer_toString(). It's pretty hard to mistake the meaning of that.
__________________
-- Greg
Reply With Quote
  #8  
Old 12-12-2009, 05:12 PM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
Well I never said I was a good programmer.
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)
Reply With Quote
  #9  
Old 12-12-2009, 05:29 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Thanks to all for helping
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #10  
Old 12-12-2009, 06:15 PM
koan00 koan00 is offline
Sage Advanced User
 
Join Date: Oct 2009
Location: Washington, DC
Posts: 125
You should be able to use the Integer object type as well:

java_lang_Integer.toString(int)

Conversions, widening, etc usually wont happen for numeric types to strings: http://java.sun.com/docs/books/jls/s...sions.doc.html

Autoboxing (1.5+): http://java.sun.com/j2se/1.5.0/docs/...utoboxing.html
__________________
[SageTVServer] AthlonII X4 920|ATI 3450/Passive 256MB|4GB PC2-1066|Gigabyte MA770-UD3v2|Seagate 320GB/DB35.3 750GB (DVR HD)|Win7/Ult/x86
[SageTVClient1] AthlonX2 5400|ATI 4550/Passive 512MB|4GB PC2-800|Gigabyte MA770-UD3v1|Creative X-Fi|Seagate 320GB|Win7/Ult/x86|42" LCD
[SageTVClient2] AthlonX2 5400|ATI 4550/Passive 512MB|4GB PC2-800|Gigabyte MA770-UD3v1|Realtek HDA|Seagate 320GB|Win7/Ult/x86|32" LCD
SageTV 6.6.2|SageMC 6.3.9b_24 (clients)|
3x HD-PVR (FiOS) - Firewire Tuning|1x HDHomeRun

Last edited by koan00; 12-12-2009 at 06:20 PM.
Reply With Quote
  #11  
Old 12-12-2009, 07:35 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by koan00 View Post
Conversions, widening, etc usually wont happen for numeric types to strings: http://java.sun.com/docs/books/jls/s...sions.doc.html
Yes, but we're talking Studio expression code here. Argument evaluation and conversion is done by the SageTV expression evaluator before the method is called, so the Java conversion rules don't come into play. Sage has its own rules for type conversion and method lookup, which is why the int + "" trick works.
__________________
-- Greg
Reply With Quote
  #12  
Old 12-12-2009, 10:18 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
sEnse it I my coding I will comment. Gregs method is the way I would do it.

That being said do you need integers stored? If so I can add some overrides in java to accept your integer and return an integer so you don't have to convert it back and fourth in your stv.

Just let's me know sorry I was late to respond was away today.
Reply With Quote
  #13  
Old 12-13-2009, 10:53 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
I used the java_lang_Integer_toString and that worked just fine.

Plucky, I'm not sure what you mean. I'm using your flux_api_Has/Set/RemovePropertyElement methods to store a list of MediaFile IDs. I need to store data that allows me to uniquely identify specific MediaFiles and this seemed like the best way to do that.

If you have a better way to store data that identifies unique MediaFiles I'm open to suggestions.

Tom
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.

Last edited by tmiranda; 12-13-2009 at 11:04 AM.
Reply With Quote
  #14  
Old 12-13-2009, 01:05 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by tmiranda View Post
I used the java_lang_Integer_toString and that worked just fine.

Plucky, I'm not sure what you mean. I'm using your flux_api_Has/Set/RemovePropertyElement methods to store a list of MediaFile IDs. I need to store data that allows me to uniquely identify specific MediaFiles and this seemed like the best way to do that.

If you have a better way to store data that identifies unique MediaFiles I'm open to suggestions.

Tom
are u using getmediafileid and getmediafileforid for storing and using the results. If so you would be better served by getting and storing integers instead of strings in the call of ours you are using. I was just offering to make that possible with the call vs having to do the conversions in studio.
Reply With Quote
  #15  
Old 12-14-2009, 07:27 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Yes I am using those methods (GetMediaFileID and GetMediaFileForID) and I am using your api to store the ID values. The problem I ran into was your api's did not work when I tried to store the ID's directly (because the IDs are integers). Converting the IDs to strings and then storing them with your api's worked.

I am now looking into what happens when I read the values back in using your api's. I'm not sure if they will get converted automatically back to integers or if they will be strings and I need to use java_lang_Integer_decode() to turn them back into integers.

I hope that makes sense. In any case, your api's are easy to work with and do a great job. I just need to understand more about java. (I never would have guessed that passing a wrong parameter to a method would generate an "Unknown Method" error. That makes no sense at all to me.)

Tom
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #16  
Old 12-14-2009, 07:43 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by tmiranda View Post
Yes I am using those methods (GetMediaFileID and GetMediaFileForID) and I am using your api to store the ID values. The problem I ran into was your api's did not work when I tried to store the ID's directly (because the IDs are integers). Converting the IDs to strings and then storing them with your api's worked.

I am now looking into what happens when I read the values back in using your api's. I'm not sure if they will get converted automatically back to integers or if they will be strings and I need to use java_lang_Integer_decode() to turn them back into integers.

I hope that makes sense. In any case, your api's are easy to work with and do a great job. I just need to understand more about java. (I never would have guessed that passing a wrong parameter to a method would generate an "Unknown Method" error. That makes no sense at all to me.)

Tom
They will be returned as strings and have to be reconverted to integers. That is why I was offering to modify the call to accept and return integers to make it easier on you

"Unkown Method" simply is because integers and strings are completely different and currently the java coding only accepts strings not integers.
Reply With Quote
  #17  
Old 12-14-2009, 10:59 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by tmiranda View Post
(I never would have guessed that passing a wrong parameter to a method would generate an "Unknown Method" error. That makes no sense at all to me.)
Java allows method overloading. You can have m(String) and m(int) and those are two different methods. It decides which one to invoke based on the argument type. So if all you have is m(String) and you try to pass in an int, it will tell you "unknown method" because it couldn't find a method called m that takes an int. It's not that you called m(String) with the wrong argument type; by definition that's not possible. What happened was you tried to call a method m(int) that doesn't exist.
__________________
-- Greg
Reply With Quote
  #18  
Old 12-14-2009, 11:58 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Greg, Thanks for the explanation. That makes sense now. Is there anything special I need to do to use java_lang_Integer_decode() to convert a string to an int or is the method as straight forward as it seems?

Plucky, It would be great if you could make the calls accept integers or strings. (Or a new method for integers, whatever is easier.)

Thanks,

Tom
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #19  
Old 12-14-2009, 12:20 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Tom, it gets even more confusing.... using java_lang_integer_decode() will decode an integer into an Integer object, which is not an "int". Depending on your java version you could still end up with a method not found.

In phoenix, I will sometimes create the method signatures that accept an Object, then I determine the type inside the method. This is not ideal programming behaviour, but it saves me from creating a bunch of overloaded methods for each type, int, long, float, string, etc. This viloates greg's "Good programming strives for clarity" approach, but it makes the code more "user friendly" to non developers that don't want to deal with auto-unboxing and type conversions. And if you can read method paramters and/or javadoc, then you still get 'clarity'.

ie, a method that requires an int, might accept look something like this...
Code:
public String GetElementAt(Object index, String[] data) {
    int idx = TotInt(index); // assume you have a ToInt() utility method that return an int
    return data[idx];
}
Sometimes there's a fine line between striving for clarity and making an API that is just easy to use...
Reply With Quote
  #20  
Old 12-14-2009, 12:43 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by stuckless View Post
Tom, it gets even more confusing.... using java_lang_integer_decode() will decode an integer into an Integer object, which is not an "int". Depending on your java version you could still end up with a method not found.

In phoenix, I will sometimes create the method signatures that accept an Object, then I determine the type inside the method. This is not ideal programming behaviour, but it saves me from creating a bunch of overloaded methods for each type, int, long, float, string, etc. This viloates greg's "Good programming strives for clarity" approach, but it makes the code more "user friendly" to non developers that don't want to deal with auto-unboxing and type conversions. And if you can read method paramters and/or javadoc, then you still get 'clarity'.

ie, a method that requires an int, might accept look something like this...
Code:
public String GetElementAt(Object index, String[] data) {
    int idx = TotInt(index); // assume you have a ToInt() utility method that return an int
    return data[idx];
}
Sometimes there's a fine line between striving for clarity and making an API that is just easy to use...

Sean,

Thanks for that idea never thought of doing it that way vs an overload. Have always used overloads...I agree it may not be ideal but would be loads easier to understand and like you said saves allot of coding.

Tom,

Sean is correct you don't want to integer_decode but rather java_lang_Integer_parseInt(String) to get it back to an integer.
I would also recommend a basics on java book or reading some of the great material sun has posted. It has helped me loads. Like Sean told me when I was starting out you got to at least know the basics and knowing that will extend your stvi's so much further, plus coding in a IDE like netbeans is loads easier than in studio for everything IMHO

Also I would load up the old flux api (has been merged with ortus) and add a integer method for you and send you the jar.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Recording Errors - Unknown Cause jillsy SageTV Software 0 03-06-2009 12:44 AM
HDPVR showing up as unknown device after replugging in. personalt Hardware Support 9 11-02-2008 09:35 AM
Error:Unknown Internal Screen on MC Main Menu McBainWRX SageMC Custom Interface 2 08-01-2008 05:39 AM
Fix for unknown wma "bug" perry59 SageTV Software 1 10-31-2007 10:29 AM
HD channel tuning and guide data for an 'unknown' channel snoopy SageTV EPG Service 5 05-04-2007 11:24 AM


All times are GMT -6. The time now is 06:04 PM.


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