mardi 21 mars 2017

Getting the object with matching classname using Reflection

I am working on a code, where in I am required to read the XML file. I have successfully done it using JAXB, and have successfully maintained it in an object. But my issue is that I will have a hierarchy of class as in

<a>
   <b>12</b>
      <c>
        <d>
          <e>11</e>
        </d>
      </c>
</a>

And the same structure is maintained in the class too. My issue is given the name of the class, will it be possible to extract the object which has already been loaded by XML in the hierarchy? Is is possible through reflection? If so how? And if not is there any work around(as in maintaining any relationship in some file and using that I can directly navigate to the required object). In short I want my code to be dynamic. The purpose of the code is that it will be validating the values in the xml with the values I input. And I can input the values of any node to be validated from a large XML file.





Aucun commentaire:

Enregistrer un commentaire