Reflection: attributes from the base class

Is there a way to get the attributes from the base class of a derived class via reflection? I only found methods to get the attributes from the derived class.
Example:
class A
int a = 4;
class B extends A
int b = 5;
Object unknown = new B();
Code/Idea to get all attributes from baseclass A using unknown (here: a=4)?

Thank you all for your hints. The mistake I make, was to use the baseclass, and not the derived class for getting the attributes. By using an extra parameter of type class I got all attributes in their context.
   private StringBuffer getDump(Object obj, Class cl)
         dmp.append(cl.getName() + " {\n");
         Field[] attribute = cl.getDeclaredFields();             <--- only the fields of the current class
         for (int j = 0; j < attribute.length; j++)
            attribute[j].setAccessible(true);
            try
               if (attribute[j].getType().isPrimitive() || attribute[j].getType() == String.class)
                  dmp.append(attribute[j].getName() + "=" + attribute[j].get(obj) + "\n");
               else
                  if (((attribute[j].getModifiers() & Modifier.STATIC) != Modifier.STATIC) &&
                      (attribute[j].getType().getName().startsWith("java.lang") == false) &&
                      ((attribute[j].getModifiers() & Modifier.FINAL) != Modifier.FINAL))
                     dmp.append(getDump(attribute[j].get(obj), attribute[j].get(obj).getClass())); <- recursive call
            catch (IllegalAccessException ex)
               ex.printStackTrace();
         dmp.append("}");
      return dmp;
   }

Similar Messages

  • Inherit protected attribute from a Super class

    Hi All,
    I am inheriting a standard class which has many instance protected attributes. how do i access the super classes protected attributes from the sub class.  i.e i need the value present in the super class attribute to be used in a sub class method.
    will i be able to get the value of an instance attribute??
    Thanks in advance,
    Arun.

    Hi marc,
    I was also wondering as to how we can make use of the public attributes in the sub classes.as in, what the syntax we need to follow.
    It'd be great if you could give a simple example with one protecetd attribute accessed in the subclass.
    I've written a sample prog.
    REPORT  YA_TEST_OO.
          CLASS s_abc DEFINITION
    CLASS s_abc DEFINITION.
      PRIVATE SECTION.
        DATA: d_abc TYPE i.
    ENDCLASS.                    "s_abc DEFINITION
          CLASS sb_abc DEFINITION
    CLASS sb_abc DEFINITION INHERITING FROM s_abc.
      public SECTION.
    DATA: sb_d_abc TYPE c." VALUE d_abc.
        METHODS: m_abc.
    ENDCLASS.                    "sb_abc DEFINITION
          CLASS sb_abc IMPLEMENTATION
    CLASS sb_abc IMPLEMENTATION.
      METHOD m_abc.
       sb_d_abc = d_abc + 1.
      ENDMETHOD.                    "m_abc
    ENDCLASS.                    "sb_abc IMPLEMENTATION
    It doesn't work though.
    Thanx,
    Zid.

  • Warning :: Derived class hides the base class virtual function

    We are porting from CC5.3 to CC5.8 compiler with Sun Studio one compiler. After plenty of hurdles we are in the final stage of removing the warning messages... Amoung the plenty the following one is very common and in different files. Why am I getting this error in 5.8 and not in 5.3 compiler....
    Warning: derived_Object::markRead Hides the virtual function base_Object::markRead(ut_SourceCodeLocation&) const in a virtual base
    From this it is easily understandable that the base class mark read was hidden by derived class markRead... when we drive and override the derived class function.... It is all over the place....
    Thank you,
    Saravanan Kannan
    //public: using xx_Object :: markRead;
    virtual void markRead() const;

    The Sun C++ FAQ discusses the warning message:
    http://developers.sun.com/prodtech/cc/documentation/ss11/mr/READMEs/c++_faq.html#Coding1
    Notice that warnings are not necessarily errors. But I applaud your desire to fix the code so that it generates no warnings. I wish more of our customers could be persuaded to do the same. :-)
    C++ 5.3 issues this warning, by the way. Example:
    struct B { virtual int foo(int); };
    struct D : B { virtual int foo(double); }; // line 2
    D d;
    line 2: Warning: D::foo hides the virtual function B::foo(int).
    If for your particular code you do not see a warning with C++ 5.3, it would be due to a bug in C++ 5.3 that was later fixed.

  • Class override, how to create the child class and then the base class

    I started to write a program for a smart DMM, the problem is every version of the DMM the company change the communication commend.
    My idea is to write a child class for every DMM version and every SubVI of the child will override the base class SubVI.
    My problem is, i want first to create one child class and after i will see every thing is work,  start to create the base class. that way i will see if am thinking the right way.
    My question is
    How can i create a child class and then create the base class and configure the SubVi of the child class to be Override of the base class?
    I tried to search in the property of the class but i didn't see nothing.
    Thanks
    Solved!
    Go to Solution.

    This can be done and I've done it on occasion.
    You simply create the base class with the dynamic dispatch methods you require (connector panes need to be identical to thos of the child class).
    Then set the inheritance of the class to inherit from this base class.  If your method is defined as a dynamic dispatch method in the parent, you'll most likely now have some errors (unless your child method was already DD in which case you might just be OK already).
    To change the inheritance of a class, right-click the properties of the class in your project and select properties.  I believe the ineritance tree is at the lower end of the properties.  Click on the "change inheritance" (or something similar) to choose the class from which you now wish to inherit.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • Data type of the base attribute or the base value does not match...

    ...the assigned expression.
    Hello all,
    I always get the Error
    +<ERROR+
    TEXT="'DWH.CUB_REGISTRATIONS_AW.REGISTRATIONS': XOQ-02517: Der Datentyp des Basisattributs oder der Basisgröße stimmt nicht mit dem zugeordneten Ausdruck überein.
    XOQ-01400: Ungültige Metadatenobjekte"/>
    The English message must be something like this:
    The data type of the base attribute or the base value does not match the assigned expression.
    when I run my mapping. The attribute REGISTRATIONS is NUMERIC (12,2) in the Cube and I map a NUMERIC(12,2) constant in it.
    I use a simple OWB-Mapping for loading, but I don't understand why it doesn't function. Other mappings where the attributes are out of a
    table I put in a cube are running well.
    I tried different things, but nothing fixed my problem. Any idea ?
    Thanks a lot for help
    Michael

    Technically this is a 'warning' from the server, not an 'error'. This means that the change you made should have been submitted, but you get an warning message on the client. AWM would suppress this warning, but evidently OWB does not. Can you switch to use AWM?
    Here is the definition of the warning along with 'cause' and 'action' sections. (Unfortunately these sections are not translated into German for some reason.)
    >
    02517, 0, "The data type \"%(1)s\" of the base attribute or base measure is different from the mapped expression \"%(2)s\"."
    // *Cause: Either the base attribute or base measure with the mapped expression was set to an inconsistent data type, or it was mapped to an expression of a different data type from its fixed data type.
    // *Action: When changing a mapped expression for a base attribute or base measure, ensure that the expression has the same data type; otherwise, set the data type of the base attribute or base measure to NULL first. When a base attribute or a base measure has an existing mapped expression, do not set it to a different data type.
    >
    It is probably safe to ignore this warning, but if you can post the relevant XML for the cube, then will probably be able to spot the problem. I assume that REGISTRATIONS is a measure in the cube CUB_REGISTRATIONS_AW, so this is what you can look for in the XML:
    (1) The definition of the base measure along with the datatype. It should be something like this
    <Measure>
      <BaseMeasure
        SQLDataType="NUMBER(12,2)"
        ETMeasureColumnName="REGISTRATIONS"
        Name="REGISTRATIONS">(2) The mapping info for the measure, which should looks something like this:
    <MeasureMap
      Name="REGISTRATIONS"
      Expression="...">
      <Measure Name="REGISTRATIONS"/>
    </MeasureMap>I don't know if you can get the XML directly from OWB. If not, then DBMS_CUBE.EXPORT_XML should work (assuming you are in 11.2). You could also attach AWM and save the cube to an XML template.

  • [svn:osmf:] 13027: Fix bug in SerialElement where the durationReached event was dispatched on a child-to-child transition due to the base class thinking that the duration had been reached  (since the second child didn't have a duration yet).

    Revision: 13027
    Revision: 13027
    Author:   [email protected]
    Date:     2009-12-16 18:09:46 -0800 (Wed, 16 Dec 2009)
    Log Message:
    Fix bug in SerialElement where the durationReached event was dispatched on a child-to-child transition due to the base class thinking that the duration had been reached (since the second child didn't have a duration yet).  Injection from trait refactoring.
    Modified Paths:
        osmf/trunk/framework/MediaFramework/org/osmf/composition/CompositeTimeTrait.as

    http://ww2.cs.fsu.edu/~rosentha/linux/2.6.26.5/docs/DocBook/libata/ch07.html#excatATAbusErr wrote:
    ATA bus error means that data corruption occurred during transmission over ATA bus (SATA or PATA). This type of errors can be indicated by
    ICRC or ABRT error as described in the section called “ATA/ATAPI device error (non-NCQ / non-CHECK CONDITION)”.
    Controller-specific error completion with error information indicating transmission error.
    On some controllers, command timeout. In this case, there may be a mechanism to determine that the timeout is due to transmission error.
    Unknown/random errors, timeouts and all sorts of weirdities.
    As described above, transmission errors can cause wide variety of symptoms ranging from device ICRC error to random device lockup, and, for many cases, there is no way to tell if an error condition is due to transmission error or not; therefore, it's necessary to employ some kind of heuristic when dealing with errors and timeouts. For example, encountering repetitive ABRT errors for known supported command is likely to indicate ATA bus error.
    Once it's determined that ATA bus errors have possibly occurred, lowering ATA bus transmission speed is one of actions which may alleviate the problem.
    I'd also add; make sure you have good backups when ATA errors are frequent

  • How to get maximal value from the data/class for show in Map legend

    I make WAD report that using Map Web Item.
    I devide to four (4) classes for legend (Generate_Breaks).
    I want to change default value for the class by javascript and for this,
    I need to get maximal value from the class.
    How to get maximal value from the data/class.
    please give me solution for my problem.
    Many Thx
    Eddy Utomo

    use this to get the following End_date
    <?following-sibling::../END_DATE?>
    Try this
    <?for-each:/ROOT/ROW?>
    ==================
    Current StartDate <?START_DATE?>
    Current End Date <?END_DATE?>
    Next Start Date <?following-sibling::ROW/END_DATE?>
    Previous End Date <?preceding-sibling::ROW[1]/END_DATE?>
    ================
    <?end for-each?>
    o/p
    ==================
    Current StartDate 01-01-1980
    Current End Date 01-01-1988
    Next Start Date 01-01-1990
    Previous End Date
    ================
    ==================
    Current StartDate 01-01-1988
    Current End Date 01-01-1990
    Next Start Date 01-01-2005
    Previous End Date 01-01-1988
    ================
    ==================
    Current StartDate 01-01-2000
    Current End Date 01-01-2005
    Next Start Date
    Previous End Date 01

  • Can i create more than one attributes for the custom class created using java API

    Hello everyone,
    I have been creating class and its attributes programatically using java APIs, I want to know that is there any way to create multipal attributs for the same class in just one call of API with all the options for each attributes,
    thanks

    You can create a new class and define all of the Attributes at the time the class is created - this is the preferred way of creating classes. Use the addAttributeDefinition() method on ClassObjectDefinition. If you need to add attributes to existing classes, you can only add them one at a time (using the addAttribute() method on ClassObject).
    (dave)

  • A weird ticking sound from the base of my macbook pro?

    My macbook pro was bought in October 2011 but I think it's the Early 2011 edition. It's an 15 inch. My problem is that I hear a weird ticking noise coming from the base of the computer. It sounds like it is coming from under the keyboard and the mouse pad. I usually hear it whenever I move it around or place my hands on the hand rest spot(?) when I'm typing. Anybody know if I should be worried or how to fix it? The sound is really annoying... Let it be known that I baby my macbook pro. I have never dropped it on the floor or slammed it on a table or something.
    Thank you in advance
    P.S. If it matters, I'm running on
    Mac OS X Lion 10.7.2.

    That could be the stepping motor in the hard drive making noise.  Sometimes the noise means nothing, other times it could mean a problem with the hard drive and it could fail soon.  Could be a fan out of allignment.  If you can backup your data, do so.  If you an get to an Apple genius bar, take it in and have the techs run some tests to find out what the noise is.

  • Issue on deployment: Solution Deployment : Missing one or more of the following attributes from the root node in solution .wsp: assembly '', type ''

    Hi,
    I have the following issue when deploying:
    Solution Deployment : Missing one or more of the following attributes from the root node in solution .wsp: assembly '', type ''
    The solution is a farm solution (was never sandbox) and it deploys fine.
    It was updated several times with success. We did not see this issue until recently when we had some other issue (unrelated) and looked at the logs. The solution is updated without problem and updates are available for the user. But we can see this error
    in the logs at the update time. 
    Any idea what might cause this?
    Pop Anisia

    Hi,
    This error is wide meaning, as it can come from differences between SP versions, variables types used, bad manifest file, WebConfiguration ...
    You can try to redeploy the solution.
    retracted the solution,removed all the previous ref, removed dll from GAC and folder from 14\features and reset the iis, deploying it again.
    Here are some similar issue post, you can use as a reference:
    https://social.technet.microsoft.com/Forums/office/en-US/72ac9a02-3a51-48b8-9e36-3b24a2d4da74/missing-one-or-more-of-the-following-attributes-from-the-root-node-in-solution-alertbdcwsp?forum=sharepointgeneralprevious
    https://social.technet.microsoft.com/Forums/office/en-US/331af288-5ba6-48a7-9e9d-ac4e4bc8f8fa/missing-one-or-more-of-the-following-attributes-from-the-root-node-in-solution-xxxwsp-assembly-?forum=sharepointdevelopmentprevious
    In additional, you can check the ULS log (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS) to get the detailed information.
    I hope this helpful.
    Best Regards,
    Lisa Chen
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Can you run a wired router from the base station?

    I have a Airport Extreme base station, I bought it about 6 months ago so it's not too old. My question is can you plug a wired switch, hub or router into it? I was told no at the apple store but I don't see why you could not. All I want to do is run a 8 port switch from the base station so I can connect my other wired comps to the net. Thanks!

    My question is can you plug a wired switch, hub or router into it?
    Yes, just connect it to the LAN port on the AirPort Extreme base station (AEBS).
    I was told no at the apple store...
    They gave you incorrect information.

  • Measure using UseRelationship not working well when sliced with attributes from the same table

    Hi,
    I have Measure created using the 'UseRelationship' Function, which uses a different datekey to link to the DateDim than the one the table is directly related by. The measure works as expected except in one scenario.
    If I browse the measure using an attribute from the same fact table then the attribute is filtered using active relationship whereas the measure is filtered using the inactive relationship as shown below:
    FACT(2 rows)(Active Relationship to Date using DateKey1)
    SNo     DateKey1     DateKey2     Geo        Amt
    1         20100101     20120101    India      100
    2         20100101     20120101    US         200
    AmtMeasure:=CALCULATE(SUM([Amt]),USERELATIONSHIP(FACT[DateKey2],'Date'[DateKey]))
    If I browse the above measure in excel, with Year selected as 2012, I get 100+200=300. Now if I drag the Geo attribute against the measure I get 2 rows with 100 and 200.
    If I do the same in a power view report I don't get any results after dragging the Geo attribute, whereas I get the correct value of 300 without the geo attribute. I checked the DAX query which the power view generates and figured this is being caused because
    there are no rows in the table with DateKey1 having year 2012. I understand why this is happening this way in a DAX query and not in MDX, but shouldn't both behave in the same way and what is a work around.
    Thanks,
    Sachin Thomas

    Sac, is this still an issue?
    Thank you!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Is it possible to call a subscreen/modal dialog box from the global class

    Hi,
    Is it possible to call a subscreen or modal dialog box from the global class ..
    or is there any option to display a pop screen or subscreen in order to get the values from user which as to be implemented
    in the global class..
    thanks and regards,
    Poornima.

    Hi Poornima,
    you should follow Uwe's suggestion. The only alternative I can imagine is dynamic document in a dialog container. But I don't know any standardized classes to make use with minimum effort. Have a look at report DD_ADD_FORM_INPUT. Here they put the input field in a container control in a screen; you can put the container control on a dialog container (CL_GUI_DIALOGBOX_CONTAINER).
    We will not get rid of any screen for the time being, but if your application is started from any screen, the DIALOGBOX_CONTAINER can start from there.
    Regards,
    Clemens

  • Can music from the ipod classis be uploaded to icloud? If so, can someone tell me how to accomplish this task?

    Can music from the ipod classis be uploaded to icloud? If so, can someone tell me how to accomplish this task?

    Hi Crystal,
    So I cancelled the first & only order I will ever make thru this company & want my account deleted.
    I can't get thru to anyone by phone or chat. Is there no other way to accomplish this?
    Sorry for this hassle. No, you need to contact them. What is the problem you are facing in contacting them?
    What happens if I sign out & just never sign back in?
    You might still get charged. Let me know if you still can't get through.
    Thanks,
    Kevin

  • [svn:bz-trunk] 21260: Update the qa-frameworks. zip to remove all comments from the base xml when merging config files.

    Revision: 21260
    Revision: 21260
    Author:   [email protected]
    Date:     2011-05-16 07:46:54 -0700 (Mon, 16 May 2011)
    Log Message:
    Update the qa-frameworks.zip to remove all comments from the base xml when merging config files.
    Modified Paths:
        blazeds/trunk/qa/resources/frameworks/qa-frameworks.zip

    Try options=('!makeflags') in PKGBUILD.

Maybe you are looking for

  • Mapping Multiple Nodes ?

    Hi Guys, Request Structure - Node - occurs   0 - unbound Target Structure - Node - occurs  0 - unbound If there are 3 transactions coming from the reguest structure then i need to generate only 2 node structures on the target side.  can anybody expla

  • MacMini 2011 VGA output

    Hi, I've read many threads about people having issues with VGA monitors (via mini display port adapters) going blank.  It seems to be when booting, coming out of sleep mode and when changing resolution.  It also seems to be intermitant.  The VGA outp

  • Flash hyperlink issue

    So for some reason the hyperlinks in my flash show are not working. If you go directly to the URL of the flash show itself, the hyperlinks work fine...but once you embed them into even a simple html page, they seem work for a short period of time, an

  • NokiaMServer.exe removal

    HI there, I am added this to the end of another thread but it seems that it might not be read there so I am adding a new topic as it might be noticed this time around. I have uninstalled all the software for the Nokia phone on my PC but for some reas

  • Reports builder alignment different that pdf aligned

    I'm using Oracle Reports 10g I have a report that output to a pdf, I have to make the report misaligned from report builder runtime (screen) so it aligned when it runs from the applications server development to pdf; that works in our development ser