Dynamic creation of class and calling methods

I've got and interface called Transformation and then two implementations called TxA and TxB, where TxA and TxB have their own attribtues and setter and getters for these attributes.
The question is, I need to create instances of TxA and TxB and called the setter and getters where I at runtime I only know the attribute to set, how can I create and instance and call the right getters and setters methods?
Thanks in advance

Smart money says your design sucks and needs to be rethought entirely. Can we get specifics?
Drake

Similar Messages

  • Extending classes and overriding methods

    If I have a class which extends another, and overrides some methods, if I from a third class casts the extending class as the super class and calls one of the methods which gets overrided, is it the overrided method or the method of the superclass which get executed?
    Stig.

    Explicit cast can't enable the object to invoke super-class's method. Because dynamic binding is decided by the instance. The cast can just prevent you from using methods only defined in sub-class, but it does not let the object to use super-class's method, if the method's been overrided. Otherwise, the polymophism, which is one of the most beautiful feature of Object-Oriented thing, can't be achieved. As far as I know, the only way to use super-class's method is the super keyword in the sub-class, and seems no way for an object to do the same thing (I may wrong, since I haven't read the language spec).
    here's a small test:
    public class Test {
    public static void main(String[] args){
    A a = new B();
    a.method();
    ((A)a).method();
    class A{
    public void method(){
    System.out.println("A's method");
    class B extends A{
    public void method(){
    System.out.println("B's method");
    The output is:
    B's method
    B's method

  • ALV using OOPS class CL_GUI_ALV_GRID, call method SET_TABLE_FOR_FIRST_DISPL

    I NEVER USED OOPS CONCEPT.BUT I GOT A TASK ON ALV REPORT USING class CL_GUI_ALV_GRID, call method SET_TABLE_FOR_FIRST_DISPLAY for ALV . I HAD PASSED THE VALUES FROM INTERNAL TABLE AND GOT OUTPUT IN ALV.
    The problem is When i save an layout(default setting button ).
    iam unable to get the output for all fields.
    if u want i will send screenshots to ur mail
    THANKS IN ADVANCE.

    ok fine,
    In the output (alv grid) there is an icon for layout settings.
    if i want to save layout (as DEFAULT SETTING) i am missing some fields in output
    EX:
    mat no | batch  | proces order | time  |  date |
    when i save layout (as DEFAULT SETTING) i am missing some fields in output
    mat no | batch  |
    the rest of the field were not displayed.
    if u are not clear just ask me. i will send some more examples.

  • Is Two Classes that call methods from each other possible?

    I have a class lets call it
    gui and it has a method called addMessage that appends a string onto a text field
    i also have a method called JNIinterface that has a method called
    sendAlong Takes a string and sends it along which does alot of stuff
    K the gui also has a text field and when a button is pushed it needs to call sendAlong
    the JNIinterface randomly recieves messages and when it does it has to call AddMessage so they can be displayed
    any way to do this??

    Is Two Classes that call methods from each other possible?Do you mean like this?
       class A
         static void doB() { B.fromA(); }
         static void fromB() {}
       class B
         static void doA() { A.fromB(); }
         static void fromA() {}
    .I doubt there is anyway to do exactly that. You can use an interface however.
       Interface IB
         void fromA();
       class A
         IB b;
         A(IB instance) {b = instance;}
         void doB() { b.fromA(); }
         void fromB() {}
       class B implements IB
         static void doA() { A.fromB(); }
         void fromA() {}
    .Note that you might want to re-examine your design if you have circular references. There is probably something wrong with it.

  • "cannot resolve symbol" when compiling a class that calls methods

    I am currently taking a Intro to Java class. This problem has my instructor baffled. If I have two classes saved in separate files, for example:
    one class might contain the constructor with get and set statements,
    the other class contains the main() method and calls the constructor.
    The first file compiles clean. When I compile the second file, I get the "cannot resolve symbol error" referring to the first class.
    If I copy both files to floppy and take them to school. I can compile and run them with no problem.
    If I copy the constructor file to the second file and delete the "public" from the class declaration of the constructor, it will compile and run at home.
    At home, I am running Windows ME. At school, Windows 2000 Professional.
    The textbook that we are using came with a CD from which I downloaded the SDK and Runtime Environment. I have tried uninstalling and reinstalling. I have also tried downloading directly from the Sun website and still the error persists.
    I came across a new twist tonight. I copied class files from the CD to my hard drive. 4 separate files. 3 of which are called by the 4th.
    I can run these with no problem.
    Any ideas, why I would have compile errors????
    Thanks!!

    Oooops ... violated....
    Well first a constructor should have the same name as the class name so in our case what we have actually created is a static method statementOfPhilosophy() in class SetUpSite and not a constructor.
    Now why does second class report unresolved symbol ???
    Look at this line
    Class XYZ=new XYZ();
    sounds familiar, well this is what is missing from your second class, since there is no object how can it call a method ...
    why the precompiled classes run is cuz they contain the right code perhaps so my suggestion to you is,
    1) Review the meaning and implementation of Constructors
    2) Ask your instructor to do the same ( no pun intended ... )
    3) Check out this for understanding PATH & CLASSPATH http://www.geocities.com/gaurav007_2000/java/
    4) Look at the "import" statement, when we have code in different files and we need to incorporate some code in another it is always a good idea to use import statement, that solves quite a few errors.
    5) Finally forgive any goof up on this reply, I have looked at source code after 12 months of hibernation post dot com doom ... so m a bit rusty... shall get better soon though :)
    warm regards and good wishes,
    Gaurav
    CW :-> Mother of all computer languages.
    I HAM ( Radio-Active )
    * OS has no significance in this error
    ** uninstalling and reinstalling ? r u nuttttttts ??? don't ever do that again unless your compiler fails to start, as long as it is giving a valid error it is working man ... all we need to do is to interpret the error and try to fix the code not the machine or compiler.

  • Dynamic Creation of Buttons and Actions HELP

    Hi there,
    I have got a problem (or maybe even two) with the dynamic Creation of buttons. The code below creates the buttons.
    My main problem is, that the parameter created for the button's action isn't propagated to the assigned event handler. I get a null, though the name of the parameter in the event handler and the name of the parameter added to the action are the same.
    Could it also be that I'm always using the same action? I.e. does wdThis.wdGetAddElementAction() always return the same action instance? If yes, how can I create individual actions for each button?
    Any help is appreciated!
    Cheers,
    Heiko
    "    for(int i=rootContainer.getChildren().length; i<wdContext.nodeFeature().size();i++)
                   IPrivateVCT_Feature.IFeatureElement featureElement = wdContext.nodeFeature().getFeatureElementAt(i);
                   IWDTray featureTray = (IWDTray) view.createElement(IWDTray.class, featureElement.getName());
                   IWDCaption header = (IWDCaption) view.createElement(IWDCaption.class, featureElement.getName()+"_Header");
                   header.setText(featureElement.getName());
                   featureTray.setHeader(header);
                   featureTray.setExpanded(false);
                   rootContainer.addChild(featureTray);
                   IWDButton button = (IWDButton) view.createElement(IWDButton.class, featureElement.getName()+"_Button_AddElement");
                   IWDAction actionAddElement = wdThis.wdGetAddElementAction();
                   actionAddElement.getActionParameters().addParameter("featureIndex", new Integer(i).toString());
                   button.setOnAction(actionAddElement);
                   button.setText("Add Element");
                   featureTray.addChild(button);

    Hi Heiko,
    You have done everything correctly....except for 1 line
    in the code...
    Replace the following line in your code:
    actionAddElement.getActionParameters().addParameter("featureIndex", new Integer(i).toString());
    Replace the above line with this code:
    button.mappingOfOnAction().addParameter("featureIndex",i);
    Actually in your code, you are not associating the parameter with the button...
    Note that addParameter(...) comes with two signatures: addParameter(String param, String value) and addParameter(String param, int value). You can use any of them based on yuor need.
    Hope it helps,
    Thanks and Regards,
    Vishnu Prasad Hegde

  • Nested Classes and Static Methods

    I was perusing the Java Tutorials on Nested Classes and I came across this...
    [http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html|http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html]
    I was reading the documentation and I read a slightly confusing statement. I was hoping some further discussion could clarify the matter. The documentation on "Nested Classes" says (I highlighted the two statements, in bold, I am having trouble piecing together.)
    Static Nested Classes
    As with class methods and variables, a static nested class is associated with its outer class. And like static class methods, a static nested class cannot refer directly to instance variables or methods defined in its enclosing class ? it can use them only through an object reference.
    Note: A static nested class interacts with the instance members of its outer class (and other classes) just like any other top-level class. In effect, a static nested class is behaviorally a top-level class that has been nested in another top-level class for packaging convenience.
    So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?

    So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?No, it means that a static nested class cannot refer to instance variables of its enclosing class. Example:public class Foo {
        int i;
        static class Bar {
            int j = i; // WRONG! Bar class is static context
    }~

  • ParameterFieldController class and getDataDefController() method missing from com.crystaldecisions.reports.sdk.*

    I am trying to use the desktop samples for the JRC. The parameter setting sample will not compile because the ParameterFieldController class and the ReportClientDocument's getDataDefController() method are missing from com.crystaldecisions.reports.sdk.* .
    I have release 2 of Crystal Reports XI Developer and should have the most up to date jrcerom.jar file for that product. What is it going to take to get this working? This is a critical aspect of using Crystal Reports for our java application reporting needs.
    Prompt attention to this is appreciated.

    <p> </p><p>That class is not in that package, but another package imported in the sample, and in a different jar file. </p><p>The readme file should reference a deployment guide listing the required jar files, which I&#39;ve copied here:</p><p> <a href="http://support.businessobjects.com/communityCS/TechnicalPapers/cr_xi_r2_jrc_deployment.pdf" target="_blank">http://support.businessobjects.com/communityCS/TechnicalPapers/cr_xi_r2_jrc_deployment.pdf</a></p><p>Sincerely,</p><p>Ted Ueda </p>

  • How can i interact with the ALV if i am using the lvc_ and call method?

    i want to hide the last entry of a line when i click on the checbox of my ALV

    u want to hide or delete?
    instead of using check box, u can use a button to display there.
    it can be achived like below.
    data: ls_lvclayout type lvc_s_layo.
    LS_LVCLAYOUT-SEL_MODE = 'D'.
    now in set_table for_first_diaplay
    CALL METHOD GO_GRID->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
          <b>  IS_LAYOUT            = LS_LVCLAYOUT</b>
    do like above.
    then u click on the row, and the row will be selected.
    now using the method GET_SELECTED_ROWS, u can get the data of the selected row and u can now manipulate what ever u needed.
    data:
    SEL_ROW TYPE LVC_S_ROID,
    SEL_T_ROW TYPE LVC_T_ROID.
    CALL METHOD GO_GRID->GET_SELECTED_ROWS
        IMPORTING
          ET_ROW_NO = SEL_T_ROW.
    LOOP AT SEL_T_ROW INTO SEL_ROW.
              read table <itab> index SEL_ROW-ROW_ID.
              check sy-subrc = 0.
    < now write the logic  like making the field blank and modify the itab>.       
            ENDLOOP.

  • Class and it methods

    Hello Experts my name is latha I am new to abap objects can any one help me in detail how to implement a class and its methods

    Welcome to SDN Forum latha.
    Please read [Rules for Asking & Answering in the Forums|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement].
    The first thing to do is try to find through the search tool for "ABAP Objects", you'll find various interesting materials.
    Also take a look at [ABAP Objects Wiki|https://wiki.sdn.sap.com/wiki/x/o5k] section where you can see information, links and several examples from [beginner to advanced|https://wiki.sdn.sap.com/wiki/x/Aq].
    Don't forget to close this thread once your question be answered
    Greetings,
    Marcelo Ramos

  • Vectors - Saving Reference to a Class and calling it's Methods ?

    Hi,
    How can I do this ? trying to execute a method from a class reference stored in a Vector.... something like this...
    Vector v = new Vector();
    v.addElement( new MyJPanel1());
    v.addElement( new MyJPanel2());
    for (int i=0; i<v.size();i++) {
    // How can i execute the methods contained within say MyPanel1()
    // from the vector c ?
    // ie) MyPanel1().closwWindow();
    }Thanks
    Rob

    You have to get the element and cast it to the appropriate type. Then do what you want.
    JPanel panel = (JPanel) v.elementAt(i);And then there is generics but from you have posted you don't seem to have those...

  • Help with dynamic creation of class object names

    Hi all
    Wonder if you can help. I have a class player.java. I want to be able to create objects from this class depending on a int counter variable.
    So, for example,
    int counter = 1;
    Player p+counter = new Player ("Sam","Smith");the counter increments by 1 each time the method this sits within is called. The syntax for Player name creation is incorrect. What I am looking to create is Player p1, Player p2, Player p3.... depending on value of i.
    Basically I think this is just a question of syntax, but I can't quite get there.
    Please help if you can.
    Thanks.
    Sam

    here is the method:
    //add member
      public void addMember() {
        String output,firstName,secondName,address1,address2,phoneNumberAsString;
        long phoneNumber;
        boolean isMember=true;
        this.memberCounter++;
        Player temp;
        //create HashMap
        HashMap memberList = new HashMap();
        output="Squash Court Booking System \n";
        output=output+"Enter Details \n\n";
        firstName=askUser("Enter First Name: ");
        secondName=askUser("Enter Second Name: ");
        address1=askUser("Enter Street Name and Number: ");
        address2=askUser("Enter Town: ");
        phoneNumberAsString=askUser("Enter Phone Number: ");
        phoneNumber=Long.parseLong(phoneNumberAsString);
        Player p = new Player(firstName,secondName,address1,address2,phoneNumber,isMember);
        //place member into HashMap
        memberList.put(new Integer(memberCounter),p);
        //JOptionPane.showMessageDialog(null,"Membercounter="+memberCounter,"Test",JOptionPane.INFORMATION_MESSAGE);
        //create iterator
        Iterator members = memberList.values().iterator();
        //create output
        output="";
        while(members.hasNext()) {
          temp = (Player)members.next();
          output=output + temp.getFirstName() + " ";
          output=output + temp.getSecondName() + "\n";
          output=output + temp.getAddress1() + "\n";
          output=output + temp.getAddress2() + "\n";
          output= output + temp.getPhoneNumber() + "\n";
          output= output + temp.getIsMember();
        //display message
        JOptionPane.showMessageDialog(null,output,"Member Listings",JOptionPane.INFORMATION_MESSAGE);
      }//end addMemberOn running this, no matter how many details are input, the HashMap only gives me the first one back....
    Any ideas?
    Sam

  • How to get class and use method on it

    Hi,
    class State {
            String name
            Enum expectedValue
            public State(String name,Enum expectedValue){
                this.name = name;
                this.expectedValue = expectedValue;
    In the same class I need to have a method that takes a String and it should return matching
    Enum value. Since  class already have the expectedValue my idea is to get the Enum class ( using that if possible) and
    the call get() on it see my example below;
    Example:
    expectedValue is HwState.UPGRADED;
        public HwState convertActualToStateType( String actual){
            return  HwState.get(Integer.valueOf(actual));
    How can I get the Enum class (HwState) ? And then use it e.g. HwState.get() ?
    //mike

    Oracle is not allowing to Pesonlize the Buttons.

  • Abstract classes and static methods

    I have an abstract report class AbstractReportClass which I am extending in multiple report classes (one for each report, say ReportA, ReportB, ...). Each report class has its own static column definitions, title, etc., which I have to access through a static method getDataMeta() in a web application. Each report has the same exact code in getDataMeta, and no report may exist without these fields. My intuition tells me that AbstractReportClass should contain the code for getDataMeta, but I know that you can't mix abstract and static keywords.
    Am I missing a simple solution to unify the getDataMeta code in the abstract base class? or do I really need to have a static function getDataMeta with the same code in each of the base classes?
    My apologies if this has been discussed many times before.
    Thanks,
    -Andrew

    I'm not trying to be "right"; rather I just asked a question about whether I can do something that seems intuitive. Perhaps you might write code in a different way than I would or perhaps I wasn't clear about every little detail about my code? Do you regularly belittle people who ask questions here?
    I have a loadFromDB() member function in AbstractReport for which all sub classes have an overloaded version. All reports I'm displaying have 4 common fields (a database id and a name and a monetary value, for example), but then each other report has additional fields it loads from the database. Inside ReportX classes' loadFromDB(), I call the superclass loadFromDB() function and augment values to get a completely loaded object. In fact, the loadedData member object resides in AbstractReport.
    I can't use a report unless it has these common features. Every report is an AbstractReport. There is common functionality built on top of common objects. Isn't this the point of inheritance? I'm essentially saying that abstract class Shape has a getArea function and then I'm defining multiple types of Shapes (e.g. Rectangle and Circle) to work with...

  • Legacy C program - new Java GUI and calling methods

    Hello,
    I am fairly new to these forums. I've been working for a company that has an exsisting program that is a propriotery video-client to a video-server. It is written in C and has DirectX components for the standalone C application and ActiveX components for the Internet Explorer version.
    I looked over the source code and found a main() function. Now I am trying to execute that main() fuction through java and jni. I have managed to get a simple HelloWorld program to work but am now stuck.
    I would like to do the following.
    1. Convert the exsisting code to a C library. I have to use Visual C++ 6.0 to create this project. (There is already an exsisting dsw project file for the video client).
    Question: How do I get rid of the main() function and compile correctly in Visual C++?
    2. How do I call the library function that I created in the above from a java main() method? What should I use to edit and compile java/c code?
    Thank you,
    Viral

    Hi,
    If you need to have fast results you can try to use the ActiveX with COM bridge like Jawin or JACOb (both at sourceforge) or use Eclipse's SWT that has an activeX support too.
    An other alternative is to create a full JNI wrapper to your project.
    A1 : Replace the main by DllMain (create a new DLL with msvc++ wizard to see how to create a basic DLL).
    A2 : Call all functions exported by DLLs with a free tool like JNative.
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • How do i back up bootcamp and osx

    I want to back up my complete disk and restore it when required. I have tried acronis which does not support any of the apple usb slots so i cant restore. copycat does not let me select the boot camp to back that up. I dont want to have to do seperat

  • Time to transfer video- iPhone 4 to iPhoto

    Does anyone know how long it would take to transfer a 30min HD video from an iPhone 4 to iPhoto? I would like to use this phone for work to record interviews, and I need to give the client a copy at the end of the meeting. But if it takes ages to tra

  • Is data stored anywhere in the system without SAVEing the file manually

    Hello All, I need to know whether the data is saved anywhere even before I save the document manually ? If so, where can I find that temporarily saved data? Ex: While writing any WORD document, you can see the draft version of any file saved after 2

  • Application CD Failed

    When I use the application CD, that was given inside the box. It fails to install the programs? Any help on this, or do I have to contact apple.

  • Last active time of a session

    Oracle 9i. OEM can show (session pero session) the timestamp, each session issued its last activity. How can I know that (last timestamp session activity) using simple SQL statement?