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 06-07-2009, 02:48 PM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
java contructor parameters

When writing a java class to be called from Sage, what parameters are used in the invocation of the class that would be used for the constructor?

I would like for the class to load some data to cache to be used by later method calls...

Thanks,
Jeff
Reply With Quote
  #2  
Old 06-07-2009, 04:30 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
The syntax is new_package_Class(args), per p. 151 of the Studio manual.
__________________
-- Greg
Reply With Quote
  #3  
Old 06-08-2009, 08:42 AM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
Thanks, that did it, plus I didn't have the contructor declared as public which caused it not to work...

One question on how the studio manual shows how to use it. When you create a new instance of the class, and call the method with has the newly created object as the first argument, do you need to setup a method in the class to call the method within the object that is passed... I know that sounds a bit confusing... For example in sudo code:

Sage Define new instance:
X = new_package_class();

Sage Method call:

package_class_method(X,args)

Java:

class class
{
method(args)
{
some code
return value
}

method(Object o,args)
{
return o.method(args)
}
}

I was originally testing without using the object passed into the java class and it seem to always use the last object created....

Sorry if this sounds convoluted...

Thanks,
Jeff
Reply With Quote
  #4  
Old 06-08-2009, 08:56 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Assuming the following sample java....
Code:
package test.sage;
public class Foo {
    public Foo() {
    }

    public String hello(String name) {
        return "Hello " + name;
    }
}
in your stv code, you'd have something like...
FooInstance=new_test_sage_Foo()
Text=test_sage_Foo_hello(FooInstance, "world")

So, you can use existing java objects as is... ie,
File=new_java_io_File("myfile.jpg")
Exists=java_io_File_exists(File)

Hope that makes sense.
Reply With Quote
  #5  
Old 06-08-2009, 09:14 AM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
I thought that is what I was doing. I had a method that had no args, and when I called it like you have it in your example, I was getting a java exception. When I added an (Object o) as the argument and basically ignored o in the code, the call worked. I will test it when I get home with your sample snippet, maybe I had another issue at the same time and was chasing a red hearing...

Thanks,
Jeff
Reply With Quote
  #6  
Old 06-09-2009, 04:02 AM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
Thanks for your help Greg/Sean... Turned out to be a problem with my public/static on the methods..

Some reason, Eclipse suggested I put the static in while doing some testing, and after some cutting and pasting, it ended up all over...

Once I got them all straight, it is working like a charm...

Thanks again,
Jeff
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
Screen Saver parameters for Slideshow Zorglub SageTV Beta Test Software 1 10-19-2006 08:15 PM
Extender Transcoding - property parameters? Mahoney SageTV Media Extender 18 08-31-2006 02:57 PM
CVD parameters CBenvie SageTV Software 2 01-02-2005 10:23 PM
Command line parameters? Opus4 SageTV Software 1 04-03-2004 03:44 AM
are there any brightness parameters for the UI? GbrNole SageTV Beta Test Software 2 01-28-2004 02:57 PM


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


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