Returning several values from a C native method

Hi,
I need to return 3 values from a native methode : an int (the return code), a string of variable length and a double.
In pure C, my function would be defined as "int f ( char* s, double* d)", and I would "malloc" the string into the calling function, then copy my string to "s" and use "*d" to return the double...
Is there a way to do that with JNI? I found some examples where the native function returns only one parameterlike: "return(*env)->NewStringUTF(env, buffer);" But I didn't find examples where the native function returns several parameters, including a string.
Thanks in advance!
JM

This really has nothing to do with JNI.
You have a method, and you want to return more than one type of value.
The following solutions are possible.
1. Return an array that contains all the values (actual return value.)
2. Return an object that contains all the values (actual return value.)
3. Use an array via the parameter list and fill in a value.
4. Use an object via the parameter list and fill in the values.

Similar Messages

  • Return multiple values from a method

    For a school project I have to make a parameter-less constructor that can input values from the keyboard and calculate those values. Now that I have the values how do I return them? I need to return 3 values from this parameter-less method.
    I hoope someone can help.

    Qwertyfshag wrote:
    Here is the wording of the assignment. I have copied and pasted it word for word:
    "Declare and use a no-argument (or "parameter-less") constructor to input the data needed, and to do the calculations."
    Any advice???Find a teacher who isn't an idiot. That sentence is vague ("to input the data needed"? Does that mean that it's supposed to query the user (which is terrible) or that it's supposed to encapsulate the data as hardcoded values, or what?) and is a bad design. Constructors shouldn't do this sort of thing.
    Ok I have done that part and now I want to retrieve the values of the calculations. How can I get those values out of that method What do you mean "that method"? Constructors aren't methods, and they don't return values.
    I suppose you could define a class whose constructor queries the user, and which would have a method to return values. That could be pretty simple; the method signature would be like this:
    Set<Integer> getValues();
    This seems like an advanced problem.It's not advanced; it's just garbage.
    I can't post the code in hear because that may constitute cheating. I am allowed to discuss it verbally but I cannot share code, sorry.You can't get a lot of help then. We can't psychically see what you've done so far.
    In conclusion: I have to have two methods. One method is a constructorConstructors aren't methods. If your teacher told you that they are, then he/she doesn't know what he/she is doing.
    that has NO parameters that will get input from the keyboard (done) and do the calculations (done). The other method must print that values to the screen on separate lines (not done). I don't know how to get the values out of the method.If they're two methods in the same class, then the constructor just needs to store the user input into a field of the class, and the other method can read the values in that field.

  • [UIX] How To: Return multiple values from a LOV

    Hi gang
    I've been receiving a number of queries via email on how to return multiple items from a LOV using UIX thanks to earlier posts of mine on OTN. I'm unfortunately aware my previous posts on this are not that clear thanks to the nature of the forums Q&A type approach. So I thought I'd write one clear post, and then direct any queries to it from now on to save me time.
    Following is my solution to this problem. Please note it's just one method of many in skinning a cat. It's my understanding via chatting to Oracle employees that LOVs are to be changed in a future release of JDeveloper to be more like Oracle Forms LOVs, so my skinning skills may be rather bloody & crude very soon (already?).
    I'll base my example on the hr schema supplied with the standard RDBMS install.
    Say we have an UIX input-form screen to modify an employees record. The employees record has a department_id field and a fk to the departments table. Our requirement is to build a LOV for the department_id field such that we can link the employees record to any department_id in the database. In turn we want the department_name shown on the employees input form, so this must be returned via the LOV too.
    To meet this requirement follow these steps:
    1) In your ADF BC model project, create 2 EOs for employees and departments.
    2) Also in your model, create 2 VOs for the same EOs.
    3) Open your employees VO and create a new attribute DepartmentName. Check “selected in query”. In expressions type “(SELECT dept.department_name FROM departments dept WHERE dept.department_id = employees.department_id)”. Check Updateable “always”.
    4) Create a new empty UIX page in your ViewController project called editEmployees.uix.
    5) From the data control palette, drag and drop EmployeesView1 as an input-form. Notice that the new field DepartmentName is also included in the input-form.
    6) As the DepartmentName will be populated either from querying existing employees records, or via the LOV, disable the field as the user should not have the ability to edit it.
    7) Select the DepartmentId field and delete it. In the UI Model window delete the DepartmentId binding.
    8) From the data controls palette, drag and drop the DepartmentId field as a messageLovInput onto your page. Note in your application navigator a new UIX page lovWindow0.uix (or similar) has been created for you.
    9) While the lovWindow0.uix is still in italics (before you save it), rename the file to departmentsLov.uix.
    10) Back in your editEmployees.uix page, your messageLovInput source will look like the following:
    <messageLovInput
        model="${bindings.DepartmentId}"
        id="${bindings.DepartmentId.path}"
        destination="lovWindow0.uix"/>Change it to be:
    <messageLovInput
        model="${bindings.DepartmentId}"
        id="DepartmentId"
        destination="departmentsLov.uix"
        partialRenderMode="multiple"
        partialTargets="_uixState DepartmentName"/>11) Also change your DepartmentName source to look like the following:
    <messageTextInput
        id=”DepartmentName”
        model="${bindings.DepartmentName}"
        columns="10"
        disabled="true"/>12) Open your departmentsLov.uix page.
    13) In the data control palette, drag and drop the DepartmentId field of the DepartmentView1 as a LovTable into the Results area on your page.
    14) Notice in the UI Model window that the 3 binding controls have been created for you, an iterator, a range and a binding for DepartmentId.
    15) Right click on the DepartmentsLovUIModel node in the UI Model window, then create binding, display, and finally attribute. The attribute binding editor will pop up. In the select-an-iterator drop down select the DepartmentsView1Iterator. Now select DepartmentName in the attribute list and then the ok button.
    16) Note in the UI Model you now have a new binding called DCDefaultControl. Select this, and in the property palette change the Id to DepartmentName.
    17) View the LOV page’s source, and change the lovUpdate event as follows:
    <event name="lovSelect">
        <compound>
            <set value="${bindings.DepartmentId.inputValue}" target="${sessionScope}" property="MyAppDepartmentId" />
            <set value="${bindings.DepartmentName.inputValue}" target="${sessionScope}" property="MyAppDepartmentName" />
        </compound>
    </event>18) Return to editEmployees.uix source, and modify the lovUpdate event to look as follows:
    <event name="lovUpdate">
        <compound>
            <set value="${sessionScope.MyAppDepartmentId}" target="${bindings.DepartmentId}" property="inputValue"/>
            <set value="${sessionScope.MyAppDepartmentName}" target="${bindings.DepartmentName}" property="inputValue"/>     
        </compound>
    </event>That’s it. Now when you select a value in your LOV, it will return 2 (multiple!) values.
    A couple things to note:
    1) In the messageLovInput id field we don’t use the “.path” notation. This is mechanism for returning 1 value from the LOV and is useless for us.
    2) Again in the messageLovInput we supply “_uixState” as an entry in the partialTargets.
    3) We are relying on partial-page-refresh functionality to update multiple items on the screen.
    I’m not going to take the time out to explain these 3 points, but it’s worthwhile you learning more about them, especially the last 2, as a separate exercise.
    One other useful thing to do is, in your messageLovInput, include as a last entry in the partialTargets list “MessageBox”. In turn locate the messageBox control on your page (if any), and supply an id=”MessageBox”. This will allow the LOV to place any errors raised in the MessageBox and show them to the user.
    I hope this works for you :)
    Cheers,
    CM.

    Thanks Chris,
    It took me some time to find the information I needed, how to use return multiple values from a LOV popup window, then I found your post and all problems were solved. Its working perfectly, well, almost perfectly.
    Im always fighting with ADF-UIX, it never does the thing that I expect it to do, I guess its because I have a hard time letting go of the total control you have as a developer and let the framework take care of a few things.
    Anyway, I'm using your example to fill 5 fields at once, one of the fields being a messageChoice (a list with countries) with a LOV to a lookup table (id , country).
    I return the countryId from the popup LOV window, that works great, but it doesn't set the correct value in my messageChoice . I think its because its using the CountryId for the listbox index.
    So how can I select the correct value inside my messageChoice? Come to think of it, I dont realy think its LOV related...
    Can someone help me out out here?
    Kind regards
    Ido

  • How to select several values from a user exit variable in a planning folder

    Hello,
    I have created a user exit variable for limiting the values only to which the user need to access.
    For a simulation part, it is then necessary for him to select several values from these values (not only one, and not all)
    But It seems in this case the user has only two possibilities :
    - keep all the values without any restriction
    - restrain the selection to only one value.
    It seems possible for the user to access to a multiple choice window, but this possibility doesn't seems to work : in all tests we did, only the first value was taken into account by BPS.
    If this method is not good do you know an other manner to permit the user to choice several values amongst a set of pre-selected  (because the original set is too important) values ?
    Thanks for your help.

    Hi Mayank,
    Thanks for your response, but I don't think it corresponds to my problem.
    I my case, I use a user exit variable to filter some data. It seems BPS offers the possibility to the user to select several values amongts the pre-selected values presented by the user exit variable, but it doesn't work. We can use a popup in which we enters the required values, but in final, only the first value is taken into account.
    I don't know if it is due to a BPS bug or if it is not a good solution in regard to BPS philosophy. In this case, the concerned caracteristic isn't in the header but in lead columns.
    I must present a solution to my client next monday, so I have not enough time to open an OSS message.
    An alternate solution should be interesting too.
    My need is to present to a user a selection of values amongst all values from an infoobject (the user exit variable seemed to be a good solution) and the user must have the possibility to select some values amongst these as filter.
    Regards

  • How to return multiple values from dialog popup

    hi all
    I'm using ADF 10g. I have a requirement that I have to return multiple values from a dialog.
    I have a page containing a table with a button which calls the dialog. The dialog contains a multi-select table where i want to select multiple records and add them to the table in the calling page.
    In the backing bean of the calling page, I have the returnListener method.
    I am thinking that I have to store the selected rows from dialog in an array and return that array to the returnListener...but I don't know how to go about it with the code.
    Can someone help me out with it?
    thanks

    Hi Frank,
    I'm trying to implement your suggestion but getting comfused.
    AdfFacesContext.getCurrentInstance().returnFromDialog(null, hashMap) is called in ActionListener method, from what I understood.
    ReturnListener method already calls it, so no need to call explicitly.
    Okay here's what i'm doing.
    command button launches the dialog on the calling page.
    In the dialog page, there is a button "select", which when i click, closes the dialog and returns to calling page. I put a af:returnActionListener on this button, which logically should have a corresponding ReturnListener() in the calling page backing bean.
    Now I have 3 questions:
    1. do i have to use ActionListener or ReturnListener?
    2. where do I create the hashMap? Is it in the backing bean of the dialog or in the one of calling page?
    3. how do I retrieve the keys n values from hashmap?
    please help! thanks
    This is found in the backing bean of calling page:
    package mu.gcc.dms.view.bean.backing;
    import com.sun.java.util.collections.ArrayList;
    import com.sun.java.util.collections.HashMap;
    import com.sun.java.util.collections.List;
    import java.io.IOException;
    import java.util.Map;
    import javax.faces.application.Application;
    import javax.faces.application.ViewHandler;
    import javax.faces.component.UIViewRoot;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import javax.faces.event.ActionEvent;
    import mu.gcc.dms.model.services.DMSServiceImpl;
    import mu.gcc.dms.model.views.SiteCompaniesImpl;
    import mu.gcc.dms.model.views.SiteCompaniesRowImpl;
    import mu.gcc.dms.model.views.lookup.LkpGlobalCompaniesImpl;
    import mu.gcc.util.ADFUtils;
    import mu.gcc.util.JSFUtils;
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCBindingContainer;
    import oracle.adf.model.binding.DCIteratorBinding;
    import oracle.adf.view.faces.context.AdfFacesContext;
    import oracle.adf.view.faces.event.ReturnEvent;
    import oracle.adf.view.faces.model.RowKeySet;
    import oracle.binding.AttributeBinding;
    import oracle.binding.BindingContainer;
    import oracle.binding.OperationBinding;
    import oracle.jbo.AttributeDef;
    import oracle.jbo.Key;
    import oracle.jbo.Row;
    import oracle.jbo.RowIterator;
    import oracle.jbo.RowSetIterator;
    import oracle.jbo.domain.Number;
    import oracle.jbo.server.java.util.Iterator;
    public class CompanyList {
    private BindingContainer bindings;
    private Map hashMap;
    DMSServiceImpl service =(DMSServiceImpl)ADFUtils.getDataControlApplicationModule("DMSServiceDataControl");
    SiteCompaniesImpl siteCompanyList = service.getSiteCompanies();
    LkpGlobalCompaniesImpl globalCompanyList = service.getLkpGlobalCompanies();
    public CompanyList() {
    public BindingContainer getBindings() {
    return this.bindings;
    public void setBindings(BindingContainer bindings) {
    this.bindings = bindings;
    *public void setHashMap(Map hashMap) {*
    *// hashMap = (Map)new HashMap();*
    this.hashMap = hashMap;
    *public Map getHashMap() {*
    return hashMap;
    public String searchCompanyButton_action() {
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    bindings.getOperationBinding("Execute");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    *public void addCompanyActionListener(ActionEvent actionEvent){*
    AdfFacesContext.getCurrentInstance().returnFromDialog(null, hashMap);
    public void addCompanyReturnListener(ReturnEvent returnEvent){
    //how to get hashmap from here??
    public String addCompanyButton_action() {
    return "dialog:globalLovCompanies";
    }

  • Function returns several values

    hi,
    is it possible that function would return several values, for ex.:
    select myfunct().val1, myfunct().val2 from dummy_table

    To add to the above,
    How ever, a procedure using IN OUT parameters is not useful for SELECT statements,
    One way is, you could use PL/SQL tables for that, here is how you do it-- create a SQL type
    create type emp_num as table of number;
    -- declare an array of emp_num type and use it to store multiple values
    create or replace function getemp_num(ind Number) return Number Is
       vEmpArray emp_num := emp_num();
    Begin
       FOR rec in (select empno from my_emp)
       Loop
          vEmpArray.extend;
          vEmpArray(vEmpArray.count) := rec.empno;
       End loop;
       RETURN vEmpArray(ind);
    End;
    -- use the fn to return more than one value
    select getemp_num(4), getemp_num(5) from dual;Thx,
    SriDHAR

  • How do I return two values from a stored procedure into an "Execute SQL Task" within SQL Server 2008 R2

    Hi,
    How do I return two values from a
    stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
    Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
    Something like ?
    CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
    @intPeriod INT,
    @strPeriod_Length NVARCHAR(1),
    @dtStart NVARCHAR(8) OUTPUT,
    @dtEnd NVARCHAR(8) OUTPUT
    AS
    then within the SSIS component; -
    Kind Regards,
    Kieran. 
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

    Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
    Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
    Add a script task to check ssis variables values using,
    Msgbox(Dts.Variables("User::strExtractStartDate").Value)
    Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
    Regards, RSingh

  • How do I return a value from a column based on info from neighboring columns?

    I have a table of data that looks similar to this:
    Weight
    Name
    School
    Division
    106
    Name1
    School1
    1
    106
    Name2
    School2
    2
    106
    Name3
    School3
    3
    106
    Name4
    School4
    4
    113
    Name5
    School5
    1
    113
    Name6
    School6
    2
    113
    Name7
    School1
    3
    113
    Name8
    School3
    4
    It's a very large table, so there will be multiple matches for Schools, and occasionally a few matches for Names, but there will always be only one match for a given Weight and Division.
    In a separate table, how can I get the name of the person associated with the unique weight and division?
    In my head, the formula goes" "Look in the Weight column to find 106, then look in the Division column to find 4, then return the value from the Name column." But I can't figure out the formula that will do that.
    Any thoughts?

    Hi momogabi,
    This can be easily done with an index column.
    The formula I used in your original table for the index column is:
    =A2&"-"&D2. This was filled down. The column can be hidden.
    You can see the formula in the search table. If I wanted to eliminate the index column in that table the formula would look something like:
    =INDEX('Table 1-1'::B,MATCH(A2&"-"&B2,'Table 1-1'::E,0),1)
    Hope this helps.
    quinn

  • How to return a value from sql plus activity

    Hi,
    I want to return a value from sqlplus activity to a processflow variable.
    SQL PLUS activity has a property :"RESULT_CODE", whenever i run the process flow this value is always reurned as 0.
    in sqlplus activity i have written some pl/sql block....
    for example
    begin
    end;
    exit
    i want to do something like
    begin
    if v=100 then
    return 1
    else
    return 0;
    end if;
    end;
    exit
    can some please tell me how can i return value from this pl/sql block to proessflow.
    Regards,
    RD_RBS

    table ==> function
    input param from table to function. ==> input mapping paramter to store the output from the mapping.
    Will this now work.

  • Returning a value from a LOV to the main document

    Hi,
    I'm using jheadsrart with uix, I have a form with a LOV. When I chose a value in the LOV, I need to return another value from that LOV to a hidden field in my main document.
    How can I do that?
    Thanks for your help!
    Martin

    Hi Rohit,
    Just declare the two variables var1(variable for checking data) & var2(variable for counter) in your include program.
    Inside the include you can do the coding as under:
    IF VAR1 <condition for checking data>.
    VAR2 = VAR2 + 1.
    ENDIF.
    Now you can check the value of the variable VAR2 in the main program & call the desired function.
    Regards,
    Chetan.
    PS:Reward points if this helps.

  • Radio Buttons - returning individual values from an exclusion group possible?

    Using LC Designer 7.1
    Does anyone know if it is possible to return individual values from an exclusion group of radio buttons?  My xml data file gives one value for the entire group, e.g.,
    2
    ...where the second radio button was selected.  But I'd prefer an output something like this...
      0
      1
      0
    etc...
    Is something in this format possible?

    You might be better off to use checkboxes and script them to act like radio buttons (as an exclusion group). That way they'd each have an on/off value.
    Regards,
    Dave

  • Returning multiple values from a method

    I have to return a string and int array from a method (both are only of size 5 for a total of 10) What would be considered the best manner in which to do this ?
    Dr there's 10 points in it for you or whoever gives me the best idea ;-P

    hey here it is easy that you can return many things
    what ever you want from a single method man....
    you know the main thing what you have to do is.....
    Just create a VECTOR or LIST object, then add all the
    values what ever you want to return like string and
    int array like etc...
    Then make the method return type is VECTOR and after
    getting the Vector you can Iterate that and you can
    get all the values from that method what ever you
    want....
    jus try this,,,,,,,,,,
    Its really work......
    reply me..but it relies purely on trust that the returned collection would contain exactly the right number and type of arguments

  • Capture Return Value from Contextual Events Subscriber Method

    Hi
    I was wondering if anyone knew whether you could capture the return value from a method exposed as  a subscriber for a contextual event?
    Requirement: We have 2 bounded task flows (parent-child) with the child task flow embedded as a region in a view activity in the parent task flow.  Based on an action in the parent task flow we raise a contextual event which calls an application module method exposed as a data control within the child task flow.  We need to be able to capture the return value from the method on the managed bean.
    Example method within child task flow application module:
    public String contextualEventSub(){
      Return "Y";
    So here we would like to capture String value when the event is raised by the event producer (parent task flow action).
    Within the Event Map on the page definition of the parent task flow view activity it is possible to set parameters to pass to the subscriber but it’s not obvious where you can capture the return value.
    Many thanks!
    Technology:
    ADF 11.1.1.7 – ADFbc with ADF task flows and page fragments

    Check this URL it may help you
    One size doesn't fit all: JDev 11g: Programmatic Contextual Events

  • Return multiple values from a web method??

    Hi,
    I am wondering if it's possible for a web method to return multiple values to a client. I know each web method can return only one value of a given data type. I am looking for something like ref or out keyword in C#. If it's not available, is there any workaround? Thanks.
    Regards

    Java web service endpoints can return multiple values by using the javax.xml.rpc.holders classes. The following post might help:
    http://forum.java.sun.com/thread.jspa?threadID=684916
    If you'll be returning lots of values, it might be worth considering a document-style implementation rather than RPC-style.

  • How to trap null return values from getters when using Method.invoke()?

    Hi,
    I am using Method.invoke() to access getters in an Object. I need to know which getters return a value and which return null. However, irrespective of the actual return value, I am always getting non-null return value when using Method.invoke().
    Unfortunately, the API documentation of Method.invoke() does not specify how it treats null return values.
    Can someone help?
    Thanks

    What do you get as a result?I think I know what the problem is.
    I tested this using following and it worked fine:
    public class TestMethodInvoke {
    public String getName() {
    return null;
    public static void main(String args[]) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    Object o = new TestMethodInvoke();
    Class cls = o.getClass();
    Method m = cls.getMethod("getName", (Class[]) null);
    Object result = m.invoke(o, (Object[])null);
    if (result == null) {
    System.err.println("OK: Return value was null as expected");
    else {
    System.err.println("FAILED: Return value was NOT null as expected");
    However, when I use the same technique with an EJB 3.0 Entity class, the null return value is not returned. Instead, I get a String() object. Clearly, the problem is the the EJB 3.0 implementation (Glassfish/Toplink) which is manipulating the getters.
    Regards
    Dibyendu

Maybe you are looking for

  • Sales order -  automatic creation of purchase order - problem on Credit Che

    Hello, We have a problem in sales order. For one item, we have an automatic creation of Purchase requisation, but we have to give manually the price in the purchase requisition. The problem is when we have give the price, the automatic credit check i

  • Audtion CC hangs, then crashes on Windows 7 Ultimate x64

    I'm not sure what's going on as it has launched previously.  It hangs on the splash screen while displaying, "initializing required application components... (DLMS)" then eventually stops responding and crashes.  I've cleared preferences, in additio

  • Photoshop merged my layers for me, can I recover

    I exported a project as a pdf by clicking Save As under the file menu, then I saved the original psd by choosing Save As again and selecting PSD this time.  When I came back to the project today all the layers had been merged into one.  I _never_ mer

  • Link to other document files

    How to link a PDF, word, & Excel file in fla by clicking a button? A separate window should open for the linked document with the swf file still open in the background.

  • My Personal Workflow for DVD Authoring in Encore

    This is being posted, due to requests for workflow recs. from a few other threads. It is separate from those threads, but I will try to link to his post in those. The DVD Specs. are quite strict on what is allowed, and in what exact form, in a DVD to