0

I have a class as such:

public interface ControlService extends RemoteJsonService
{

    public void myValues( String [] Names, AsyncCallback<Map<String,RegisterValues>> callback); 

    public class RegisterValues
    {
        int FirstField;
        int SecondField;
                //etc. 200 times

I have a string as such:

String[] fieldValues = new String[]{"FirstField", "SecondField", ....}; //200 of these

My attempt at calling upon these fields (the important part is towards the end):

public class RegistersPanel implements TestStandPanel, ChangeHandler
{
    private ControlService service_;

    public RegistersPanel(){

        service_.RegisterValues( Names, new AsyncCallback<Map<String,ControlService.RegisterValues>>()
                {
                public void onSuccess( Map<String,ControlService.RegisterValues> result )
                    {

                        for( String Name : result.keySet() ){
                            for (String Values : fieldValues){
                                message+=result.get(Name).getField(Values); //something like this but I can't quite figure out the syntaxt
                                //message+=result.get(Name).FirstField; this is tedious 
                            }

As you can see, I can't just use getField, and Eclipse is giving me no helpful options - any advice?

fiz
  • 906
  • 3
  • 14
  • 38
  • 200 of these? Are you serious. What exactly are you trying to do? – Rohit Jain Mar 25 '14 at 16:36
  • Use GSON to parse a Map of Maps - you can't do it without doing this silly/ugly method. I just want to call upon these field values without having to type it out another 200 times. – fiz Mar 25 '14 at 16:38
  • And the number is actually closer to 256 values – fiz Mar 25 '14 at 16:38
  • Fiz, are you sure you can't do it using another method? – Charlie Mar 25 '14 at 16:58
  • I've asked and no one seems to be able to give me a pointer to a better way to parse a Map of Maps. http://stackoverflow.com/questions/22637077/parsing-json-map-of-maps-with-gson – fiz Mar 25 '14 at 16:59
  • @fiz Take a look at your question http://stackoverflow.com/questions/22637077/parsing-json-map-of-maps-with-gson . Maybe you can now solve part of your problem. – rpax Mar 27 '14 at 23:05

1 Answers1

0

I think this is something what you are looking for inside the double for loop,

RegisterValues  regValue=reuslt.get(Name);      
regValue.getClass().getDeclaredField(Values).getInt(regValue);

This is not the exact solution. This just gets you access to the fields value inside that class. P.S: that Values would look nice if changed to value

Jimmy
  • 2,589
  • 21
  • 31