A doubt regarding the usage of Reflection

There are several classes A, B, C, D,.... in a package.
A, B, C & D are generic names given to the java files inside the package.
They actually indicate files selected by the user during run-time.
A a = new A();
B b = a.getB();
C c = b.getC();
D d = c.getD();
int count = d.getCount();
a.getB() returns an instance of B.
similarly with getC() & getD() too.
The classes indicated by A, B, C & D are selected by the user.
So, I need to use reflection to implement the above 5 statements.
How do I go about doing this?
Thanks

Basically to create an instance of a dynamic class:
Class cl = Class.forName(myClassName);  // get class
for name
Object o = cl.newInstance();  // create an instance
the above code works fine, if Iam dealing with a single class.
But my problem is Class A returns an object of Class B
which I need to use to get an Object of class C and so on until I get the required data to be parsed form the XML document.
When I invoke a method in Class A, it returns an object(of class B, which I need to use to invoke a method in class B) and so on to get the final value.
I have a large XML document as shown below, which I need to parse.
!-- an xml document -->
<Element A>
   <Element B>
      <Element P>
         Some data for Element P
      <Element Q>
         Some data for Element Q
      <Element R>
   </Element B>
   <Element C>
   <Element D>
   <Element E>
</Element A>I have a class that represents the whole document with the main elements in it. (Class A representing the whole document along with objects representing the main Elements B, C, D & E)
Each element in turn has its own class which are necessary to access the sub-elements of it. (Class B representing Element B and also including Element P & Q)
If I want to parse a specific part of the document(if i need to get the data in Element P), I need to get the Element B from a Class A and use that Object representing Element B to get Element P and then use it to get the required data.
Each class returns a part of the document and as you use the classes(and the returned part of the document), we narrow down to the required region to get the data.

Similar Messages

  • Help needed regards the usage of STL.....with CC

    Hi All,
    I am relatively new to SOLARIS. I am trying to figure out the options for using the STL components in the project.
    The project needs to be compiled with both CC ang g++, should support both SOLARIS and LINUX systems. That's why i am going for STL components rather than using the RW-Components of Tools.h++.
    I have the following doubts regards the usage of STL.
    CC provides the -library option to link the libraries we require.
    The following is what i understood from the documentation:
    No ( -library ) option provides - default libraries included -lCstd -lCrun -lm -lw -lcx -lc+
    -library=iostream+ - libraries included -liostream -lCstd -lCrun -lm -lw -lcx -lc+
    -library=iostream,no%Crun+ - libraries included -liostream -lCstd -lm -lw -lcx -lc+
    -library=stlport4+ - libraries included -lstlport4 -lCrun -lm -lw -lcx -lc+
    -library=iostream,no%Cstd+ - Invalid combination, some header files missing [[ *iostream, sstream* ]]
    When we try to make a new project, which of the following is recommended?
    #! - Use libCstd suppplied along with solaris package.
    When solaris makes a new release, is it always guaranteed that project is compatible with new libCstd ? (Is there a backward compatibility?)
    The STL components which can be used in the project are limited. i.e we can use only those that come along with libCstd.....right?
    Might not be compatible with other c++ compilers. ( Not compatible with g++ ) Right?
    #2 - Use libCStd along with libiostream
    Can we use STL (supported by libCstd ) + Classic-iostreams and still have the backward-compatibility?
    Compatible with other C++ compilers....provided care has been taken of the CC STL Specializations. ( Compatible with g++ ) Right?
    #3 - Use stlport4. Is it stable and backward-compatible ?
    We can exploit usage of STL to the maximum.
    Is it guranteed that the project (using -library=stlport4 ) will be backward compatible ?
    Can the SunStudio (ORACLE) organization gurantee that stlport will take care of the changes in the CPP standards ?
    i.e Is it guranteed that STLPORT and SUN-STUDIO packages will always be in sync?
    Among the above three which is preferred method to go ensuring stability and backward-compatibility.
    Thanks in advance.
    Cheers,
    Sreekar
    Edited by: 855323 on 20-Oct-2011 04:04
    Edited by: 855323 on 20-Oct-2011 04:04
    Edited by: 855323 on 20-Oct-2011 04:06

    In general, you don't need any options to use the C++ Standard Library (which includes what is sometimes loosely called the "STL"). Consider this toy program:
    // file vec.cc
    #include <vector>
    #include <iostream>
    int main()
        std::vector<int> vi(10);
        vi[1] = 1;
        std::cout << "vi[1]=" << vi[1] << '\n';
    }You can compile and run the program as either
    CC  vec.cc && a.out
    g++ vec.cc && a.outWith CC, by default you get the original libCstd. You use the -library option to select STLport or (on or selected versions of Solaris) Apache stdcxx instead. With g++, you just get the g++ library libstdc++, which should be suitable for all purposes.
    For a discussion of which library to select with CC, see this thread:
    Differnce between LibCstd and LibStlport
    The optional libiostream is provided to provide support for programs written for the very old version of iostreams that was provided with the original AT&T Cfront compiler in the 1980's and early 1990's. There is usually no reason to use this obsolete library with code written after 1998.
    The Solaris libCstd.so.1 (and libCrun.so.1) is always compatible with various releases of Studio, with one caveat: Each Studio release specifies the minimum patch level of Solaris libraries that is required to run programs created by the compiler. Any newer version of the library is guaranteed to be compatible. Thus, it is always safe to update the library, and an update might be required when using binaries created by a newer compiler.
    A version of the STLport library ships with the compiler. C++ binaries created by an older compiler that link to libstlport.so.1 should still work when linked into a program created by a newer compiler. Use of the static libstlport.a is generally not safe when mixing binary code from different compiler releases.
    Binaries created by Studio CC in default mode are not compatible with binaries created by g++. Even if you can get a program to link, which is doubtful, the program is not likely to run correctly.
    Studio CC does provide a g++ compatibility mode as follows:
    On supported versions of Linux with Studio 12.2 (C++ 5.11).
    On Solaris/x86 and supported versions of Linux with Studio 12.3 (C++ 5.12).
    In this mode, CC uses the g++ headers and the g++ runtime libraries.
    Refer to the -compat=g option in the C++ Users Guide for details.
    We plan to support the new C++ Standard, C++11, in a future compiler release. Because the ABI (binary interface) used by the current compilers is not adequate to support all the new features in C++11, we expect binaries built in C++11 mode to be incompatible with binaries created by earlier compilers. None of the existing C++ support libraries will be used in C++11 mode. A new library that provides full C++11 support will be used instead. We expect the new compiler to continue to provide the current C++03 mode as an option, being source and binary compatible with our earlier compilers.
    Edited by: Steve_Clamage on Oct 20, 2011 10:00 AM
    Edited by: Steve_Clamage on Oct 20, 2011 1:29 PM

  • Have some doubt regarding the  weblog (Lookup's in XI made simpler)

    Hi All,
    I have created the same scenario as mentioned in Siva's weblog (Lookup's in XI made simpler).
    I having some doubts regarding the scenario, it will be great if you help me to resolve the same.
    I am having a file-file scenario where I need to do lookup in database(MS-Access)  through mapping.
    The standard file-file scenario is in place and in addition I have created a receiver jdbc channel . I  have also created the receiver agreement for the same in the cofiguration.
    While creating the receiver agreement you have to specify the interface name which includes the message type…I have specified the normal format which we specify while configuring the jdbc receiver adapter.
    In the message mapping I have created a advance user defined function as mentioned in your weblog which calls my receiver jdbc channel.
    I have also specified the select query to be executed in the mapping program.
    While testing I am getting the following error
    Cannot produce target element /ns0:Role_MT/URole. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd
    <b>Can you please suggest me what all I need to do in addition to the file-file scenario for this lookup scenario to work.</b>
    Thanks and Regards
    Rahul

    Hi,
    Following is my user defined function
    //write your code here
    String Query = "";
    Channel channel = null;
    DataBaseAccessor accessor = null;
    DataBaseResult resultSet = null;
    Query = "Select URole from  Lookup where UName = '  " + UName[0] + "  ' and UPassword = '  " + Pwd[0] +" '  ";
    try{
    channel = LookupService.getChannel("DB_service","JDBC_channel_receiver");
    accessor = LookupService.getDataBaseAccessor(channel);
    resultSet  = accessor.execute(Query);
    for(Iterator rows = resultSet.getRows();rows.hasNext();){
    Map rowMap = (Map)rows.next();
    result.addValue((String)rowMap.get("URole"));
    catch(Exception ex){
    result.addValue(ex.getMessage());
    finally{
    try{
    if (accessor!= null) accessor.close();
    catch(Exception ex){
    result.addValue(ex.getMessage());
    Thanks and Regards
    Rahul

  • Regarding the usage of HR_INFOTYPE_OPERATIONS function module in ECM badi i

    Hi All,
    We have requirement where we need to update the infotype 0015 while implementing the badi 'HRECM00_ACTIVATION'.
    To achieve this functionality we are calling the HR_INFOTYPE_OPERATION function module to update the infotype 15. But we are getting the runtime error.
    Can some one suggest how to solve this issue.
    Thanks & Regards,
    Sreelatha Gullapalli.

    thanx for ur reply...
    But i want to use Transmission Medium 5 only as i have the requirement to Send the data as an EMAIL or FAX depending on the Communication Method specified in the Partner Number.
    Actually SAP Help also explains the usage of this medium using the same requirement as mine... but then it never anywhere specified on how the Print Program will be...
    I also checked the standard output type CPAC used in Application V7 to which transmission medium 5 is assigned. And the print program assigned to this output type has no coding on sending the email using the FM. So i am very very confused.... I have seen few postings in this forum on this topic.. but not clear enuf to clarify my confusion...
    Kind Regards,
    Tanuja

  • Doubts regarding the CTTYP field after a PU12 run

    Hi Everyone,
    I had some doubts regarding PU12. When I maintain the IT16 data for an employee belonging to Employee Group/Subgroup E/52, I want to keep the contract type blank. However, when I do this, CTTYP is not sent through in the IDoc after PU12 processing. I would like to know if this is standard behaviour. (If it is maintained as say unlimited contract, the field is sent through with the value 01) If I would like to send CTTYP through as 00, can I do it? Would I have to maintain a conversion? As of now, this field is configured as a key field in my system.
    Regards,
    Alpana.

    I presume that you cave a template for your documents with unsigned signature fields. Add a text filed (or other field type that you wish to use) to this template. Then you will be able to fill in this field after signing.

  • Basic doubts Regarding the RFC to File scenario.

    Hi All,
    I'm doing a RFC to File scenario, so before starting the development i went through many blogs and sites to know more the about scenario. I'm confused in the step where we have to create a RFC (type TCP/IP) in sm59.
    I have the following doubts :
    1)whether  to create the RFC in sender (which will be ECC system) or XI.
    i.e., RFC in sender (ECC) pointing to xi system in sm59 of Sender(ECC)
    or
    in XI pointing to sender (ECC) system.
    2) the program id maintained in RFC.
    the program id is any name or the FM which is being imported in XI system.
    Thanks in Advance,
    Kind Regards,
    Lalitkumar.

    Hi Lalitkumar,
    1)whether to create the RFC in sender (which will be ECC system) or XI.
    i.e., RFC in sender (ECC) pointing to xi system in sm59 of Sender(ECC)
    or
    in XI pointing to sender (ECC) system.
      It should be in sender ECC.
    2) the program id maintained in RFC.
    the program id is any name or the FM which is being imported in XI system.
    It can be any name but should be same in RFC destination and RFC adapter.
      As stefen mentioned use ABAP proxy inspite of RFC as its better performance wise.
    Regds,
    Pinangshuk.

  • Comprehensible question regarding the usage of a ccBPM in SAP PI 7.31

    Hello experts,
    I have got basic question about the useage of ccBPM in PI 7.31 double Stack. I haven't  created any ccBPM before so the whole set up process is new for me. We are currently using several ccBPM already which where created by our colleagues.
    I just have a question about the basic of work of a ccBPM and if the designed process can be realised at all.
    The current process should be implemented, starting from the erp system with a trigger report (left side). All the offered function are provided by the called system (right side)
    So can this whole process can be realised using ccBPM, so that after the trigger report is called the rest of the process is handled within the pi? The process checkStatus needs to be called within a loop and at the end the generated File should be stored on the file system.
    Thanks in advance for clearing my thoughts on this problem guys!
    regards
    Christian

    Hello Christian,
    is this a 1-1 correlation? So you have just one sender system and one target system? It might be better then to implement the flow in your sender system and only call single interfaces on PI. While it is technically possible to do everything in PI there is no real added value to do so. BPM is most benefitial when you need to aggregate information from different sources and when the process contains decisions that lead to alternative process steps.
    Regards,
    Jörg

  • Doubts regarding the SDN BPM scenerio!

    Hi Experts,
        I was tryin on the BPM scenerio made my Murthy.
    /people/krishna.moorthyp/blog/2005/06/09/walkthrough-with-bpm
    I have completeted all the steps.
    The communication channels are up and running well. But I simply cant get to the last step.
    In the last step:
    "To monitor Integration process log, go to transaction SXMB_MONI_BPE ->Process Selection->Select corresponding integration process (in Service Field) ->Execute->Select work item."
    I simply cant get to see ANY FIELDS in Process Selection. It is all blank . And when I am putting no selection criteria, and simply executing it, then also it is giving NO VALUES.
    Experts, can u suggest, what step, am I missing, any settings, any step, that I hav skipped.
    PS.
    I hav checked each step thoroughly.
    I hav avtivated all items.
    Regards,
    Arnab.
    I am also getting an error in SXMB_MONI:
    <SAP:Stack>No receiver agreement found for sender -BS_FILE_BPM to receiver -IP_File_to_File,urn:bpm_am.MI_FILE_to_BPM_ABS</SAP:Stack> .
    Pls comment Experts:
    Regards,
    Arnab
    Edited by: Arnab Mondal on Jan 6, 2009 7:14 AM

    >
    > "To monitor Integration process log, go to transaction SXMB_MONI_BPE ->Process Selection->Select corresponding integration process (in Service Field) ->Execute->Select work item."
    >  I simply cant get to see ANY FIELDS in Process Selection. It is all blank . And when I am putting no selection criteria, and simply executing it, then also it is giving NO VALUES.
    You will see that only if the BPM was executed. Seems your BPM is not executed yet. In SXMB_MONI, for the entry of your process, do you see a column with PE ? if so try clicking and drilling down
    > I am also getting an error in SXMB_MONI:
    > <SAP:Stack>No receiver agreement found for sender -BS_FILE_BPM to receiver -IP_File_to_File,urn:bpm_am.MI_FILE_to_BPM_ABS</SAP:Stack> .
    have you created the receiver agreements?
    there will be two receiver agreements;
    1. from sender system to BPM.
    2. BPM to receiver system.

  • Doubts regarding the filters

    Hi All,
          I am creating a qurey in the BEx Analyzer in BI 7.0 which consists of some dropdown boxes for materials and sales organisation.
          My requirement is this:
                 If I select the particular material (Ex: M100), only the sales organisations which are availble for the material should have to be displayed.
         Pls give me ur valuable suggestions regarding this problem.
    With Regards,
    Yokesh.

    Dear Yokesh,
    Restirct the Material with the particular Material number (Ex: M100).
    or
    Restrict the Material with a Variable.
    Create a Char variable on Material : Give value  (Ex: M100), only the sales organisations which are availble for the material would be displayed.
    Regards,
    Ram.

  • Regarding the Usage of oracle external tables.

    HI All,
    I am using POI API for generating Oracle external tables. If that excel sheet is having empty sheets then its throwing null pointer exception. Can anybody help me out in resolving this problem.
    Thanks and Regards,
    Venky

    Do you use the technique described by Casimir Saternos in this OTN article?
    Generate External Tables from an Excel Spreadsheet Using Apache Jakarta POI
    http://www.oracle.com/technology/pub/articles/saternos_tables.html

  • Doubts regarding the 'Append Row' button

    Hi Experts,
    I have created one ABAP screen. In this ABAP screen I can see 'Append Row' button. I want to know what code is executed after this button is clicked.
    Answer of this question is very important. As it will help me in resolving one important query.
    The query is mentioned in my other two threads that I have created today.
    Thanks in advance
    Smith

    Hi Vijay,
    I have used class CL_GUI_ALV_GRID for creation of the screen. I can see that function = '&LOCAL&APPEND' of method handle_toolbar_set is responsible for creation of this push button.
    Regards,
    Smith

  • I have doubt regarding the byte to integer conversion.

    In java card epurse application the output we see is in bytes.to convert this byte to integer which is understandable by the end-user what should be done?

    809295 wrote:
    In java card epurse application the output we see is in bytes .
    to convert this byte to integer which is understandable by the end-user what should be done?What do you mean by we ?
    How many bytes ?
    On a java card platform support for integer is optional, you may only have short.
    I assume by understandable by the end-user you mean display as a sequence of decimal digits ?
    So two bytes 0x04 0xd2 (combined to a short 0x04d2 which is 1234 decimal)
    should be presented to the user as 0x31 0x32 0x33 0x34 (ascii values for '1' '2' '3' '4').

  • Question regarding the usage of DSP48E1 in Zynq7030

    Hi everyone.
    I'm trying to implement 3D audio function using emmbeded DSP slices in the Zynq.
    I got DSP libray which is compiled with XDK and want to import the library to the DSP48E1 slice in the Zynq.
    The DSP library I got is consisted of HRTF (Head Related Transfer Functions). The HRTF is consisted of some FFT, phase compare, phase add, phase substraction and amplitude amplifying or attenuating.
    So, waht I wonder is can we import the library to the DSP slice and use?
    Please let me know.
    Thanks,
    S. J. Lee

    Hello,
    Are you talking about a software library? You cannot just take a software library and automatically map it to DSP slices in the FPGA fabric in the same way that you would re-compile it for a different processor architecture, if that's what you mean. Don't think of the DSP slice as a DSP *processor*. That's not what it is.
    The closest thing to this would be to use high level tools such as HLS or SDSoC to help ease the work of pushing certain portions of the algorithm to hardware. However, you will still be responsible to do some level of partitioning and hardware design for implementing the algorithm.

  • Regarding the usage of Twitter references in Windows Phone 8 apps

     private void LoadFromTwitter(string CelebrityLink)
                var service = new TwitterService("LYTy3T8P556GxqRymimhwA", "5TSKipEjESOAcdBsViWm2E1RVxFEN1Ooh0nRwIj7RsY");
                if (p.getAccessToken() != null)
                    string[] Tokens = new string[2];
                    Tokens = p.ReturnTokens(p.getAccessToken());
                    if (Tokens[0] != null)
                        service.AuthenticateWith(Tokens[0], Tokens[1]);
                        service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions() { ScreenName = CelebrityLink }, (ts, rep) =>
                            if (rep.StatusCode == HttpStatusCode.OK)
      Deployment.Current.Dispatcher.BeginInvoke(() =>
                                    foreach (TwitterStatus si in ts.Take(2))
                                        TwitterList.Add(si);
    In the above code snippet iam getting error at the Bolded part
    Errors are:
    Error 116
    Cannot convert type 'TweetSharp.TwitterStatus [TweetSharp.WindowsPhone.dll]' to 'TweetSharp.TwitterStatus [TweetSharp.WindowsPhone.Mango.dll]'
    Error 115
    Cannot convert lambda expression to type 'System.Delegate' because it is not a delegate type
    Please help me in solving this errors . I have used 
    TweetSharp.WindowsPhone.dll
    TweetSharp.WindowsPhone.Mango.dll as references
    Mohan Rajesh Komatlapalli

    You should only reference one of these dlls. 
    Jeff Sanders (MSFT)
    @jsandersrocks - Windows Store Developer Solutions
    @WSDevSol
    Getting Started With Windows Azure Mobile Services development?
    Click here
    Getting Started With Windows Phone or Store app development?
    Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

  • Querstion regarding the "this" keyword

    hi everyone,
    i've doubt regarding the usage of this keyword in the inner classes & static methods. like the following:
    class A {
        int val1 = 0;
        int val2 = 0;
        A() {
            B b = new B();
            C c = new C();
            for(int i=1; i < 11; i++) {
                b.add(i);
                c.add(i);
                System.out.println("Val 1 : " + val1);
                System.out.println("Val 2 : " + val2);
        public static void main(String args[]) {
            new A();
        class B {
            public void add(int val) {
                // the this keyword is used as static variable
                A.this.val1 += val;
        static class C {
            public void add(int val) {
                // the "this" keyword cannot be used
                //A.this.val2 += val;
    }the code doesn't matter what its meant for, i wrote code to explain u my doubt with example.
    so any explanation from ur side, i'm not clear with the this keyword usage.
    thanx

    I am in agreement with trinta, although I think your doubt arises from a lack of understanding of inner classes, not from the use of 'this'. You seem very adept in the use of 'this'.
    Realise that there are 4 categories of nested classes:
    1> Top-level or static nested classes
    These are declared by the static keyword (as in class C in your example). They can be instantiated with or without an instance of the containing class. i.e. using the class names from your example.
    C c = new A.C();
    or
    C c = new instanceOfA.C();
    Since a static nested class does not require an instance of a class, there is no use of the 'this' keyword. There may not be any instance created, if if there was, which one since you don't have to specify which when creating it (see first example code above).
    2> Member Inner Classes
    As in class B in your example. The name should indicate that we think about these classes as members, or part of, the containing instance. Use these classes when it makes no sense for the inner class to exist outside the containing class. Usually these inner classes are designed to be helper classes and often hidden from view. When they aren't, the only way to create new instances of them is through an actual instance of the containing class. i.e. using the class names from your example,
    B b = new instanceOfA.B();
    Note that this code
    B b = new A.B();
    will yield an error. There must be an associated containing class.
    For this reason, the use of 'this' is only appropriate for member classes.
    3> Local Inner Classes
    4> Anonymous Inner Classes
    Not really relevant to this question.

Maybe you are looking for

  • Nokia 5235 firmware upgrade

    I am from India and have a 5235 the current installed version is 21.6.005. I have an Airtel connection if that helps. Nokia india site shows that there is a software upgrade available from march onwards (You will not find 5235 but if you search for 5

  • Importing DV in iMovie09

    I have recently upgraded to Snow Leopard and iLife09. I am now trying to import videos from my JVC DV camera. iMovie recognizes the camera and reproduces the videos without problems. But when I try to import them, well it rewinds the tape, it signals

  • Disc won't eject.

    Hello, I put a cd in, and uploaded it without a problem. Now the disc wont ejected, I tried using the terminal, starting up and holding down the trackpad mouse button, putting it to sleep and holding the eject media button, everything listed here. It

  • Cant download pre-ordered album??

    A few weeks ago I pre-ordered Sophie Ellis-Bexters new album Wanderlust. On 20 January, I received an email saying that my order was now ready, and that I should click on the link below to download. However, the link only takes me to ITunes, it doesn

  • Removing dashes '-' in update rules

    Hi all, I am looking for the simplest way to remove dashes in update rule. Data comes 123-45-678 Format we need 12345678 I'd appreciate any recommendations. PS: We'd rather not to add '-' to invalid characters list Mike