Dynamically return a list of all class variable values in Java
<p>I am creating a helper class in parsing XML elements, so the developer do not need to know the exact name and capitalization of the XML fields. </p>

<pre><code>private static class TagNames{
      public static String RESOURCE_ID = "ResourceId";
      public static String RESOURCE_NAME = "ResourceName";
      public static String RESOURCE_PRICE = "ResourcePrice";
}
</code></pre>

<p>This makes it easier to do things like:</p>

<pre><code>someXMLParser.getValueByTagName(TagNames.RESOURCE_ID);
</code></pre>

<p>My question is this. If I want to iterate over all the fields declared in class TagNames, how do I do that? Pseudocode:</p>

<pre><code>For tag in TagNames:
   someXMLParser.getValueByTagName(tag)
</code></pre>

<p>I know I will probably have to restructure all of this. But I can't figure out a way to make the names easily accessible as well as iterable, without any duplication.</p>

<p>Any suggestions? </p>
