Better way to map from String constants to int constants in Java
<p>I have a load of images of musical symbols which I need to do some processing on and for each one I need to get the integer code corresponding to its file name. There are 23 possible file name strings and 23 integer code and there are many images with the same name under different directories.</p>

<p>The solution I have so far is given (abbreviated) below. I have just defined a load of <code>int</code> and <code>String</code> constants and then written a method which is just a huge chain of <code>if</code> statements to do the translation.</p>

<p>What would be a better way to achieve the same effect? The way I've done it seems really awful! I thought about using some kind of <code>Map</code>, but I wasn't sure of the best way to do so.</p>

<pre><code>public class Symbol {
    public static final int TREBLE_CLEF = 0;
    public static final int BASS_CLEF = 1;
    public static final int SEMIBREVE = 2;
    // ...

    public static final String S_TREBLE_CLEF = "treble-clef";
    public static final String S_BASS_CLEF = "bass-clef";
    public static final String S_SEMIBREVE = "semibreve";
    // ...

    public static int stringCodeToIntCode(String strCode) {
        if (strCode == S_TREBLE_CLEF) {
            return TREBLE_CLEF;
        } else if (strCode == S_BASS_CLEF) {
            return BASS_CLEF;
        } else if (strCode == S_SEMIBREVE) {
            return SEMIBREVE;
        } //...

        else {
            return -1;
        }
    }
}
</code></pre>
