Getting the object of a class that is already running

there is one class a
i created an object of class a
a a1 = new a();
i am in class B
i want to get the 'a' class instance that is already running ie i want to access object a1 and these classes are not related. Can i get them?
If yes how?
It is urgent.

1. class B could encapsulate class A.
Class B
   A a1;
   public B(A a1)
      this.a1 = a1;
   //......remaining part of class
}Now when you create an object of B, you could pass the a's object to B's constructor,
   A a1 = new A();
   B b1 = new B(a1);
  // to access the a object within b, usage is as below
   b1.a1.<a's methods>2. If you wish that the object of class A is required only in some methods of B, pass it as a parameter to B's methods
class B
   public void someMethodThatNeedsA'sObject(A a1)
      //do something with a's object here
      //do something with B's own variables
   psvm() //main
       A a1 = new A();
       B b1 = new B();
       b1.someMethodThatNeedsA'sObject(a1);
}ram.

Similar Messages

  • Getting the objects for a class

    I am able to get all live classes of a dynpro by using method cl_gui_cfw=>get_living_dynpro_controls. (Also thanks to this forum).
    The resulting table has a reference to a class like ...
    How do I use this reference to:
    1. Get the objects for it?
    2. How can I then free the object from memory by using the "free" method.
    I guess I am asking how to dynamically assign it, then make sure it has a free method and then to use the method to actually free it.

    Hello Uwe
    My first reaction was "NO it cannot be that easy!!". It almost was but on the second line I get a short dump. Then I realised why: the other live control in the table was a sub class of the first class and as a result it was cleared on the first call.
    So I modified the call to be a recursive call (of the form) as follows...
    form clear_live_controls .
    DATA:
      gt_list       TYPE cnto_control_list,
      gt_wa like line of gt_list.
      REFRESH: gt_list.
      CALL METHOD cl_gui_cfw=>get_living_dynpro_controls
        IMPORTING
          control_list = gt_list.
      describe table gt_list lines tab_lines.
      if tab_lines = 0.
    *    Nothing
      else.
         loop at gt_list into gt_wa.
           gt_wa->free( ).
           exit.
         endloop.
         perform clear_live_controls.
      endif.
    endform.                    " clear_live_controls
    This took care of it.
    Many thanks for your help.
    Regards

  • How to recover the objects (iView, Page etc) that have already been deleted

    Dear All,
    We found the problems. We deleted the objects (such as iViews, System, Pages, Workset etc.) that we don't want to delete it. If there is the way to recover them, please help us.
    Thank you very much.
    Anek.

    HI,
    You can use PCD Inspector  and try to recover your iviews and pages.
    This link will tell u how to use it:
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4ee6d3ee-0901-0010-658f-d9b21cdebce4|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4ee6d3ee-0901-0010-658f-d9b21cdebce4]
    You can download it from SDN from [here|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4929b690-0201-0010-c992-c8f0a2546d3f]
    I hope it helps
    Regards,
    Sumit

  • Getting the name of outer class in an inner class

    Hi,
    I have a private inner class, something like this:
    public class OuterClass extends AnotherClass {
    public OuterClass() {
    supre();
    private class innerClass1 extends SomeotherClass {
    protected void someMethod() {
    // how to get the name of outer class, that is, "OuterClass"
    Can someone please tell me how to get the name of the outer class inside the inner class method?
    Thanks in advance..
    Prasanna

    getClass().getEnclosingClass().getName()But then, you already know it, don't you?

  • How to get the object class field value in CDHDR table for vendor

    hi
    how to get the object class field value in CDHDR table for vendor

    Try KRED/KRED_N as object class in CDHDR for Vendor.

  • OIM - Task Assignment Adapter - How to get the object instance key?

    Hello experts,
    I'm trying to use a task assignment adapter to assign an approval task dynamically. Basically, the user can request a resource like "CustomApp Profiles" and we create an object form to let them choose the profile that he needs. Each profile has an owner, which is populate in a Lookup (Owner is the code and Profile is the decode).
    So, in the approval task, I need to get the profile selected by user in the object form and search into the lookup who is the owner of that profile. But I don't know how can I get the object instance key using the parameters that can be mapped to a task assignment adapter.
    Looking into the OIM documents, I believe that the easier way is using the request key, because the REQ_KEY is a foreign key in OBI table.
    Did anyone knows how can I get the object instance key using the request key? Can I use some API or should I execute a SQL statement directly in OIM database?
    Best Regards,
    Nitto

    To retry a task that is in a rejected state, you use the SCH_KEY which is the task key.  In OIM, all rejected tasks are listed in the OTI table.  It contains all the important information about a rejected or pending task.
    You can use the APIs found in the tcProvisioningOperationsIntf class to retrieve open tasks.
    -Kevin

  • Is it possible in an html to call the objects of a class?

    Hi,
    Please help me.I have already posted it, but it's very urgent i am in need for an working answer.
    I am calling an applet class 2 times in a browser.To share some variable i have declared as private static. But when i call these applets are called in different browsers , still these variables are shared.
    Actually i want the applets in one browser to be independent of the other applets in a separate browser. Can anyone help me to solve this problem?
    Is it possible in an html to call the objects of a class?
    Is there any some workarounds? For instance calling applets in separate JVM in the same machine.Any idea how to do that?
    Another option is using something like the session variables. But is that possible in a variable inside the applet class?
    Thanks in advance to all the solutions. Hope someone clicks an idea from the above possibilities.

    To get a reference to other applets in the same JVM (actually same browser window), do the following:
    //get a reference to the other applets in the same browser window
    java.applet.AppletContext appCon = yourAppletRef.getAppletContext();
    JApplet applet = (JApplet) appCon.getApplet(otherAppletName);or use AppletContext.getApplets() to get an enumeration of all the accessible applets. If you want to use the Session object to store your values, then, in your javascript, make a call to the applet methods. Use JSP expressions for the value of these session String values (i.e. <%= %>) to set the parameters of your applet methods. In a nutshell, it is possible. I hope this helps.

  • Get the objects for getDeclaredFields

    Hi,
    Can I get the objects of the Fields in my class.
    I want to go through my Fields and find the ones with a certain suffix in there name. This I have done with getDeclaredFields. But know I want to get and set the data for the corresponding objects.
    for (Field zField : getClass().getDeclaredFields())
        if (zField.getName().endsWith("_Save"))
             // I need somethign that will do something like this. I know the next lines don't work
             Object zObject = zField.getObject();
             if (zObject  instenceof jCheckBox)
                 ((jCheckBox)zObject).isSelected();
    }Thanks,
    Shaul

    Shaul wrote:
    I'm sorry. I didn't understand that the object is the one that contains the objects that I need.Exactly. And if the field is static you pass in 'null'

  • How to programmatically get the source for a class provided the class name?

    Hello,
    As a quick background, I am providing some tools to potential users of an in-house framework. One is the ability to generate quick prototypes from our existing demo applications. Assume a user downloads our jars and uses them in their project (we are using Eclipse, but that detail should not greatly affect my question). Included in the jars is a demos package that contains ready-to-run classes that serve to exhibit certain functionality. Since many users may just need quick extensions of these demos, I am trying to provide a way for them to be able to create a new project that starts with a copy of the demo class.
    So, the user is provided a list of the existing demos (each one uses a single class). When the user makes their selection, with the knowledge of our framework, I can translate that into what demo class they need (returned as a string of format package.subpack1.subpackn.DemoClassName). What I now want to do is to use that complete class name to get the source (look up the file) for the corresponding class, and copy it into to a new file in their project (the copying into the project can be done easily in Eclipse, so what I need help with is the bolded part). Is there a simple way to get the source given a class path for a class as described above? You may assume the source files are included in the jars for the framework.
    Thanks in advance.

    If there's a file named "package.subpack1.subpackn.DemoClassName.java" in a "demos" directory in the jar, then yes. You'd just use
    InputStream code = getResourceAsStream("/demos.package.subpack1.subpackn.DemoClassName.java");Or if those dots in the name actually separate directory names, i.e. you have a "package" directory under "demos" and a "subpack1" director under that and so on, then:
    InputStream code = getResourceAsStream("/demos/package/subpack1/subpackn/DemoClassName.java");

  • Line Chart: It is possible to get the object reference from a flash chart

    Hi Folks,
    hope you feel well ...
    I wan't to get the Object Reference from a Chart Flash Object using javascript in the HTML Header of a Apex Page.
    It's long time ago with Oracle/Java and so my skills are really shity :-)
    The Functionbody works, but the following error occurs: chart.refresh is not a function
    It is necessary to CAST it ? with the Class AnyChart.js ?
    After 5 hours i give up ^^ is this kind of object handling possible ? THX4HELP@ll
    Apex Page HTML Header
    <script type="text/javascript">
    function hideSID2()
    var chart = document.getElementById("*c7067437546726610*");
    chart.refresh();
    </script>
    HTML File at runtime:
    <div class="rc-body"><div class="rc-body-r"><div class="rc-content-main"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
    width="1400"
    height="600"
    id="c7067437546726610"
    align="top"> ...

    If you are using adobe Flex Builder to develop SWF, please be sure using ExternalInterface class to expose the refresh() method.
    then you can should be able to call this method in Javascript.

  • Workitem ID wise to get the Object value

    Hi All,
    is it possible to get the object value form Workitem id wise.
    for example workitem id '446085' based on that workitem id i want to retrieve the object value.
    Please clarify.,
    Thanks & Regards
    K.Gunasekar.

    Hi
    I want to update the object Reference.
    for example i am getting the object value from SAP_WAPI_GET_OBJECTS. (F.M)
    based on the workitem_id.
    i want to update the objects reference from the original one.
    if is it possible means please let me know.
    Thanks & Regards
    K.Gunasekar.

  • Getting the Object Access key

    This weird question,
    But does any one know how to get the object access key for Standard SAP object is changed..
    Normally when we try to do any modification on Standard SaP object it asks for and access key.. We need to enter it once, after which the object is open for editing.
    I have an SAP object which as been modified .
    I want to know that number?? Is it possible..
    Any help will be highly appreciated..
    Regards,
    Samir.

    Hi Samir,
    You have to contact SAP Support to obtain the access key for a Standard SAP Object. The correct channel for that is the OSS, where yo can raise a message requesting the same.
    But you are saying that there's one object that has already been modified. Who has done the modification ? When they have done it, they must have specified the access key. If you want to modify the same object, then the best thing for you to do is to contact the person who has changed it.
    By the way, have the modifications been done using the Modififcation Assistant?
    Regards,
    Anand Mandalika.

  • How to pass the object of one class to the another class?

    Hello All,
    My problem is i am sending the object of serializable class from one class to another class but when i collection this class into another it is transfering null to that side even i filled that object into the class before transfer and the point is class is serializable
    code is below like
    one class contain the code where i collecting the object by calling this function of another class:-
    class
    lastindex and initIndex is starting and ending range
    SentenceStatusImpl tempSS[] = new SentenceStatusImpl[lastIndex-initIndex ];
    tempSS[i++] = engineLocal.CallParser(SS[initIndex],g_strUserName,g_strlanguage,g_strDomain);
    another class containg code where we transfering the object:-
    class
    public SentenceStatusImpl CallParser(SentenceStatusImpl senStatus, String strUserName, String strLanguage, String strDomain)
    *//here some code in try block*
    finally
    System.+out+.println("inside finally...........block......"+strfinaloutput.length);
    senStatus.setOutputSen(strfinaloutput);//strfinaloutput is stringbuffer array containg sentence
    fillSynonymMap(senStatus);
    senStatus.setTranslateStatus(*true*);
    return senStatus;
    Class of which object is serialized name sentenceStatusimpl class:-
    public class SentenceStatusImpl implements Serializable
    ///Added by pavan on 10/06/2008
    int strSourceSenNo;
    String strSourceSen = new String();
    String strTargetSen = new String();
    StringBuffer[] stroutputSen = null;
    HashMap senHashMap = new HashMap();
    HashMap dfaMarkedMap = new HashMap();
    boolean bTargetStatus = false;
    public SentenceStatusImpl(){
    public void setOutputSen(StringBuffer[] outputSen){
    stroutputSen = outputSen;
    public StringBuffer[] getOutputSen(){
    return stroutputSen;
    public void setTranslateStatus(*boolean* TargetStatus){
    bTargetStatus = TargetStatus;
    }//class

    ok,
    in class one
    we are calling one function (name callParser(object of sentenceStatusImpl class,.....argument.) it return object of sentenceStatusImple class containg some extra information ) and we collecting that object into same type of object.
    and that sentenceStatusImple classs implements by Serializable
    so it some cases it is returning null
    if you think it is not proper serialization is please replay me and suggest proper serialization so that my work is to be done properly (without NULL)
    hope you understand my problem

  • Get the object type

    hi,
    i have only ONE field that has a formatted search,
    but a want to get the object type of the document,
    for example.
    if i am in a A/R Invoice, i want to get some value (i.e. OINV)
    if i am in a A/P Invoice , i want to get some value (i.e. OPCH)

    Hi,
    You may get the object type by ObjType field.  However, it is not available by UI.  Therefore, you may only get it after the document has been saved.
    Thanks,
    Gordon

  • Why can't get the object "out" in this way?

    We use "PrintWriter out=response.getWriter()"to get a "out" object in Servlet and output text to webbrowser with it.But I think the PrintWriter is a class and Why can't I get the object "out" use this way:"PrintWriter out=new PrintWriter()"?I think the later is easier to understand.Anyone can help me?

    I check the Servlet API.The PrintWriter has a constructor with a abstract object Writer as it's parameter.I couldn't create the Writer object so I can't create the out object.Why it's constructor is protected by java?

Maybe you are looking for

  • I want to send a message to iPhone user but as sms not imessage

    My daughter uses iPhone as do I. She has her data turned off most of the time and uses wifi. If she is on a solid wifi network she gets iMessage. If she is not she doesn't. I used to be able to send to her phone number as a text message...old school

  • Hp photosmart 7150 only prints black and white with mac

    My hp photosmart 7150 only prints black and white with mac.  I have tried installing and uninstalling, installing drivers, but no change.

  • Adobe  PS CS2 (win7) quick mask mode is broke

    Hello My (Windows7) PS CS2 quick mask mode is broke. When in it, tools work backwards, delete is alt-backspace, eraser tool is paintbrush. Then, when I'm ready to exit quick mask to standard mode to delete selection, selection has disappeared, no sel

  • OCR with HP printer Photosmart 2570 all-in-one

    I prepare a newsletter with Pages once a quarter, and I find that it would help if I could use OCR to avoid having to type some of the contributions.   When I open the Device Manager of the HP printer it offers 'Make copies', 'Scan to OCR' and 'Scan

  • Installing nVidia GeForce drivers on Mac OS 9 Classic Support

    hi, everyone ! I have just installed classic support on my Quicksilver and i don't know how to install the drivers for my GeForce Ti4600 OEM video card. Can you please give me more information ? Cheers !