How to get private fields from super class?

Hi.
I must get protected and private fields from a class. I know that sounds werid but I have a very good reason for doing so, ask if you want.
I have tried the getDeclaredField(String) method, but it apparently doesn't return the fields declared by the super classes.
What's the smartest solution to this?
Thank you all.
edit: note that the superclass hierarchy's length is 3 and that there are several classes at the bottom level.
Edited by: bestam on Sep 24, 2009 2:05 PM

bestam wrote:
I do not claim I have invented a new programming language Sir, you must be mistaken. This is not turing complete.
This is a language for describing Cards or a game's rules if you want.
AspectJ isn't Turing complete but AspectJ is still a compiler.
This is how I have been working :
- I have implemented the core library in Java (what is a Player, what is an Effect, what is a Card, what is a BuildingCard, what is a Player's Turn and so on)
- It also includes packages dedicated to service, able to retrieve and send data to the clients via sockets.
- Then I have "hardcoded" a dozen of specific cards in Java, for testing and validating the core library. I have been doing so by extending the BuildinCard's class for example.
- But my ultimate goal is not to code thoses 1.000+ cards of the game in Java. I chosed to design a little language so that I would end up writing cards faster. While I'm traversing the syntactical tree representing the card, I feed the card's fields one by one. Some of them are quite primitive, some other are more complex and have a recursive nature for instance.
Providing detail for how you implemented it doesn't change anything about what I already said.
Thus, this is not really a compiler as it doesn't transform a text in language A into a text in language B.
You really need to understand more about what "compilers" and certainly compiler theory do before you decide what they can and cannot do.
And your statement still does not change what I said.
Is this wrose than the bean design pattern from JSP ? I'm not sure.
Bean design? A "bean" has almost zero requirements.
Aside of that, it's a bit harsh to be told "read the fucking manual" while I have written my first compiler some years ago.Not sure who that was directed. I suggested some reading material on compiler theory.
If you think that your idea is ideal then knock yourself out. Since I doubt I will end up seeing it in anything that I must maintain it doesn't matter to me. But you did in fact ask what the best solution was.

Similar Messages

  • How to get additional field from the second list base on lookup information column ?

    Hi everyone,
    Currently I created a SharePoint hosted Apps project and I need to know how can I get additional field from the second list base on lookup information column. example List1 Have 2 columns column1 and column2(Lookup Information from list2 (category)),
    List2 have 3 columns title, and category, and color.  so how can get the title and color from list2 base on this lookup information column (SharePoint Hosted apps and Javascript code)? that is possible?
    Best regards,
    ------------------------------------------------------------ ---Tola---

    You can build one custom lookup control. Refer to the following post
    http://www.stuartroberts.net/index.php/2012/10/03/enhanced-lookup-field-part-1/
    Alternatively, try the following solution from codeplex
    http://sp2010filteredlookup.codeplex.com/
    http://filteredlookup.codeplex.com/
    --Cheers

  • How to get Ethnicity field from IT 77 into BI

    We are in middle a new implementation of BI HCM and users want Ethnicity & Ethnic origin fields in BI. I can see Ethnic Origin as a attribute of Employee but can't find Ethnicity anywhere in standard BI content. What is the simplest way to get Ethnicity field from IT 77 (maintained by client) into BI.

    I would recommend enhancing the 0EMPLOYEE_ATTR DataSource by adding the Ethniticty column in an append structure of the extraction structure for that DataSource. Then to populate that field in the 0EMPLOYEE_ATTR DataSource, create a User Exit in CMOD (Function Module EXIT_SAPLRSAP_002).
    Then on BW, you're going to need to replicate the modified DataSource and in the 0EMPLOYEE InfioObject make sure you identify the attribute for Ethnicity as Navigational or Display. Then update the transformational processes to load into 0EMPLOYEE. Finally, you will need to add this custom InfoIObject to other InfoProvider(s) that you need it in (if any) to meet your end customer reporting requirements.
    Edited by: Dennis Scoville on Sep 10, 2009 8:33 PM

  • How to get array values from one class to another

    Supposing i have:
    - a class for the main()
    - another for the superclass
    And i want to create a subclass that does some function on an array object of the the superclass, how can i do so from this new subclass while keeping the original element values?
    Note: The values in the array are randomly generated integers, and it is this which is causing my mind in failing to comprehend a solution.
    Any ideas?

    If the array is declared as protected or public in the superclass you can directly access it using its identifier. If not, maybe the superclass can expose the array via some getter method.
    If this functionality can be generified (or is generic enough) to apply to all subclasses of the superclass the method should be moved to the superclass to avoid having to reproduce it in all the subclasses.

  • How to get Required field from R/3 to  load in Bw.

    To get a perticular value from R/3 to BW . in r/3 side I need to go to first table equi from there i pick equipmentno on the basis of this number i need to go to objnr from objnr i need to pick up objnr number and i have to see this number's value in table AUSP. like this same scenario i am facing in master as well as transaction tables , how i should fetch these values and load to BW .
    In standard datasources if i want to add the field value of which is derived by the value in two more tables then how do i Enhance the datasource.
    Can any one give clue to resolve It.

    Hi Srinivas,
       If you want to enhance any data source, by appending any field from any table.. basic rules are
    1. All the key fields in that perticular table should be available in your data source.
    2. Similar for more fields from different tables.
       Or if you want to extract more fields from different tables try to create a View on these table and go for generic extraction(create data source on this View). Choose which one if best option for your requirement.
    Hope it Helps
    Srini

  • How to get back fields from INSERT statement in batch mode(getGeneratedKeys

    Hi,
    I wanted to insert records to database and get back some fields.
    I create prepared statement:
    preparedStatement = connection.prepareStatement(sqlQuery, columnIndexes);
    then I set parameters.
    Following code works properly:
    preparedStatement.executeUpdate();
    generatedKeys = preparedStatement.getGeneratedKeys();
    if (generatedKeys.next()) {
    doSomething();
    But when I try to do this by batch I get exception:
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 22
         at oracle.jdbc.driver.T4CNumberAccessor.unmarshalOneRow(T4CNumberAccessor.java:190)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:612)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:966)
         at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10644)
         at org.jetel.component.DBOutputTable.runInBatchMode(DBOutputTable.java:619)
    My "batch" code:
    for(...){
    setParameters(preparedStatement);
    preparedStatement.addBatch();
    preparedStatement.executeBatch();
    Isn't it a bug?
    Can I get back fields (eg. from last insert added to batch)?
    I hope somebody can help me.
    Agata

    This code works for me but only inserting one row. More than one causes an ArrayIndexOutOfBoundsException once sendBatch is called.

  • Question reg. how to get a field from a table

    What is EIN? (I think it is employer identification number). My functional consultant told me to get this value from company code. Can you tell me from which table and field I can get this value?
    Thanks,
    Krishen

    i think these tables are helpfull
    /SAPPCE/TDPC01
    /BEV1/RBVBAK
    /BEV1/RBVBAP
    VSVBAK_CN
    VSVBAp_CN
    VBAK and VBAP.
    Regards,
    Pradhan.

  • How to get UCM content from Java class?

    Hello,
    I need to get UCM content from backend I mean from the Java class. Is there any way to do that? If anybody please give any resources it will be very helpful.
    Thanks and regards.

    Hi
    You mean to say that with JAVA API you want to search and retrieve the contents ? If yes , then you should use RIDC API for the same and that way you can use to do all the operations on UCM from the JAVA Api .
    Search this forum and you will get sample codes for the checkin , search , checkout operations .
    Documentation is available at : http://docs.oracle.com/cd/E14571_01/doc.1111/e16819/toc.htm
    Thanks
    Srinath

  • How to get jhelp field from DefaultHelpBroker

    Since java help 2.0 most of protected fields such as frame and jhelp got disappeared.
    About frame field, I can get this field using "getWindowPresentation().getHelpWindow() method.
    But I can't find any method to get "jhelp" field which was a protected field in earlier version.
    Anyone knows?
    Thanks ahead.

    I would recommend enhancing the 0EMPLOYEE_ATTR DataSource by adding the Ethniticty column in an append structure of the extraction structure for that DataSource. Then to populate that field in the 0EMPLOYEE_ATTR DataSource, create a User Exit in CMOD (Function Module EXIT_SAPLRSAP_002).
    Then on BW, you're going to need to replicate the modified DataSource and in the 0EMPLOYEE InfioObject make sure you identify the attribute for Ethnicity as Navigational or Display. Then update the transformational processes to load into 0EMPLOYEE. Finally, you will need to add this custom InfoIObject to other InfoProvider(s) that you need it in (if any) to meet your end customer reporting requirements.
    Edited by: Dennis Scoville on Sep 10, 2009 8:33 PM

  • Setting private fields from Parent class.

    Hi all, I have what seems to be a weird situation to me.
    Basically I have two classes:
    import java.lang.reflect.Field;
    public class Parent {
         protected void ensureDefaults() {
              Field[] declaredFields = getClass().getDeclaredFields();
              for (Field field : declaredFields) {
                   Object fieldValue = getDefaultValueForType(field.getType());
                   try {
                        System.out.println("defaulting field - name: " + field.getName() + " | this: " + this);
                        field.set(this, fieldValue);
                   } catch (Exception e) {
                        e.printStackTrace();
         private Object getDefaultValueForType(Class<?> type) {
              Object defaultValue = null;
              if (type.isAssignableFrom(String.class)) {
                   defaultValue = "default";
              } else if (type.isAssignableFrom(int.class)) {
                   defaultValue = -100;
              return defaultValue;
    public class Child extends Parent {
         private String name;
         private int age;
         public Child() {
              ensureDefaults();
         public String getName() {
              return name;
         public void setName(String name) {
              this.name = name;
         public int getAge() {
              return age;
         public void setAge(int age) {
              this.age = age;
    // Test Case
    import junit.framework.TestCase;
    public class ChildTest extends TestCase {
         public void testEnsureDefaults() {
              Child child = new Child();
              assertEquals("default", child.getName());
              assertEquals(-100, child.getAge());
    }The odd thing to me is that the output looks like:
    defaulting field - name: name | this: Child@7431b9
    java.lang.IllegalAccessException: Class Parent can not access a member of class Child with modifiers "private"
    ... more exception ...
    defaulting field - name: age | this: Child@7431b9
    java.lang.IllegalAccessException: Class Parent can not access a member of class Child with modifiers "private"
    ... more exception ...
    As you can see, it doesn't like me setting (or getting for that matter - tried that) these fields because they're private. However, if you look it's saying that "this" is a Child, so shouldn't those fields be accessible? Shouldn't ensureDefaults be executed as if it was being called by the Child instance?
    Obviously, I can try to use the accessor methods, but that means creating strings for method names, and then looking for the methods. I'd like to avoid this and it seems to me this should work, no?
    Another odd thing is that if I change the fields in Child to protected, it works fine.
    Also, I'm not sure if this is important (I don't know enough about security managers to know if they're different platform to platform, version to version), I'm on a Mac OSX 10.4.11 and:
    java version "1.5.0_13"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-241)
    Java HotSpot(TM) Client VM (build 1.5.0_13-121, mixed mode, sharing)
    Any help with this would be greatly appreciated.
    Thanks,
    Eric

    jschell wrote:
    As you can see, it doesn't like me setting (or getting for that matter - tried that) these fields because they're private.Myself I don't like it because it suggests a design problem which is associated with understanding that although a child is a parent that doesn't mean that a parent is a child.
    I understand that, but I don't see how this actually breaks that. The Child is executing a method that is passed down to it from it's Parent, but it's executing it as itself - by that I mean it's not looking at anything that it can't already look at, or at least I thought it was.
    Shouldn't ensureDefaults be executed as if it was being called by the Child instance?No.Ok, I thought it was. Can you please explain this a bit more, I want to understand it.
    >
    Another odd thing is that if I change the fields in Child to protected, it works fine.If you messed with reflection some more you could get to to work even with private. How exactly? I really don't want to bypass any security measures (by settings accessible or using a different security manager, or anything like that). As I mentioned in my last post, what I want to do really is nothing more than a nice way to have a generic toString or hashCode method, if it's not possible to do it nicely - within java's default constraints, I'd rather not.
    >
    However in general the idiom would still be wrong.I'm moving more towards using beans anyway, so I plan on just calling accessor methods which corrects the "wrong idiom" right?
    Thanks for all the help,
    Eric

  • How to get a field from an attached excel/csv?

    I currently manage some price lists for the company I work for. They are graphical, and usually created in inDesign and then exported to pdf.
    I'm looking for a way to attach our company's prices in an excel sheet, (or delimited file) and be able to pull a price into the pdf.
    For example, attaching an excel file with 2 columns, SKU & Price. Then saying, if text field SKU= "APPLE" text field PRICE = "0.50". Only I don't want the user to have any inpurt options, I want to do this myself and then save a flat version to distribute in the company.
    I've been working on this for a few weeks. My javascript skills are really rough.
    So far, I have some code in my pdf that looks like this:
    (Price.csv is an attachment in the PDF)
    var oFile = this.getDataObjectContents("Price.csv");
    var sData = util.stringFromStream(oFile, "utf-8");
    function ParseData(sData){
    var oData = {};
    sData.replace(
    new RegExp( "\\[(\\w+)=([^\\]]*)\\]", "gi" ),
    function( $0, $1, $2 ){
    oData[ $1 ] = $2;
    return( oData );
    // Parse the data into an object
    var oData = ParseData(sData);
    // Custom Calculate script for price text field
    (function () {
        // Get the value of the SKU field
        var sku = getField("SKU").valueAsString;
        // Look up the price
        var price = oData[sku];
        // Set the value of this field to the price if it's present,
        // otherwise blank this field
        event.value = price || "";
        console.println(price);
    I have two text fields on the form. One that I have filled in a valid SKU, and a blank one named event.
    I seem to be getting an undefined error on prices. I am completely lost as to where to go from here.
    Does anyone have an idea of where I may be going wrong? I get that undefined error and nothing appears on my form.
    Thank you in advance.
    (I have acrobat X pro)

    First of all, "undefined" is not an error. It just says that the script ended without returning any values.
    I would suggest starting by debugging the code that reads the input file (you have to use a plain-text file, by the way, not an Excel spreadsheet). Make sure that oData actually contains the data you expect it to contain. If that works OK, start debugging your calculation script and see what's going on there...

  • How to get invoice field from SD tables

    Hi, experts,
    what is the "invoice field name" in SD tables.
    please specify in which tables i can find it

    Hi Praveen,
    in SD the order,delivery or invoice , evrything has field name vbeln.
    only difference is which table your are referreing.
    if you are working on VBAk, the vbeln will give the sales order..
    if in LIPs, it will give delivery while in VBRK for vbeln you will get invoice number.
    VBFA will give you the complete flow of order, delivery and invoice
    e.g:-
    Find sales order number and item from the delivery document
    number and delivery item no by using sales document flow table
        select single VBELV POSNV from VBFA into ITAB where
               VBELN = mseg~oivbeln and         "delievry
               POSNN = mseg~oiposnr,     and  "Delivery item
               VBTYP_N = 'J'.

  • How to get protected fields

    Hello,
    I don't know how to get protected fields that a class inherits from its superclass through reflexion ... the getDeclaredFields method seems not working ...
    here is my test program:
    import java.io.File;
    import java.lang.reflect.Field;
    public class Test {
         public static void main(String[] args) {
              Field [] fieldList = SubClass.class.getDeclaredFields();
              for (Field field: fieldList) {
                   field.setAccessible(true);
                   System.out.println (field.getName());
         static class SuperClass {
              protected File file;
              public SuperClass () {
                   file = new File ("a.txt");
         static class SubClass {
              private File myfile;
              public SubClass () {
                   myfile = new File ("b.txt");
    The output is
    myfile
    This means, the getDeclaredField method of the SubClass returns only fields declared by this class, not protected fields declared by its superclass.
    Anyone has an idea to fix the problem, please help me. Thank you a lot
    }

    That's not a problem, the documentation specifically says that getDeclaredFields() only returns fields from this class. If you want fields from the superclass, why not just getSuperclass().getDeclaredFields()?

  • How to get the message from a Runnable class

    The Schedule class is actually a JFrame, what I want to do is to "get" the message from Scheduler Class and display it in a JTextField, to let user know what is doing.
    How can I approach this?
    public class Schedule {
        @SuppressWarnings("static-access")
        public static void main(String args[]) throws InterruptedException {
            final Scheduler s = new Scheduler();
            Thread t = new Thread(s);
            t.start();
    public class Scheduler implements Runnable{
    private static int actionType;
    private static String msg;
        public static void setMsg(String msg) {
            Scheduler.msg = msg;
        public static String getMsg() {
            return msg;
        public void run() {
            //System.out.println((int)(Math.random() * 1000));
            actionType = 1;
            while(true){
                try {
                    switch(actionType){
                        case 1:
                            setMsg("Process actionType: "+actionType);
                            break;
                            case 2:
                            Thread.sleep(2000L);
                            setMsg("Process actionType: "+actionType);
                            break;
                            case 3:
                            Thread.sleep(2000L);
                            setMsg("Process actionType: "+actionType);
                            break;
                            case 4:
                            Thread.sleep(2000L);
                            setMsg("Process actionType: "+actionType);
                            break;
                    actionType++;
                    if(actionType>4){
                        actionType = 1;
                } catch (InterruptedException ex) {
                    System.out.println("Scheduler.run:"+ex.toString());
    }

    Or with only one loop:
            int actionType = 0;
            while (true)
                actionType = (actionType % 4) + 1;
                msg = "Process actionType: " + actionType;
                try
                    Thread.sleep(2000L);
                catch (InterruptedException ex)
                    System.out.println("Scheduler.run:" + ex.toString());
            }

  • 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

Maybe you are looking for

  • How to transfer movies from mac book to ipad, how to transfer movies from mac book to iPad, how to transfer movies from mac book to iPad

    I have downloaded a tv series onto my mac book and want to transfer it to my Ipad. I have used the USB cable to try and transfer and sync but it wont work can anyone help Thank you

  • Organizing object in 10g

    In Jdeveloper, there is "project" concept to group all related files relating to Order subsystem, for instance. So, is it a good best practice to create all required EO or VO under this Order subsystem project or we should create all EO/VO under Mode

  • Posting message to a third party System

    Hi All          I m working on a scenario where I m using the R/3 system as the sender and using Idoc as the message type. The receiver system wants to hide its technical system details and hence I m unable to create a technical system for the same i

  • Importing spanned .mp4 AVCHD files

    My client shot a long video on a Samsung HMX-F80 camcorder  He mailed the SD card to me.  As one would guess, if I import the .mp4 files into Premiere CS5.5 (Windows), there is a slight bit of video missing at the borders of each clip.  I tried impor

  • Delta data upliad problem

    Hi, I am facing problem delta data uploading.  Following steps as follows which I have done : 1.     First I have upload the data with Initialize delta process ( Initialization with Data transfer ) It was working fine and uploaded data to ODS. 2.